Society of Robots - Robot Forum
Software => Software => Topic started by: henry on August 06, 2007, 12:30:20 AM
-
guys..
I want to make logic operation in Uc....but I stuck..
this the algorithm..:
I have 2 register...R0 and R1....and then..I want to compare them...
if R0 is bigger than R1 then decrement R0
if R0 is lower than R1 then increase R0...
I want to write in assembly language...
this is my program:
MAIN:
MOV A, R0
CJNE A,R1,CHECK
MOV P0,0FFH
MOV P2,0FFH
CHECK:
...................
...................
In the label check..I don't know how we can find that R1 is bigger or lower than R0..
can somebody help...
thanks..
-
That'll depend on the MCU you are using. Not all assembly mnemonics are available in a specific MCU, some might rename the command you want.
If you're using an AVR try this site:
http://www.avr-asm-tutorial.net/avr_en/beginner/index.html (http://www.avr-asm-tutorial.net/avr_en/beginner/index.html)
-
why assembly and not C?
-
Hi,
I don't know how we can find that R1 is bigger or lower than R0..
Subtracting one from the other will yeild a positive or negative value (depending on ?C, might be reflected in a flag), if not zero of course.
In pseudo 'x86 code, it could be done something like this:
SUB R0, R1
JZ Do_Nothing
SUB R0, R1
JNAE Increase_R0
DEC R0
JMP DoNothing
Increase_R0:
INC R0
Do_Nothing:
RET ; or whatever