• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Calculating delays for a microcontroller...

#21
The dollar sign ($) indicates the value of the active segment's location counter.
When you use the location counter symbol, keep in mind that its value changes with each instruction, but only after that instruction has been completely evaluated.
If you use $ in an operand to an instruction or a directive, it represents the code address of the first byte of that instruction.

In your case the code loops back to the first byte of the "djnz R2,$" instruction as long as R2 is not zero.
Clear ?

Edit: Please note that this is valid for the ASM51 assembler.
If you use another assembler, it could mean something else... ...
 
Last edited:
#23
Code:
D2:   mov R2,#29
     djnz R2,$
is equal to
Code:
D2:   mov R2,#29
D3:   djnz R2,D3
is not equal to
Code:
D2:   mov R2,#29
     djnz R2,$
If you use $ in an operand to an instruction or a directive, it represents the code address of the first byte of that instruction.
 

Latest threads

EE World Online Articles

Loading

 
Top