出于教育目的,我已经从mikeos.berlios.de/write-your-own-os.html改编了这个引导加载程序,将其重写为专门加载地址0x7c00.
最终的代码是这样的:
[BITS 16] ; Tells nasm to build 16 bits code
[ORG 0x7C00] ; The address the code will start
start:
mov ax, 0 ; Reserves 4Kbytes after the bootloader
add ax, 288 ; (4096 + 512)/ 16 bytes per paragraph
mov ss, ax
mov sp, 4096
mov ax, 0 ; Sets the data segment
mov ds, ax
mov si, texto ; Sets the text position
call imprime ; Calls the printing routine
jmp $ ; Infinite …Run Code Online (Sandbox Code Playgroud)