15 213 Recitation 3 2 5 01 Outline Code to Executables Machine Model Assembly Programming Structure Addressing Modes Miscellaneous Stuf H1a L3 Practice Shaheen Gandhi e mail sgandhi andrew cmu edu Office Hours Wednesday 1 30 2 30 Wean 3108 Code to Executables start C C Code text Preprocessor text Compiler text Assembler binary Linker binary finish Binary Executable binary Machine Model CPU Memory Addresses E I P Registers Condition Codes Data Object Code Program Data Instructions Stack Special Registers eax eip ebp esp Return Value Instruction Pointer Base Stack Frame Pointer Stack Pointer Assembly Programming Structure Function Setup Save Old Base Pointer pushl ebp Set up own base pointer movl esp ebp Save any registers that could be clobbered Note that this saves the old stack pointer Where Function Body Operations on data loops function calls Assembly Programming Structure Function Cleanup Return value placed in eax What about returning larger values structs doubles etc Restore Caller s Stack Pointer movl ebp esp Restore Old Base Pointer popl ebp Return Where does it return to Assembly Programming Simple Addressing Modes R 10 R 0x10 R Examples Mem R Mem R 10 Mem R 16 Assembly Programming Indexed Addressing Modes Generic Form D Rb Ri S Mem Reg Rb S Reg Ri D Examples Rb Ri Mem Reg Rb Reg Ri D Rb Ri Mem Reg Rb Reg Ri D Rb Ri S Mem Reg Rb S Reg Ri
View Full Document