LoopsConditionalStructuresARM

# LoopsConditionalStructuresARM - .. @ Else Code Endif: Is...

This preview shows pages 1–3. Sign up to view the full content.

Loops and Conditional Structure Examples in ARM Assembly While While (x < 3) { /* While Code */ } LDR R1, = x LDR R2, [r1] While: CMP R2, #3 BGE Endwhile @ While Code (changes R2) B While Endwhile: . .. Is this for signed or unsigned variable x? What if the condition was ( x > -3)? For For (x=1; x < 10; x++) { /* For Code */ } Init: MOV R2,#1 For: CMP R2,#10 BGE Endfor @ For Code ADD R2,R2,#1 B For Endfor: Is this for signed or unsigned variable x? Does it make sense for x to be signed in this case?

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

View Full Document
if-then-else statement If (x > 5) then { . .. \* If Code *\ ...} Else { . .. \* Else Code *\ ...} LDR R1, = x LDR R2, [r1] CMP R2, #5 BLE Else If: @ If Code B Endif Else: .
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .. @ Else Code Endif: Is this for signed or unsigned variable x? What if the condition was ( x > -3)? Inequality Conditions Summarised ARM has the full set of signed and unsigned inequality conditions. They can be confusing. After a CMP x,y or SUBS z,x,y , if x,y are the two operands, the 8 possible inequalities are shown in the table below It is important to choose the correct condition if the test is to work for all inputs, even though for positive numbers signed and unsigned comparisons are identical. Test Signed Unsigned x > y GreaTer GT HIgher HI x y Greater or Equal GE Higher or Same HS (= CS ) x y Less or Equal LE Lower or Same LS x < y Less Than LT LOwer LO (= CC )...
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- Toronto.

### Page1 / 3

LoopsConditionalStructuresARM - .. @ Else Code Endif: Is...

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

View Full Document
Ask a homework question - tutors are online