0
if (R1 > R2 || R3 > R4)
    R1 = R1 + 1

I'm having trouble figuring out what to do with multiple conditions. Would the instructions look something like this?

CMP     R1, R2
CMPNE   R3, R4
ADDEQ   R1, R1, #1
Vesque
  • 99
  • 2
  • 6

1 Answers1

1
if (R1 > R2 || R3 > R4)
    R1 = R1 + 1

The OR condition makes this tricky since it requires a short-circuit evaluation. What you can do is make a fall through comparison that gets evaluated only if r1 is NOT greater than r2, and then have the add instruction look at the results of the flag from the last comparison done.

cmp   r1, r2     ; compare r1 and r2
cmpls r3, r4     ; if lower or same, compare r3 and r4
addhi r1, r1, #1 ; if higher, add 1
Variable Length Coder
  • 7,958
  • 2
  • 25
  • 29