Unknown Label - DELAY occurring in edsim51,8051 microprocessor

117 views Asked by At

i can't figure out the problem. it shows "Unknown Label - DELAY" in edsim51

Org 00h

Main:
    Mov A, #0FEh
    Mov P1, A
    Acall Delay
    
    Mov A, #0FFh
    Mov P1, A
    Acall Delay

    Djnz R1, Main  ; Repeat the code until R1 becomes zero

End

i can't figure out the problem

2

There are 2 answers

0
the busybee On

You do not provide the subroutine Delay, and so the assembler/linker cannot resolve the label to an address.

The solution is to provide the subroutine, as a separate source code module, or in the same source.

0
Mohamed Ahmed Mokhtar On

The Delay subroutine is missing from your code.

Org 00h

Main:
    Mov A, #0FEh
    Mov P1, A
    Acall Delay
    
    Mov A, #0FFh
    Mov P1, A
    Acall Delay

    ;you forgot to give the R1 an initial value
    Djnz R1, Main  ; Repeat the code until R1 becomes zero

    ;If R1 equals zero halt the system
    JMP HALT
;For example this is a delay for 1 Microsecond while using FREQUENCY 11.0592MHZ
Delay:
    MOV R6,#2D  ;10uS delay
    DJNZ R6, $  ;'$' mean to jump on the same line
    RET

HALT:
    JMP $
End

Also don't forget to give an initial value for R1 that you are using in 'Djnz R1, Main'