lur*_*ker 2 assembly operating-system bios
I write some code to make my own operating system and study x86 assembly language, too. While studying x86 assembly language, I start wondering about interrupt. Look at below assembly code:
mov ah, 2
mov dl, 'A'
int 0x21
Run Code Online (Sandbox Code Playgroud)
This code prints 'A' to the screen. it is for MS-DOS.
mov eax, 1
mov ebx, 0
int 0x80
Run Code Online (Sandbox Code Playgroud)
This code makes program to exit. it is for Linux. The last one:
mov ah, 2
mov al, 1
mov ch, 0
mov cl, 2
mov dh, 0
mov dl, 0
int 0x13
Run Code Online (Sandbox Code Playgroud)
I wrote this code to copy kernel code from disk. This code is included in MBR sector. so there is no operating system when this code is executed. I have one question on here.
Let's assume that someone executes 'int' instruction to invoke interrupt and if that 'int' instruction is executed on MBR sector, it invokes BIOS routine. But I wonder if that 'int' instruction is executed on Linux or Windows, what happens ? does it refer to Linux/Windows interrupt vector or BIOS routine same like the situation on MBR sector ?
坦率地说,我测试了尝试在 Linux 上执行第一个代码的方法,但没有成功。我认为“int”指令的结果取决于操作系统。如果这不是事实,有人可以告诉我真相或任何想法吗?
该int指令引发软件中断。这会导致 CPU从中断描述表(IDT)执行中断处理程序。在启动时,BIOS 设置一个 IDT,其中包含许多执行一些基本服务的中断处理程序。DOS 将其自己的中断处理程序添加到该表中以提供 DOS 特定的功能。
现代操作系统以保护模式运行。在这种模式下,BIOS 服务不会运行,因为它们被写入要在实模式下执行。现代操作系统通常用自定义表替换标准中断描述表。因此,DOS 和 BIOS 服务都不可用。