Chap10-func-1 - Overview C functions Bookkeeping for function call/return Instruction support for functions Nested function calls C memory

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

View Full Document Right Arrow Icon
Overview ° C functions ° Bookkeeping for function call/return ° Instruction support for functions ° Nested function calls ° C memory allocation: static, heap, stack ° Conclusion Review ° HLL decisions (if, case) and loops (while, for) use same assembly instructions Flag Setting Instructions: cmp, cmn, tst, teq in ARM Data Processing Instructions with Flag setting Feature: adds , subs, ands , in ARM Conditional branches: beq , bne, bgt, blt, etc in ARM Conditional Instructions: addeq, ldreq ,etc in ARM Unconditional branches: b, bal , and mv pc, Rn in ARM Switch/Case: chained if-else or jump table + ldr pc, [ ] ldr pc, [ ] is VERY POWERFUL!
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: Branches: PC-relative addressing ° Recall register r15 in the machine also called PC ; ° points to the currently executing instruction ° Most instruction add 4 to it. (pc increments by 4 after execution of most instructions) ° Branch changes it to a speciFc value ° Branch adds to it 24-bit signed value (contained in the instruction) Shifted left by 2 bits ° Labels => addresses memory 0: FFF. .. registers r14 r0 r15 = pc beq address b address –32MB +32MB 24 bits C functions main(void) { int i,j,k,m; i = mult (j,k); . .. ; m = mult (i,i); . .. } int mult (int mcand, int mlier) { int product = 0; while (mlier > 0) { product = product + mcand; mlier = mlier -1; } return product; } What information must compiler/program keep track of?
Background image of page 2
Basics of Function Call ...(use regs) set up args jump to function access args ... compute result . .. ...(use regs)
Background image of page 3

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

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

This note was uploaded on 12/20/2010 for the course CSC CSCC85 taught by Professor Lorincz during the Spring '10 term at University of Toronto- Toronto.

Page1 / 10

Chap10-func-1 - Overview C functions Bookkeeping for function call/return Instruction support for functions Nested function calls C memory

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

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