ARM Assembler - How do I use CMP, BLT and BGT?

前端 未结 3 617
北荒
北荒 2021-02-09 12:29

Quick question for you guys, in my loop I need to use CMP , BLT and BGT to compare some values. How would use said instructions in the following loop?

I\'m trying to use

3条回答
  •  耶瑟儿~
    2021-02-09 12:38

    If I wanted to use CMP to compare r6, with r4 and put the difference into r7, how would I do this?

    subs r7, r6, r4    /* r7 ← r6 - r4 */
    

    The same question if I wanted to use BLT if r7 is less than 0, how would I do this?

    bmi _exit          /* branch if r7 < 0 */
    

    BMI (minus/negative) When N is enabled (N is 1) where N is a flag that will be enabled if the result of the instruction yields a negative number. Disabled otherwise.

    Why subS instead of sub? Because S is an optional suffix that when is specified, the condition flags (like N) are updated on the result of the operation.

    Regards.

提交回复
热议问题