前言
现在我们来阅读邓志老师的《x86/x64体系探索及编程》,边阅读边将其代码放到bochs中运行,然后观察bochs的CPU是如何来模拟的。现在我们来详细分析ex3-2目录里面的内容。
boot.asm 代码解读
自己在工作中经常看汇编代码,但是写汇编代码真的很少写过,我们现在一边分析着这段boot汇编代码一边回顾其如何编写。
; Int 19h 加载 sector 0 (MBR) 进入 BOOT_SEG 段, BOOT_SEG 定义为 0x7c00
org BOOT_SEG
start:
cli
; enable a20 line
FAST_A20_ENABLE
sti
; set BOOT_SEG environment
mov ax, cs
mov ds, ax
mov ss, ax
mov es, ax
mov sp, BOOT_SEG ; 设 stack 底为 BOOT_SEG
call clear_screen
mov si, hello
call print_message
mov si, 20 ; setup 模块在第20号扇区里
mov di, SETUP_SEG - 2
call load_module ; 使用 load_module() 读多个扇区
mov si, SETUP_SEG
call print_message
mov si, word [load_message_table + eax * 2]
call print_message
next:
jmp $
org 解读
The
binformat provides an additional directive to the list given in chapter 7:ORG. The function of theORGdirective is to specify the origin address which NASM will assume the program begins at when it is loaded into memory.For example, the following

本文详细分析了《X86探索及编程》中的boot.asm源码,包括org指令、clear_screen函数、字符串与数组的定义、print_message函数和load_module代码。通过解析汇编代码,了解如何在Bochs中模拟执行,并探讨了int 0x10中断、LBA与CHS模式转换以及配置文件的细节。
最低0.47元/天 解锁文章
934

被折叠的 条评论
为什么被折叠?



