问题
I am not sure if I am doing something drastically wrong. I am learning assembly language in AT&T syntax on a linux machine with intel chip. I learned that INT 10H is used to invoke BIOS subroutines for various video purposes.
I wrote this simple assembly code to clear the screen.
.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
I assembled it in a gnome terminal (using fedora 19 on intel chip). assembling and linking was no issue. but it failed to run and segmentation fault appears. Why it failed and how to correct the code?
回答1:
Ahaa, got the answer. I was totally doing it wrong. INT 10H is a DOS/windows thing, not LINUX at all.
http://docs.cs.up.ac.za/programming/asm/derick_tut/#maindiff
Introduction to Linux Assembly 4.1 Main Differences Between DOS and Linux Assembly
In DOS assembly, most things get done with the DOS services interrupt int 21h, and the BIOS service interrupts like int 10h and int 16h. In Linux, all these functions are handled by the kernel. Everything gets done with "kernel system calls", and you call the kernel with int 80h.
回答2:
Linux and all modern systems run in protected mode and BIOS interrupts can't be called when the system in this mode. You can use DOSBox to emulate DOS in Linux.
回答3:
In Linux Int 80h is used for calling the system functions. There is a great assembly oriented SDK that will help you starting with Linux assembly programming.
There are examples, include files and system functions help. This SDK is based on FASM, but it is even better, because of the much more readable syntax and great macro features.
来源:https://stackoverflow.com/questions/19440487/why-is-this-int-0x10-bios-int-not-working-on-linux