我試圖做一個引導程序爲我自己的操作系統。我試圖把它與imageusb程序寫入到一個USB記憶棒(從格式:IMG,ISO和垃圾桶,沒有什麼作品)。然後我嘗試啓動它,但是我沒有在BIOS啓動菜單中找到它。我用程序集編碼它。我怎樣才能使用自己的bootloader啓動操作系統?如何將我的操作系統的引導程序寫入USB棒?
這裏是我的代碼部分:
[BITS 16]
[ORG 0x7C00]
JMP Main
Main:
MOV SI, Text
CALL PrintString
CALL NextLine
MOV SI, PressKeyForBoot
CALL PrintString
CALL Boot
JMP $
PrintCharacter:
MOV AH, 0x0E
MOV BH, 0x00
MOV BL, 0x07
INT 0x10
RET
NextLine:
MOV AL, 0
stosb
mov AH, 0x0E
MOV AL, 0x0D
INT 0x10
MOV AL, 0x0A
INT 0x10
ret
Boot:
CALL RebootKey
db 0x0ea
dw 0x0000
dw 0xffff
RebootKey:
mov ah, 0
int 0x16
cmp ah, 01h
jne RebootKey
PrintString:
next_character:
MOV AL, [SI]
INC SI
OR AL, AL
JZ exit_function
CALL PrintCharacter
JMP next_character
exit_function:
RET
Text db 'Loading...', 0
PressKeyForBoot db 'Press ESC key to reboot.', 0
TIMES 510 - ($ - $$) db 0
DW 0xAA55
我使用Windows,感謝您的幫助。 – AsdMan
@AsdMan,在Windows上,您可以使用** diskpart **實用程序將分區標記爲可啓動。你必須在你的U盤上標記分區爲'active'。 –
如果引導扇區位於USB記憶棒的第一個扇區上,則不需要將任何分區標記爲活動分區,因爲第一個扇區位於任何分區之外。實際上,設備第一扇區中包含的代碼的工作是讀取嵌入在其中的MBR分區表,並引導標記爲活動的分區。 –