PDA

View Full Version : Assembly code help



06-21-2005, 01:26 PM
Hi;
I want help with this 8051 code.


mov R2,#29
djnz R2,$

what does this dollar symbol mean

nchinoy
06-22-2005, 01:05 PM
let me see if i can get this right ...

<the code simply loads Register R2 with 29 and decrements R2 , as long as R2 is not zero the code has to jump to $>

I think the 2 line code is taken from some compiled file. What i mean is that the original code is in C/ or some high level language... Then after compilation this is the code you have ended up with...

The thing is that the file is compiled but not LINKED.. So if in the high level language the REFERNCE FUNCTION to which the code wants to jump to as long as R2 is not zero has been placed in some other file or is yet to be processed by the linker then you will end up with a $. This $ will be then filled in with the appropriate address to jump to......

Hope that helps ...

Cheers ;-)

06-23-2005, 07:17 PM
Thanks a lot man.I was wondering how that line worked.I generate delays using delay generator 8051 delay generator.I always get this $ for the delay.When I use it in my code it works fine.


When I run code(simulate) the code jumps to the same R2 itself util it is zero
But the delays are exact so I thought this dollar symbol had to indicate that the program has to remain in the same line till it becomes zero.

here is delay code for 1 sec for 12Mhz crystal

; Delay Routine
Delay:
mov R0,#46 ; 1
D1:
mov R1,#44 ; 1

D2:
mov R2,#245 ; 1
djnz R2,$ ; 2
nop ; 1
djnz R1,D2 ; 2
djnz R0,D1 ; 2
nop ; 1
ret ; 2
;
; call into routine ; 2
;
; initial mov ; 1
;
; End of Delay - total cycles 1000000