CDA3101-L08-procs-numbreps

CDA3101-L08-procs-numbreps - CDA 3101 Fall 2011...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CDA 3101 Fall 2011 Introduction to Computer Organization Procedure Support 31 August 2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Review 3 formats of MIPS instructions in binary: Op field determines format Operands Registers: $0 to $31 mapped onto: $zero, $at, $v_, $a_, $s_, $t_, $gp, $sp, $fp, $ra Memory : Mem[0] , Mem[4] , , Mem[4294967292] Index is the “address” (Array index => Memory index) Stored program concept (instructions are numbers!) op immediate rs rt op funct rs rt shamt rd op destination address 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits R I J
Background image of page 2
Overview Memory layout C functions MIPS support (instructions) for procedures The stack Procedure Conventions Manual Compilation Conclusion
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Memory Layout Stack segment Data segment Text segment Dynamic data Static data 0xFFFFFFFF 0x7FFFFFFF 0x10000000 0x00400000 0x00000000 (2GB) (4MB) $gp (0x10008000) 0x10010000
Background image of page 4
Data Segment lw $v0, 0x0020($gp) 0xFFFFFFFF 0x10000000 $gp (0x10008000) 0x10010000 2 instructions (lui and lw) are needed to access this memory (64KB) lui $s0, 0x1001 # s0 = 0x10010000 lw $v0, 0x8020($s0) # 0x8020 = (-7fe0) 16 0x10008020
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C Functions / Procedures main() { int i, j, k; i = mult(j,k); } int fact (int mcand, int mlier) { int product; product = 0; while (mlier > 0) { product = product + mcand; mlier = mlier -1; } return product; } What information must compiler keep track of?
Background image of page 6
Procedure Call Bookkeeping Problems Procedure address Return address Arguments Return value Local variables Register conventions Labels $ra $a0, $a1, $a2, $a3 $v0, $v1 $s0, $s1, …, $s7 Dynamic nature of procedures Procedure call frames Arguments, save registers, local variables
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Procedure Call Convention Software rules for using registers Name Register Number Usage Preserved on call $zero 0 the constant value 0 n.a. $at 1 reserved for the assembler n.a. $v0-$v1 2-3 expr. evaluation and function result no $a0-$a3 4-7 arguments (procedures/functions) yes $t0-$t7 8-15 temporaries no $s0-$s7 16-23 saved yes $t8-$t9 24-25 more temporaries no $k0-$k1 26-27 reserved for the operating system n.a. $gp 28 global pointer yes $sp 29 stack pointer yes $fp 30 frame pointer yes $ra 31 return address yes
Background image of page 8
ProcedureOne The Stack 0xFFFFFFFF 0x7FFFFFFF main ProcedureTwo Stack Frames
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ProcedureOne’s (callee) frame Main’s (caller) frame Stack Frames argument 5 argument 6 local variables saved registers $fp, $ra, S $fp $sp Saved VAT registers $a0 $a3 $a2 $a1 $v0 $v1
Background image of page 10
Caller / Callee Conventions Immediately before the caller invokes the callee Pass arguments ($a0 - $a3). Extra args: push on the stack Save caller-saved registers ($a0 - $a3; $t0 - $t9) Execute jal (jumps to callee; saves return address)
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 32

CDA3101-L08-procs-numbreps - CDA 3101 Fall 2011...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online