1. 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.
    Dismiss Notice

Calculating delays for a microcontroller...

Discussion in '8051/8951' started by AceOfHearts, Jul 12, 2007.

  1. mcs51mc

    mcs51mc New Member

    Joined:
    Feb 7, 2006
    Messages:
    343
    Likes:
    2
    Location:
    Belgium
    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: May 1, 2010
  2. keanhong2

    keanhong2 New Member

    Joined:
    Apr 10, 2010
    Messages:
    11
    Likes:
    0
    is that mean $ is from the label d2 , mean it replace this $ to become d2 ,Djnz r2,$ Subtract value r2 by one then loop back until not zero
     
  3. mcs51mc

    mcs51mc New Member

    Joined:
    Feb 7, 2006
    Messages:
    343
    Likes:
    2
    Location:
    Belgium
    Code (text):

    D2:   mov R2,#29
         djnz R2,$
    is equal to
    Code (text):

    D2:   mov R2,#29
    D3:   djnz R2,D3
    is not equal to
    Code (text):

    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.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. keanhong2

    keanhong2 New Member

    Joined:
    Apr 10, 2010
    Messages:
    11
    Likes:
    0

    understand Thanks :)
     
    Last edited: May 1, 2010
  6. subinalex

    subinalex New Member

    Joined:
    May 27, 2010
    Messages:
    15
    Likes:
    0
    Location:
    kerala
    thaankss

    dcwin gud s/w
     

Share This Page