Computer System Basis

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

  1. How to deal with compiler literal
  2. High-level language operation rules
  3. Correspondence between high-level language instruction
  4. Execution of machine instructions
  5. 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;
}
  1. High-level languages ​​rules of operation
  2. The meaning and implementation of machine instructions
  3. Arithmetic circuits inside a computer
  4. Abnormality detection and processing
  5. 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) **
  1. Machine-level representation of data
  2. Execution of machine instructions
  3. 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) **

  1. Machine-level representation of data
  2. Variable storage space allocation
  3. The large end of the small end data storage
  4. Symbol parsing rules connector

    first handout

Guess you like

Origin www.cnblogs.com/congrifan/p/11299425.html