Computer System Basis
Listen mooc Nanjing University Yuan Chunfeng teacher's lecture notes
- Under ISO C90 standard on 32-bit systems
Results The following C expression of what is?
-2147483648 <2147483647
false (from the truth)! Why?
Expression result less to do with it?
I = -2147483648 int;
I <2147483647
to true! Why?
-2147483647-1 <2147483647, the result of what?
#include<stdio.h>
int main()
{
if(-2147483648 < 2147483647)
printf("false\n");
else
{
printf("true\n");
}
return 0;
}
If the expression is replaced -2147483647-1 <2147483647
results and what will happen
- How to deal with compiler literal
- High-level language operation rules
- Correspondence between high-level language instruction
- Execution of machine instructions
- Machine-level representation of the data and calculation
- When the parameter len is 0, return value should be
0, but executed on the machine, but send
raw memory access exception. But when an int len
is normal. Why?
Access violation address why is 0xC0000005?
sum(int a[ ], unsigned/*int*/ len)
{
int i,sum = 0;
for (i = 0; i <= len–1; i++)
sum += a[i];
return sum;
}
#include<stdio.h>
int sums(int a[],unsigned len)
{
int i,sum=0;
for(i=0;i<=len-1;i++)
{
sum+=a[i];
}
return sum;
}
int main()
{
int a[2]={0,1};
printf("%d\n",sums(a,0));
return 0;
}
- High-level languages rules of operation
- The meaning and implementation of machine instructions
- Arithmetic circuits inside a computer
- Abnormality detection and processing
- Virtual address space
???
- ** If x and y are int type, the time when x = 65535, y = x * x; y is how much?
y = -131071. Why?
The real world, x2≥0, but in the computer world is not necessarily true.
For any type int variables x and y, (x> y) == (-x <-y) total established it?
When x = -2147483648, y is not satisfied arbitrary (except outside -2147483648) **
- Machine-level representation of data
- Execution of machine instructions
- Arithmetic circuits inside a computer
- ** If x and y are int type, the time when x = 65535, y = x * x; y is how much?
y = -131071. Why?
The real world, x2≥0, but in the computer world is not necessarily true.
For any type int variables x and y, (x> y) == (-x <-y) total established it?
When x = -2147483648, y is not satisfied arbitrary (except outside -2147483648) **
- Machine-level representation of data
- Variable storage space allocation
- The large end of the small end data storage
- Symbol parsing rules connector
first handout