如何在nasm屏幕上指定位置书写文本?

时间:2019-06-07 02:06:39

标签: assembly nasm x86-16 bootloader

所以我有一个显示文本的程序(“工作已完成” ),此后计数为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

1 个答案:

答案 0 :(得分:0)

对不起,忘记了答案,我找到了答案。这是我使用的代码,这要感谢 Peter Cordes ,当然,我在源代码中修改了dhdl,并从其中删除了10,13 msg2->

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