2

コードを使用してブートローダーから文字を印刷しようとしています

[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 AL, 65
CALL PrintCharacter
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

TIMES 510 - ($ - $$) db 0   ;Fill the rest of sector with 0
DW 0xAA55           ;Add boot signature at the end of bootloader

Hello World Bootloaderの記述の指示に従ってください。しかし、何も印刷せずにハングします。これをどのようにデバッグできますか? 次のコードを使用して、ハングするブートローダーを正常に作成しました

[BITS 16]   ;tell 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

JMP $       ;infinite loop

TIMES 510 - ($ - $$) db 0   ;fill the rest of sector with 0
DW 0xAA55           ; add boot signature at the end of bootloader

VMware 3.0.0 build-203739 でコードをテストしています。

4

2 に答える 2

2

リアルモード X86 をデバッグするには、Dosbox に統合されたデバッガーを試すことができます。

于 2010-01-12T05:59:48.767 に答える
0
[BITS 16]       ; We need 16-bit intructions for Real mode
[ORG 0x7C00]    ; The BIOS loads the boot sector into memory location
0x7C00
       mov ah, 0Eh     ; We want to print a single character
       mov al, 'A'     ; That character is 'A'
       mov bh, 0Eh     ; White text on black background, not blinking
       mov bl, 0       ; Page number 0
       int 10h

hang:
       jmp hang        ; Loop, self-jump

times 510-($-$$) db 0  ; Fill the rest of the files with zeros, until we reach 510 bytes
dw 0AA55h              ; Our boot sector identifyer

- Windows で nasm と Bochs の助けを借りて、このコードを実行することに成功しました。手順:- 1)nasm -f bin booting.asm -o booting.bin '-f bin' は、形式をプレーン バイナリに指定します。2) ファイルを Bochs のディレクトリにコピーし、booting.bin をフロッピーとして実行すれば完了です。

binファイルのイメージをフラッシュドライブに書き込んでテストし、そのフラッシュドライブを起動すると、期待どおりの結果が得られました。http://www.weethet.nl/english/hardware_bootfromusbstick.phpですべての情報を取得でき ます。

于 2012-03-22T08:22:00.147 に答える