我对装配很新,但我正试图深入了解低级计算的世界.我正在尝试学习如何编写将作为引导加载程序代码运行的汇编代码; 所以独立于任何其他操作系统,如Linux或Windows.在阅读了本页和其他几个x86指令集列表之后,我想出了一些汇编代码,它应该在屏幕上打印10 A然后是1 B.
BITS 16
start:
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096
mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax
mov cl, 10 ; Use this register as our loop counter
mov ah, 0Eh ; This register holds our BIOS instruction
.repeat:
mov al, 41h ; Put …Run Code Online (Sandbox Code Playgroud) 我在程序集中编写了一个stage 1 bootloader,我试图将FAT12文件系统加载到内存中,以便我可以加载我的stage 2 bootloader.我已经设法将FAT加载到内存中,但是我很难将根目录加载到内存中.
我目前正在使用它作为参考,并产生了以下内容:
.load_root:
;es is 0x7c0
xor dx, dx ; blank dx for division
mov si, fat_loaded ; inform user that FAT is loaded
call print
mov al, [FATcount] ; calculate how many sectors into the disk must be loaded
mul word [SectorsPerFAT]
add al, [ReservedSectors]
div byte [SectorsPerTrack]
mov ch, ah ; Store quotient in ch for cylinder number
mov cl, al ; Store remainder in cl for sector number
xor dx, dx …Run Code Online (Sandbox Code Playgroud)