在 16 位实模式汇编中无法清除整个屏幕 [英] Can't clear entire screen in 16-bit real mode Assembly

查看:22
本文介绍了在 16 位实模式汇编中无法清除整个屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在简单的 16 位实模式操作系统中清除屏幕.下面是代码:

I'm trying to clear the screen in my simple 16-bit real mode operating system. Below is the code:

clearScreen:
    pusha

    mov ah, 0x7
    mov al, 0
    int 0x10

    popa
    ret

我读到将 al 设置为 0 并调用滚动屏幕中断会清理屏幕,但它似乎只是将第一行的颜色更改为灰色.

I read that setting al to 0 and calling the scroll screen interrupt would clean the screen but it only seems to change the colour of the first line to grey.

感谢任何能解释为什么这不起作用的人.

Thanks to anyone who can explain why this is not working.

推荐答案

问题是 int 0x10 函数 0x07 接受的参数比你给的多.具体来说,

The problem is that int 0x10 function 0x07 takes more parameters than you've given. Specifically,

  • AH = 07 = 向下滚动窗口
  • AL = 要滚动的行数(或全部为 0)
  • BH = 写入空行的属性
  • CH, CL = 窗口左上角的行、列
  • DH,DL = 窗口右下角的行、列

除非您设置它们,否则它们只会包含之前说明中发生的任何内容,这不太可能是您想要的!

Unless you set them, they'll just contain whatever happens to be there from previous instructions, which is very unlikely to be what you want!

所以假设您使用的是标准的 80x25 字符屏幕,您的代码应该改为这样编写:

So assuming that you're using the standard 80x25 character screen, your code should instead be written like this:

clearScreen:
    pusha

    mov ax, 0x0700  ; function 07, AL=0 means scroll whole window
    mov bh, 0x07    ; character attribute = white on black
    mov cx, 0x0000  ; row = 0, col = 0
    mov dx, 0x184f  ; row = 24 (0x18), col = 79 (0x4f)
    int 0x10        ; call BIOS video interrupt

    popa
    ret

有关详细信息,请参阅此版本的著名 Ralf Brown 中断列表.

See this version of the famous Ralf Brown interrupt list for more details.

这篇关于在 16 位实模式汇编中无法清除整个屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆