【发布时间】:2021-03-31 13:00:51
【问题描述】:
我正在尝试在 NASM 中制作一个 DOS 程序,该程序使用中断 10h 在左上角的 16 种可用颜色中显示一个像素循环。我还使用中断 21h 使程序每 1/100 秒 (100 fps) 运行一次。
segment .data
pixelcolor: db 0
pixelx: dw 100
pixely: dw 100
timeaux: db 0 ; used later on to force the program to run at 100fps
segment .text
global _start
_start:
mov ah,00h
mov al,0dh
int 10h
mov ah,0bh
mov bh,00h
mov bl,00h
int 10h
.infinite:
mov ah,2ch
int 21h ; get system time
cmp dl,timeaux ; if 1/100 seconds haven't passed yet...
je .infinite ; ...skip current frame
; else, continue normally
mov byte[timeaux],dl
mov ah,00h
mov al,0dh
int 10h
mov ah,0bh
mov bh,00h
mov bl,00h
int 10h
mov ah,0ch
mov al,pixelcolor
mov cx,pixelx
mov dx,pixely
int 10h
inc byte[pixelcolor]
jmp .infinite
但是,当我在 DOSBox 中实际运行程序时,像素只是保持红色。有谁知道为什么我的无限循环不起作用? (注意:我对 NASM 很陌生,所以老实说,我什至不惊讶我的程序只有 15% 的时间工作。)
【问题讨论】:
-
您将需要设置一个开发环境,让您可以调试代码,使用调试器单步执行它以查看发生了什么,如果您的代码正在循环或崩溃。不过,我不知道在 DOS 下运行的过时 16 位 DOS 代码有什么好处。
标签: graphics nasm dos x86-16 bios