gpt4 book ai didi

assembly - x86 视频模式 清屏

转载 作者:行者123 更新时间:2023-12-02 20:04:16 25 4
gpt4 key购买 nike

您好,我正在尝试使用此代码在 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

;======================================================

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

最佳答案

您的代码存在一些问题。

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

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

所以应该是:

mov ax,0A000h
mov es,ax
xor di, di ; ES:0 is the start of the framebuffer

8 位的 320x200 消耗 320*200 = 64 000 字节的视频内存。所以cx的值是不正确的。应该是:

mov cx,32000d    ; you can write 320 * 200/2 in your source if you want
cld
xor ax,ax
rep stosw ; zero 2*CX bytes at ES:DI

关于assembly - x86 视频模式 清屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13979246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com