LoopsConditionalStructuresARM

LoopsConditionalStructuresARM - Else Code Endif Is this for...

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

View Full Document Right Arrow Icon
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?
Image of page 1

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

View Full Document Right Arrow Icon
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:
Image of page 2
Image of page 3
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

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern