《Programming from the Ground Up》学习第3天,p49-p74总结,总计26页。
一、技术总结
1.function
(1)定义
p49, Functions are unit of code that do a defined piece of work on specified types of data。
函数是在指定类型的数据上完成所定义的某个工作的代码单元。
(2)parameter
p49, The data items a function is given to process are called it's parameters。
给予函数处理的数据项称为函数的参数。
(3)interface
p49, The parameter list and the processing expectations of a function(what it is expected to to with the parameters) are called the function's interface。
函数参数列表和预期处理结果称为函数的接口。
2.primitive functions/primitives
p50,However, ultimately there are things that you cannot write functions for which must be provided by the system. Those are called primiteive function(or just primiteives)-they are teh basics which everything else is built off of.
这些由系统提供的函数称为原函数(或原语)。
3.stack
(1)定义
p51,Each computer program that runs uses a region of memory called the stack to enable functions to work properly.
The computer's stack lives at the very top address of memory.
stack(栈)就是memory(内存)的一块区域,位于内存的最顶端。这是物理意义的上的。
4.power.s
书里使用的是32位的电脑,但我们现在的电脑大多是64位的,如果运行书中的代码就会提示:Error: invalid instruction suffix for `push',这里对代码做了修改,改为64位电脑里的寄存器。
二、英语总结
无。
三、其它
1.8、16、32、64位电脑里寄存器的名字
因为不同教材使用的寄存器名称不一样,容易对初学者造成困扰,这里把8位、16位、32位、64位电脑里的寄存器名称全部列出来,这样在看到这些名字的时候我们就知道作者使用的是多少位的电脑。同时我们尽量在对应位数的电脑里去运行这些代码。
r8 = AL AH BL BH CL CH DL DH
r16 = AX BX CX DX BP SP SI DI
r32 = EAX EBX ECX EDX EBP ESP ESI EDI
r64 = RAX RBX RCX RDX RBP RSP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15
2.32和64位电脑里寄存器调用区别
(1)x86 Assembly pushl/popl don't work with "Error: suffix or operands invalid"
(2)What are the calling conventions for UNIX & Linux system calls (and user-space functions) on i386 and x86-64
四、参考资料
1. 编程
(1)Jonathan Bartlett,《Programming From The Ground Up》: https://book.douban.com/subject/1787855/
2. 英语
(1)Etymology Dictionary: https://www.etymonline.com
(2) Cambridge Dictionary: https://dictionary.cambridge.org
欢迎搜索及关注:编程人(a_codists)