TASM闪烁的LED灯

时间:2019-12-11 22:09:51

标签: assembly dos tasm

我想知道我的代码中是否有错误?
许多人说应该是pop cx而不是pop ax,但是如果我在其中放cx,它总是会弹出一条错误消息,提示

  

NTVDM CPU遇到非法指令

但是,另一方面,如果我放置ax而不是cx,则完全没有错误发生,但是闪烁并不理想。

这是我的代码:

.model small
.stack
.code
org 100h
start:
    main proc
    mov cx,1; how many times to loop
    here:mov al,00000001b
    mov dx,378h
    out dx,al
    call delay
    mov al,00000010b
    mov dx,378h
    out dx,al
    call delay
    mov al,00000100b
    mov dx,378h
    out dx,al
    call delay
    mov al,00001000b
    mov dx,378h
    out dx,al
    call delay
    mov al,00010000b
    mov dx,378h
    out dx,al
    call delay
    mov al,00100000b
    mov dx,378h
    out dx,al
    call delay
    mov al,01000000b
    mov dx,378h
    out dx,al
     call delay
     mov al,10000000b
    mov dx,378h
    out dx,al
    call delay
    loop here
    int 20h
    main endp
    delay proc
        push cx
        mov cx,2050
        delay2:
        push cx
        mov cx,10000
        delay3:
        nop
        nop
        nop
        nop
        nop
        loop delay3
        pop cx
        loop delay2
        pop ax
        ret
    delay endp
end start

0 个答案:

没有答案