Arm Assembly beq and BNE

Source: Internet
Author: User

Tst r0, #0x8
BNE suspendup; BNE commands are "not equal (or not 0) Jump commands ":

LDR R1, #0x00000000

Perform the and operation first. If the fourth digit of R0 is not 1 and the result is zero, set zero = 1 (continue the following LDR command );

Otherwise, zero = 0 (jump to suspendup for execution ).

Tst r0, #02

BNE sleep

LDR R1, #0

Explanation: bitwise comparison: Perform the and operation first. If the R0 2nd bit is not 1, the result is 0, set the flag zero = 1, and continue the following LDR command. Otherwise, zero = 0 will jump to sleep for execution.

BNE command: non-zero jump

Personal conclusion: TST and BNE are used together: first, TST is used for bitwise AND calculation, and then the result of bitwise AND is compared with 0. If it is not 0, then jump to the BNE followed mark (such as BNE sleep, then jump to sleep ).

TST and beq: first, TST is used for bitwise AND operation, and then the result of bitwise AND is compared with 0. If it is 0, it will jump to the beq followed tag (such as bne aaaa, to AAAA ).

2,

I was reading Arm Assembly yesterday. There is such a statement.

0         ldr    r3, [r0], #4         str    r3, [r1], #4         cmp r2, r0         bne %B0

BNE: transfer if not equal

But % B0, I searched it online, but it still failed. In the final assembly language, % B indicates to search for rows with lable 0. In other words, it indicates the address with lable 0 before this statement. The entire statement indicates that, if not equal, the row with lable 0 is redirected.

 

Similarly, with BNE % B0, there is BNE % F1, which is to search backward for rows with lable 1. Reference code:

; Check if ein0 button is pressed LDR r0, = gpfcon LDR R1, = 0x0 STR R1, [R0] LDR r0, = gpfup LDR R1, = 0xff STR R1, [R0] LDR R1, = gpfdat LDR r0, [R1] Bic r0, R0, # (0x1e <1); bit clear TST r0, #0x1 BNE % F1 (some statements are omitted); clear SDRAM end1; initialize stacks BL initstacks

% B, % F can be understood as follows: B Represents before, forward. F indicates after, backward

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.