I am very new to ARM and doing an assignment for a class. What I am confused about is a double condition like, if (x > 0 && x < 100) do something.
What I
What I am confused about is a double condition...
You can use a compiler with optimizations and a disassembler to see how it implements this. With the GNU tools, this is gcc and objdump -S.
if (x > 0 && x < 100)
You need assembler that checks both conditions and sets a flag. Say the value x is in r0.
sub r1, r0, #1 ; change zero test to minus.
cmp r1, #98 ; allow equal.
; condition 'ls' (lower and same) for true
movls r2, #42 ; set r2 to 42 if(x > 0 && x < 100)
; condition 'hi' (high unsigned) opposite flags
movhi r2, #24
This is typical of any CPU. The compiler translates the tests to something that maps better to the underlying instruction set. Your example tests have different operators.
It is easier to understand some code that needs less concepts,
if(x > 0 && y > 0)
This translates to something more straight forward in assembler,
cmp r0, #0
cmpgt r1,#0
movgt r0,#42 ; condition passed (here with signed conditions).
It is more straight forward if the tests are for the same conditions (usually the same 'C' operators) as the condition codes allow a conditional compare in these cases.