LoopsConditionalStructuresARM

# LoopsConditionalStructuresARM - Else Code Endif Is this for...

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: ... @ Else Code Endif:
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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern