x86视频模式清除屏幕

Bel*_*esy 2 x86 assembly dos bios nasm

您好我正在尝试使用此代码清除DOS视频模式下的屏幕.

但是当我运行它时,点仍然存在!

    org 100h

    mov     ah, 0       ; set display mode function.
    mov     al, 13h     ; mode 13h = 640x480 pixels, 256 colors.
    int     10h         ; set it!

    mov     cx, 10      ; column
    mov     dx, 10      ; row
    mov     al, 15      ; white
    mov     ah, 0ch     ; put pixel
    int     10h         ; draw pixel

    ; -------  clear the screen ----------     
    ; -------  doesn't work! dot is still there

    mov ax,0B800h
    mov es,ax
    xor di,di
    xor ax,ax
    mov cx,2000d
    cld
    rep stosw

    ; -------------------------------------

    ;wait for keypress
    mov ah,00
    int 16h

    mov ax, 4c00h ; exit to operating system.
    int 21h

    ;======================================================
Run Code Online (Sandbox Code Playgroud)

我尝试使用INT 10重置视频模式但是这让我在循环中不需要闪烁

nrz*_*nrz 7

您的代码存在一些问题.

首先,BIOS模式13h不是8位/像素的640x480,而是8位/像素的320x200.

B800h是BIOS文本模式的地址.BIOS图形模式使用A000h.

所以它应该是:

mov ax,0A000h
mov es,ax
Run Code Online (Sandbox Code Playgroud)

8位的320x200消耗320*200 = 64000字节的视频内存.所以价值cx是不正确的.它应该是:

mov cx,32000d
cld
rep stosw
Run Code Online (Sandbox Code Playgroud)