如何在不填充屏幕的情况下清空屏幕
是否存在中断服务例程来帮助我清除终端屏幕?它可以在 Windows 上运行吗?
Does an interrupt service routine exist to help me clear the screen of the terminal? Will it work on windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通过 BIOS 设置图形模式(int 10h,AH=0)将清除屏幕。
通过 BIOS 向上或向下滚动屏幕(int 10h,AH=6 或 7)也可以清除屏幕。
这只适用于您可以调用 BIOS 服务功能的情况。
MSDOS 是永远可以使用的地方。
在 Windows 中,这仅适用于 DOS 应用程序,并且 Windows 确实可以运行它们。 64 位版本的 Windows 根本不支持 DOS 应用程序,从 Windows Vista 开始,即使在 32 位版本的 Windows 中,许多 DOS 应用程序也无法完全运行。
还要记住,如果 DOS 应用程序在 Windows 的窗口中运行,则只有该窗口会被清除,而不是整个屏幕。
Setting a graphics mode through BIOS (int 10h with AH=0) will clear the screen.
Scrolling the screen up or down through BIOS (int 10h with AH=6 or 7) can clear the screen as well.
This will only work where you can invoke BIOS service functions.
MSDOS is where this will always work.
In Windows this will work only in DOS applications and if Windows can actually run them. 64-bit editions of Windows don't support DOS applications at all and starting with Windows Vista even in 32-bit editions of Windows many DOS apps don't work fully.
Remember also that if a DOS application runs in a window in Windows, only that window will get cleared, not the entire screen.
我让它工作(使用qemu,NASM)
(http://www.gabrielececchetti.it/Teaching/CalcolatoriElettronici/Docs/i8086_and_DOS_interrupts.pdf)
I got this to work (used qemu, NASM)
(http://www.gabrielececchetti.it/Teaching/CalcolatoriElettronici/Docs/i8086_and_DOS_interrupts.pdf)
在汇编中,试试这个:
不,你不能在 Windows 上执行此操作。此代码只能用于引导加载程序和汇编内核(仅限 16 位,警告:请勿尝试 32 位!!!)
如果您想在 Windows(控制台应用程序)中执行此操作,请尝试以下操作:
C++
VB。 NET
C#
注意:我认为我们无法使用 C# 或 VB 制作控制台应用程序。当然,我从来没有尝试过。只是说。但这些代码只适用于Windows。
In assembly, try this:
And no, you cannot do this on windows. This code can only be used for bootloaders, and assembly kernels (16 bit only, WARNING: DO NOT TRY ON 32 BIT!!!)
If you'd like to do in Windows (Console Applications), then try this:
C++
VB.NET
C#
NOTE: I don't think we can make Console apps using C# or VB. Of course, i never tried. Just saying. But these codes only work for windows.
对于 Windows 控制台应用程序,采用纯 C 语言:
其中
hConsoleOutput
是控制台屏幕缓冲区的句柄(通过GetStdHandle(STD_OUTPUT_HANDLE)
或CreateConsoleScreenBuffer( ...)
,或其他方式。该函数的作用是,首先检索当前控制台屏幕缓冲区信息(包含其当前大小),然后使用默认文本属性和空格填充整个屏幕缓冲区,最后将光标置于 (0, 0)。
For Windows console applications, in plain C:
where the
hConsoleOutput
is a HANDLE to a console screen-buffer (obtained either viaGetStdHandle(STD_OUTPUT_HANDLE)
, orCreateConsoleScreenBuffer(...)
, or other means.What this function does is to, first, retrieve the current console screen-buffer information (that contains its current size), then fill the complete screen-buffer with the default text attribute and with spaces, then finally place the cursor at (0,0).