私はブートローダを起動するのにBochsを使用しています。https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf 第4.1章BIOSへの文字列の印刷ビデオメモリが動作しない
私はBochsを実行すると直接ビデオメモリに書き込むことでBIOSコンソールに印刷しようとしていますが、印刷された文字列は表示されません。コードは実際にはPDF上のコードと同じです。 何か不足していますか? Bochsの設定が忘れていたのですか、PDFが私に教えてくれなかったことはありますか?ここで
はここで機能
;
; A simple collection of string routines for 32-bit protected mode.
;
[bits 32]
VIDEO_MEMORY equ 0xB8000
WHITE_ON_BLACK equ 0x0f ; Color mode for the text to be written
PrintString: ; Assume ebx holds memory address of string.
; edx will hold start of video memory
; Recall that each character written will take up 2 bytes of video memory
; So any particular row or column on the screen will have mem location = 0xb80000
; + 2 * (80r + c)
; The way this code is written, its always writing starting from the start of the
; video memory at 0xb8000, the top left of the screen, replacing everything there.
pusha
mov edx, VIDEO_MEMORY
PrintLoop:
mov al, [ebx] ; Only ebx can be used to index
mov ah, WHITE_ON_BLACK
cmp al, 0
je ExitRoutine
mov [edx], ax
inc ebx
add edx, 2
jmp PrintLoop
ExitRoutine:
popa
ret
を含むアセンブリファイルである私の実際のブート・ロジックです。
;
; A simple boot sector program that loops forever.
;
[bits 32]
[org 0x7c00]
mov ebx, welcome_msg
call PrintString
jmp $
%include "string_utils.s"
welcome_msg db 'WELCOME TO BASICOS OMFG!', 0
goodbye_msg db 'Goodbye! Thanks for using my BasicOS!', 0
times 510 -($ - $$) db 0
dw 0xaa55
「DS」の値は何ですか? – xmojmr
コードが32ビット保護/非現実的なモード用であることをご存知ですか?あなたのブートローダは、ちょうど2番目のスニペットにあるものではありません。 –
16ビットリアルモードのコードをターゲットにしているので(ブートローダーがプロテクトモードに移行していないため)、ビット16ではなくビット32を使用する必要があります。 386台のマシンとほとんどの386台のエミュレータでBIOSが動作するのは、[非現実的なモード](https://en.wikipedia.org/wiki/Unreal_mode)になってしまいます。 16ビット命令を持つデータには、32ビット・アドレスを持つ32ビット・レジスタを使用できる必要があります。これはもちろん8086または80286プロセッサ(とおそらく古代の80386ハードウェア)でも動作しません –