【发布时间】:2013-10-26 18:08:12
【问题描述】:
我不确定我是否做错了什么。我正在使用英特尔芯片的 linux 机器上学习 AT&T 语法中的汇编语言。我了解到 INT 10H 用于为各种视频目的调用 BIOS 子例程。
我写了这个简单的汇编代码来清屏。
.section .data
data_items:
.section .text
.global _start
_start:
mov $6, %ah # to select the scroll function
mov $0, %al # the entire page
mov $7, %bh # for normal attribute
mov $0, %ch # row value of the start point
mov $0, %cl # column value of the starting point
mov $24, %dh # row value of ending point
mov $79, %dl # column value of the ending point
int $0x10 # invoke the BIOS INT 10H interrupt
movl $1, %eax # exiting the program
int $0x80
我在 gnome 终端中组装了它(使用英特尔芯片上的 fedora 19)。组装和链接没有问题。但它无法运行并出现分段错误。为什么会失败以及如何更正代码?
【问题讨论】:
-
考虑到这对我来说甚至没有链接 xD(这是 GAS 对吗?)我不确定我能帮忙。
-
你用的是什么汇编程序?
-
来自 gnu 的气体。我得到了答案。 int 10 根本不打算在 linux 中使用。它是 DOS/windows 的东西。