Chap8-decision-1 - Loops and Branches ° ARM assembly...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Loops and Branches ° ARM assembly language thus far: • Instructions: add,sub,mov, orr,and,bic, eor, mul, • ldr, str At most one assembly instruction per line • Comments start with; to end of line • Operands: registers r0 – r3 a1 – a4 (correspond to C functions arguments. Used for scratch pad too!) r4 – r10 v1 – v7 (correspond to function variables) • Operands: memory Memory[0], Memory[4], Memory[8], ,... , Memory[4294967292] Quiz ° What are the three different ways to obtain a data operand you have seen? ° Immediate- data is IN the instruction • add r1, r1, #24 ° Register Direct- data is IN a register • the register number is in the instruction • add r1, r1, r2 ° Base plus offset- data is IN memory • the register number is in the instruction • the base address is in the register • the offset is in the instruction/offset index register number in instruction • ldr r1, [ r2, #24 ] / ldr r1, [ r2,r3 ] • These are called Addressing Modes Overview ° C/Assembly if , goto , if-else ° C /Assembly Loops: goto , while ° Test for less Than, Greater Than, etc ° C/Assembly case/switch statement ° Conclusion C Decisions (Control Flow): if statements ° 2 kinds of if statements in C • if ( condition ) statement • if ( condition ) statement1 else statement2 ° Following code is same as 2nd if if ( condition ) goto L1; statement2; goto L2; L1: statement1; L2: • Not as elegant as if-else, but same meaning ARM decision instructions (control fow) (#1/2) ° Decision instruction in ARM: • cmp register1, register2 ;compare register1 with ; register2 • beq L1 ; branch to L1 if equal is “Branch iF (registers are) equal” Same meaning as C: • if (register1==register2) goto L1 ° Complementary ARM decision instruction • cmp register1, register2 • bne L1 • bne is “Branch iF (registers are) not equal” Same meaning as C: if (register1!=register2) goto L1 ° Called conditional branches ARM decision instructions (control fow) (#2/2) ° Decision instruction in ARM: • cmp register1, #immediate ;compare register1 with ; immediate number • beq L1 ; branch to L1 if equal • is “Branch iF (register and immediate are) equal” Same meaning as C: • if (register1==#immediate) goto L1 ° Complementary ARM decision instruction • cmp register1, #immediate • bne L1 • bne is “Branch iF (register and immediate are) not equal” Same meaning as C: if (register1!=#immediate) goto L1 ° Called conditional branches ARM decision instructions (control fow) (#1/2) ° Decision instruction in ARM: • cmp register1, register2 ;compare register1 with ; register2 • beq L1 ; branch to L1 if equal is “Branch iF (registers are) equal” Same meaning as C: • if (register1==register2) goto L1 ° Complementary ARM decision instruction • cmp register1, register2 • bne L1 • bne is “Branch iF (registers are) not equal” Same meaning as C: if (register1!=register2) goto L1 ° Called conditional branches ARM decision instructions (control fow) (#2/2)...
View Full 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.

Page1 / 18

Chap8-decision-1 - Loops and Branches ° ARM assembly...

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