我已經寫了簡單的引導程序基於:http://www.viralpatel.net/taj/tutorial/hello_world_bootloader.php的Bootloader與圖形(NASM)
[BITS 16] ;16bit
[ORG 0x7C00] ;offset
MOV AH, 0x00 ; change video mode
MOV AL, 0x13 ; 0x13
INT 0x10 ; interrupt
CALL DrawTenLines ;lets draw
JMP $ ;hang it
DrawOneLine:
MOV CX, 0x00 ;x = 0
nextpixel:
MOV AH, 0x09 ;func number - WritePixelOnScreen [wiki]
MOV AL, 0x05 ;color - Magenta
MOV BH, 0x00 ;Page no
INT 0x10 ;Video interrupt - BIOS
CMP CX, 10 ;if (x == 10) {
JE exitfunc ;exit function } else {
JNE nextpixel ;next pixel }
ADD CX, 0x01 ;add one :D
exitfunc: ;exit :D
RET
DrawTenLines: ;draw some lines
MOV DX, 0x00 ;y = 0
CALL DrawOneLine
MOV DX, 0x01 ;y = 1
CALL DrawOneLine
MOV DX, 0x02 ;y = 2
CALL DrawOneLine
MOV DX, 0x03 ;y = 3
CALL DrawOneLine
MOV DX, 0x04 ;y = 4
CALL DrawOneLine
MOV DX, 0x05 ;y = 5
CALL DrawOneLine
RET
;Data
TIMES 510 - ($ - $$) db 0 ;Fillers
DW 0xAA55 ;boot signature
但如預期,這並不工作 - 不畫,只有黑色的屏幕和掛起(如預期)。
與NASM編譯,-f bin。這個網站的例子起作用。在Virtualbox中測試。
編輯:忘記更改視頻模式 - 但仍然無法正常工作。
編輯2:此代碼: [比特16]; 16位 [ORG 0x7C00];偏移
MOV AH, 0x00
MOV AL, 0x13
INT 0x10
MOV AH, 0x09 ;WritePixelOnScreen [wiki]
MOV AL, 0x0F ;color - White
MOV BH, 0x00 ;page no.
MOV CX, 1 ;x
MOV DX, 1 ;y
INT 0x10 ;interrupt
MOV CX, 2 ;x
MOV DX, 1 ;y
INT 0x10 ;interrupt
MOV CX, 3 ;x
MOV DX, 1 ;y
INT 0x10 ;interrupt
JMP $ ;hang
;Data
TIMES 510 - ($ - $$) db 0 ;filler
DW 0xAA55 ;boot signature
使: http://i.imgur.com/UGS3m.png
BTW。第二部分是什麼?你也可以幫助我嗎? – djmati11 2012-03-31 17:38:43