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