TST, CMP, BNE, beq directives

Source: Internet
Author: User
Tags processing instruction

1, TST: Logic processing instructions, for the contents of one register and the contents of another register or the immediate number of bitwise AND operation, and according to the results of the operation update CPSR the value of the condition flag bit. The current operation result is 1, then z=0; The current operation result is 0, then z=1
CMP: Arithmetic processing instruction for subtracting the contents of one register from the contents or immediate number of another register, changing the flag bit without storing the result
BNE: Data jump instruction, flag register in the z flag bit is not equal to zero, jump to bne after the label
BEQ: Data jump instruction, flag register in the z flag bit equals zero, jump to beq after the label
2. Example
TST R0, #0x2         // to perform an and operation, if Bit_2 is 1,zero==0, if Bit_2 is 0, then zero==1, that is, the directive tests whether Bit_2 is 0BNE LED _blink         // non-zero jump, if zero==1, jump to Led_blink place, if zero==0, continue to execute the next instruction

3. Example

Sub R1, R1, #1    //r1=r1-1cmp R1, #0          //R1 equals 0, and change flag bit     bne led_blink       //zero==1 jumps to Led_blink, Zero==0 continues execution 

TST, CMP, BNE, beq directives

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.