Double Conditions in ARM assembly

后端 未结 3 1292
予麋鹿
予麋鹿 2020-12-21 22:41

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

3条回答
  •  自闭症患者
    2020-12-21 23:29

    You can't do the comparison and branch together in one instruction like that. You need to use separate compare and branch instructions. (ARM does have a "compare and branch on zero," but that does not apply here.)

    You want something more like:

        CMP r2, #100
        BGT label_out
        CMP r2, #0
        BLT label_out  
    
    ... do stuff
    
    label_out:  ; the branches come here if R2 < 0 || R2 > 100
    

提交回复
热议问题