assembly - 如何在nasm屏幕上的指定位置写入文本?
问题描述
所以我有一个显示文本的程序(“Work was done to”),然后计数到 100% 并显示过程,但问题是我不想在显示新百分比之前总是打印文本。那么如何在屏幕上的指定位置插入文本以覆盖其他文本?
现在的样子
Work was done to 1%
2%
3%
...
我想成为怎样的人
工作完成到 1%(这个百分比只是用新的百分比覆盖)
cpu 386
bits 16
org 0h
start:
...
;=====================================================================================================================
mov ah, 0x07 ;function to call with interrupt
mov al, 0x00 ;scroll whole window
mov bh, 0x07 ;background color
mov cx, 0x0000 ;row 0,col 0
mov dx, 0x184f
int 0x10
mov si, msg1
call print_str
mov eax, [PERCENT]
next:
inc eax
mov di, strbuf ;ES:DI points to string buffer to store to
call uint32_to_str ;Convert 32-bit unsigned value in EAX to ASCII string
mov si, di ;DS:SI points to string buffer to print
call print_str
mov si, msg2
call print_str
cmp eax, 100 ;End loop at 100
jl next ;Continue until we reach limit
done:
hlt
jmp done
;=====================================================================================================================
print_str:
...
;=====================================================================================================================
uint32_to_str:
...
;=====================================================================================================================
MBR_Signature:
msg1 db 13,10,' Work was done to ',0
msg2 db '%',0
PERCENT dd 0
strbuf times 11 db 0
times 510-($-$$) db 0
db 55h,0aah
times 4096-($-$$) db 0
解决方案
对不起,忘记答案了,我找到了答案。这是我使用的代码,感谢Peter Cordes,当然,我在源代码中修改了dh
和,并从 msg2 中删除 ->dl
10,13
mov dh, 0 ;Cursor position line
mov dl, 0 ;Cursor position column
mov ah, 02h ;Set cursor position function
mov bh, 0 ;Page number
int 10h ;Interrupt call
推荐阅读
- python-3.x - 如何从 Flask 中的一个请求发送多个响应?
- python - 如何在不插入我需要的文件的情况下连接多个 excel csv 文件
- python - 如何在熊猫中计算逆cumsum
- html - 如何仅选择 div 的子 div(而不是“孙子” div 等)?
- android - 如何在 LinearLayout 中使用 Admob 广告?
- azure - Azure VM 软件安装 RDP
- python - 一键多值的dict
- java - For循环在Rock Paper Scissors Java程序中无法正常工作
- c - 如何将数据传递给 kthread_run
- php - 如何在外部 PHP 页面中安全地从 Nextcloud 继续会话