2010-01-12 4 views
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 

, как указано в Writing 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 билд-203739.

ответ

2

Для отладки реального режима X86 вы можете попробовать отладчик, интегрированный с Dosbox.

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 

- я успешно удалось запустить этот код с помощью 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

Смежные вопросы