如何在保护模式下清除屏幕

问题描述 投票:0回答:1

我正在使用NASM for Linux,我想知道如何在保护模式下清除屏幕。我找到了使用int10h的解决方案,但是在保护模式下,我只能使用int80h。提前致谢。

linux assembly screen nasm
1个回答
1
投票

您可以将\x1b[2J写入标准输出,以便清除端子并使用\x1b[H固定光标位置,例如在nasm中:

global  _start

section .data
  clr    db 0x1b, "[2J", 0x1b, "[H"
  clrlen equ $ - clr

section .text
_start:
  mov eax, 4
  mov ebx, 1
  mov ecx, clr
  mov edx, clrlen
  int 0x80

  mov eax, 1
  mov ebx, 0
  int 0x80

对于gnu汇编程序:

.globl _start

.data
  clr     : .ascii "\x1b[2J\x1b[H"
  clrlen  =  . - clr

.text
_start:
  movl $4, %eax
  movl $1, %ebx
  movl $clr, %ecx
  movl $clrlen, %edx
  int $0x80

  movl $1, %eax
  movl $0, %ebx
  int $0x80
© www.soinside.com 2019 - 2024. All rights reserved.