csapp notes 2.1

structure map

  • Computer representations use a limited number of bits to encode a number, and hence some operations can overflow when the results are too large to be rep- resented
  • Integer computer arithmetic satisfies many of the familiar properties of true integer arithmetic (associativity & commutativity). The computer might not generate the expected result, the result is consistent. Floating-point arithmetic is not associative, due to the finite precision of the representation. ((3.14+1e20)-1e20 -> 0.0 , 3.14+(1e20- 1e20) -> 3.14.)
  • Integer representations can encode a comparatively small range of values, but do so precisely, while floating-point representations can encode a wide range of values, but only approximately.
  • The value of a pointer in C—whether it points to an integer, a structure, or some other program object—is the virtual address of the first byte of some block of storage.
  • Although the C compiler maintains this type information, the actual machine-level program it generates has no information about data types. It simply treats each program object as a block of bytes, and the program itself as a sequence of bytes.
  • Just like a variable, a pointer has two aspects: its value and its type. The value indicates the location of some object, while its type indicates what kind of object (e.g., integer or floating-point number) is stored at that location.
  • Word size determines the maximum size of virtual address space. (0 - 2^w - 1)
  • A pointer (e.g., a variable declared as being of type “char *”) uses the full word size of the machine
  • One aspect of portability is to make the program insensitive to the exact sizes of the different data types.
  • A multi-byte object is stored as a contiguous sequence of bytes, with the address of the object given by the smallest address of the bytes used
  • little endian: the least significant byte comes first; big endian: the most significant byte comes first.
  • Byte ordering becomes visible when: 1. network communication, sending data from little endian machine to big endian machine); 2. inspecting machine-level byte sequences representing integer data; 3. usage of casting

As a Chinese trying to write in English I might must have made many grammatical mistakes. If you find one or two or many of those please please please leave a comment to help me improve. I can’t appreciate it more. After all, fixing bugs is what my life is all about.