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

查看:76
本文介绍了无法在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天全站免登陆