【发布时间】:2023-12-24 17:23:01
【问题描述】:
我编写了简单的引导加载程序,基于:http://www.viralpatel.net/taj/tutorial/hello_world_bootloader.php
[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
【问题讨论】:
-
顺便说一句。第二部分是怎么回事?你也可以帮我做一个吗?
标签: assembly nasm bootloader