我正在为未来的测试应用程序(如 MEMTEST 等)构建一个简单的内核。
所以,我现在拥有的是引导加载程序。我需要做的是加载另一个我将编译的文件放在软盘的第二个扇区然后运行。
那么,我怎样才能将软盘的其余部分加载到 RAM 中然后运行呢?
你不需要 100% 准确,我只需要知道和学习必要的中断和“功能”来做我需要的 :)
只是为了分享引导加载程序:
[BITS 16] ;set 16bit mode
[ORG 0x7C00] ; address location where the program will run
jmp main ;start on main
main:
mov si,hstr ; put the pointer into si register
call printstr ;print hstr
;call load_kernel
;here we gonna load kernel into memory and then we will run it.
mov si,mstr ; put the pointer into si register
call printstr ;print mstr
jmp hold ;idle the CPU
hold:
hlt ;idle CPU
printstr:
;This will write in TTY char that will be loaded into al 8bit register.
lodsb ;load into al
cmp al,0 ; set flag if al is 0
jnz print ; if isnt equal to 0 then jump to print
ret ;else return to main
print: ;print the char
mov ah,0x0E ;set the ah before calling the video interrupt
int 10h ;here we go
jmp printstr ;jump back
;
hstr db "Loading ...",13,10,0 ;define the strings. 13 is ASCII, 10 for new line, 0 is the null terminator
mstr db "CPU is now idle!",13,10,0
times 510 - ($-$$) db 0 ;fill the rest of the sector(less 2 last bytes) with 0's. 510-(here-start)=free space with 0's
dw 0xAA55 ;the last 2 bytes of the sector with AA55 signature. means that is the bootloader.