15-213 Recitation 3 - PowerPoint PPT Presentation

About This Presentation
Title:

15-213 Recitation 3

Description:

ebp Base (Stack Frame) Pointer %esp Stack Pointer. Assembly Programming: Structure ... Save any registers that could be clobbered. Where? Function Body ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 9
Provided by: shaheen8
Learn more at: http://www.cs.cmu.edu
Category:

less

Transcript and Presenter's Notes

Title: 15-213 Recitation 3


1
15-213 Recitation 3 2/5/01
  • Outline
  • Code to Executables
  • Machine Model
  • Assembly Programming
  • Structure
  • Addressing Modes
  • Miscellaneous Stuff
  • H1a / L3 Practice

Shaheen Gandhi e-mail sgandhi_at_andrew.cmu.edu Of
fice Hours Wednesday 130 230 Wean 3108
2
Code to Executables
C/C Code (text)
start
  • Preprocessor (text)
  • Compiler (text)
  • Assembler (binary)
  • Linker (binary)

Binary Executable (binary)
finish
3
Machine Model
CPU
Memory
Addresses
Registers
E I P
Object Code Program Data
Data
Condition Codes
Instructions
Stack
4
Special Registers
  • eax Return Value
  • eip Instruction Pointer
  • ebp Base (Stack Frame) Pointer
  • esp Stack Pointer

5
Assembly Programming Structure
  • Function Setup
  • Save Old Base Pointer (pushl ebp)
  • Set up own base pointer (movl esp, ebp)
  • Note that this saves the old stack pointer
  • Save any registers that could be clobbered
  • Where?
  • Function Body
  • Operations on data, loops, function calls

6
Assembly Programming Structure
  • Function Cleanup
  • Return value placed in eax
  • What about returning larger values? (structs,
    doubles, etc.)
  • Restore Callers Stack Pointer (movl ebp, esp)
  • Restore Old Base Pointer (popl ebp)
  • Return
  • Where does it return to?

7
Assembly ProgrammingSimple Addressing Modes
  • Examples
  • (R) MemR
  • 10(R) MemR 10
  • 0x10(R) MemR 16

8
Assembly ProgrammingIndexed Addressing Modes
  • Generic Form
  • D(Rb, Ri, S) MemRegRbSRegRi D
  • Examples
  • (Rb,Ri) MemRegRbRegRi
  • D(Rb,Ri) MemRegRbRegRiD
  • (Rb,Ri,S) MemRegRbSRegRi
Write a Comment
User Comments (0)
About PowerShow.com