未知标签 - edsim51,8051 微处理器中发生延迟

问题描述 投票:0回答:2

我无法找出问题所在。它在 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

我无法找出问题所在

assembly microprocessors 8051 edsim51
2个回答
1
投票

您没有提供子例程

Delay
,因此汇编器/链接器无法将标签解析为地址。

解决方案是提供子例程,作为单独的源代码模块,或在同一源代码中。


0
投票

您的代码中缺少 Delay 子例程。

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

另外,不要忘记为您在“Djnz R1,Main”中使用的 R1 提供初始值

© www.soinside.com 2019 - 2024. All rights reserved.