15513(2) Machine-Level Programming
In the second part, the course stepped into the machine level programming, that is assembly language. In this semester, the course switches from the y86 architecture to x86 one and so does the assembly language part. Here we goes! I’m writing this blog just when I go through all the slides for the first time.
General points
- RISC, CISC
- CPU (PC, Registers, Condition Codes) Memory(code, data, stack)
This is slightly different from the original ones.
Instructions
- movq Source. Dest
- leaq Src, Dst (Compute the value of address)
- salq <<
- sarq, shrq >>
- incq, decq, negq, notq
Procedure
Usage conventions
- %rax : return value/caller save
- %rdi,…, %r9 : arguments/caller save
- %r10, %r11 : caller save/can be modified by procedure
- %rbx, %r12, %r13, %r14 : callee-saved
- %rbp /frame pointer
- %rsp /Restore to original value upon exit
Data
Alignment for data struct
- primitive data type requires k bytes
- address must be multiple of k
- to make memory be accessed by chunks
- POssible to put large data types first to save space
floating points
we have xmm registers for floating points.
All xmm registers are caller-saved here. Return value should be stored in %xxm0. All the integers that refers the memory will still be passed in ordinary registers while only FP values are passed in XMM registers.
Almost forget about this part. Remeber refer to original text book. I’ll add the content the content once I have it .
Advanced topics
To be continued before next lab.