Mat*_*gan 5 assembly bios bootloader
以下站点"编写引导扇区代码"提供了一个代码示例,可在系统引导时将"A"打印到屏幕上.从我一直在阅读的不是你必须使用INT操作码让BIOS做某些事情?以下代码如何从上面引用的站点工作而不使用中断?代码的哪一部分实际告诉硬件将"A"打印到屏幕上?
有问题的代码:
.code16
.section .text
.globl _start
_start:
mov $0xb800, %ax
mov %ax, %ds
movb $'A', 0
movb $0x1e, 1
idle:
jmp idle
Run Code Online (Sandbox Code Playgroud)
附加原始问题
如果我使用以下代码,BIOS调用是否会为我写入文本缓冲区?缓冲区从地址0xb800开始?
# Author: Matthew Hoggan
# Date Created: Tuesday, Mar 6, 2012
.code16 # Tell assembler to work in 16 bit mode (directive)
.section .text
.globl _start # Help linker find start of program
_start:
movb $0x0e, %ah # Function to print a character to the screen
movb $0x00, %bh # Indicate the page number
movb $0x07, %bl # Text attribute
mov $'A', %al # Move data into low nibble
int $0x10 # Video Service Request to Bios
_hang:
jmp _hang
.end
Run Code Online (Sandbox Code Playgroud)
直接回答你的问题:行"movb $'A',0"有效地完成了对屏幕的打印(以下行,"movb $ 0x1e,1"指定它应该是什么颜色).
更长的答案:视频硬件根据内存的内容绘制屏幕.在文本模式下,视频硬件基于内存段0xB800开始绘制.无论字节0是什么,都定义了要在屏幕上的第一个文本单元格绘制的字符.下一个字节定义属性(前景色,背景色和闪烁状态).这种模式在整个屏幕上重复(char - attr - char - attr).
所以,从技术上讲,我的直接回答并非如此.2'movb'语句只是将字母"A"打印出来.在下次硬件根据内存刷新显示屏之前,不会打印"A".