CSAPP学习笔记
深入理解计算机系统(C语言、数据结构、微嵌、编译原理、数电、模电) 第一章:计算机系统漫游 编译系统 hello.c->hello.i gcc -E hello.c -o hello.i hello.i->hello.s gcc -S hello.i -o hello.s hello.s->hello.o gcc -c hello.s -o hello.o hello.o->hello gcc hello.o -o hello 第二章:信息的表示和处理 //数据在不同架构处理器下的表示 #include <stdio.h> typedef unsigned char * byte_pointer; void show_bytes(byte_pointer start, size_t led) { size_t i; for (i = 0 ;i < led; i++) { printf("%.2x",start[i]); } printf("\n"); } void show_int(int x) { show_bytes((byte_pointer)&x,sizeof(int)); } void show_float(float x) { show_bytes((byte_pointer)&x,sizeof(float)); } void show_pointer(void *x) { show_bytes((byte_pointer)&x,sizeof(void *)); } int main() { int i =12345; show_int(i); return 0; } 整数、浮点数在计算机内部的表示与运算 第三章:程序的机器级表示 while、do-while、for性能分析 三种都是通过条件测试和跳转指令实现的。 switch、if-else性能分析 switch通过一个跳转表实现,所以只需要执行一次跳转,而if-else需要多次跳转指令,代码效率相对低。 ...