hi
i want to use IF statement in assembly, like this
if (p3.0 true) { } else { }
or like this
BEGIN: IF R0 = #45 { } ELSE { } ENDIF jmp begin
so how can i use it, for one byte or compare two bits
help me plz
You have to choose:
Either write in a High-Level Languge (HLL) such as 'C' - which gives you "structured" facilities like if-then-else;
Or write in a Low-Level Languge (LLL) such as Assembly - which doesn't!
Your call!
i want to use IF statement in assembly ... so how can i use it
This is accomplished with 'conditional branch' instructions. Google is your friend. And the MCU manual too.
An if-then-else construct is likely to require both a conditional and an unconditional branch...
waiting for someone to show up, I decided to list the "assembly IFs"
JC rel Jump if carry is set 2 24 JNC rel Jump if carry not set 2 24 JB rel Jump if direct bit is set 3 24 JNB rel Jump if direct bit is not set 3 24 JBC bit,rel Jump if direct bit is set and clear bit 3 24 JZ rel Jump if Accumulator is zero 2 24 JNZ rel Jump if Accumulator is not zero 2 24 CJNE A,direct,rel Compare direct byte to ACC and jump if not equal 3 24 CJNE A,#data,rel Compare immediate to ACC and jump if not equal 3 24 CJNE RN,#data,rel Compare immediate to register and jump if not equal 3 24 CJNE @Ri,#data,rel Compare immediate to indirect and jump if not equal 3 24 DJNZ Rn,rel Decrement register and jump if not zero 2 24 DJNZ direct,rel Decrement direct byte and jump if not zero 3 24
Erik
It is left as an exercise for the student to look-up the non-conditional (unconditional) jump instructions...