我寫了簡單的第一階段啓動加載程序,它使用中斷向BIOS顯示「Hello world」。現在作爲編寫第二階段的下一個顯而易見的步驟,但是代碼應該存在以及如何從第一階段加載它?如何從第一階段加載第二階段啓動加載器?
下面是第一階段的程序
[BITS 16] ;Tells the assembler that its a 16 bit code
[ORG 0x7C00] ;Origin, tell the assembler that where the code will
;be in memory after it is been loaded
MOV SI, HelloString ;Store string pointer to SI
CALL PrintString ;Call print string procedure
JMP $ ;Infinite loop, hang it here.
PrintCharacter: ;Procedure to print character on screen
;Assume that ASCII value is in register AL
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
RET ;Return to calling procedure
PrintString: ;Procedure to print string on screen
;Assume that string starting pointer is in register SI
next_character: ;Lable to fetch next character from string
MOV AL, [SI] ;Get a byte from string and store in AL register
INC SI ;Increment SI pointer
OR AL, AL ;Check if value in AL is zero (end of string)
JZ exit_function ;If end then return
CALL PrintCharacter ;Else print the character which is in AL register
JMP next_character ;Fetch next character from string
exit_function: ;End label
RET ;Return from procedure
;Data
HelloString db 'Hello World', 0 ;HelloWorld string ending with 0
TIMES 510 - ($ - $$) db 0 ;Fill the rest of sector with 0
DW 0xAA55 ;Add boot signature at the end of bootloader
你是用C語言?任何其他您可以分享的重要信息? – 2010-01-14 15:53:22
,我們一直使用第一架組件的x86指令,但我們r打算寫第二階段在更高層次語言如C ..我在哪裏存儲第二階段二進制以及如何從第一階段的引導加載程序加載[加載內核的 – Xinus 2010-01-14 16:15:23
可能的複製從組件(NASM)(http://stackoverflow.com/questions/1551240/loading-kernel-from-assembly-nasm) – 2015-10-28 18:14:36