としてメモリにBIOSによって読み込まれたアセンブリプログラムでのラベルの使用。それは以下のように、(16-BIT REAL MODE IN)第3章ブートセクタプログラミングの例があります。メモリー参照し、私はOSの開発に<a href="https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf" rel="nofollow noreferrer">book by Nick Blundell</a>勉強してブートセクタ
;
; A simple boot sector program that demonstrates addressing.
;
mov ah, 0x0e ; int 10/ ah = 0eh -> scrolling teletype BIOS routine
; First attempt
mov al, the_secret
int 0x10 ; Does this print an X?
; Second attempt
mov al, [the_secret]
int 0x10 ; Does this print an X?
; Third attempt
mov bx, the_secret
add bx, 0x7c00
mov al, [bx]
int 0x10 ; Does this print an X?
; Fourth attempt
mov al, [0x7c1e ]
int 0x10 ; Does this print an X?
jmp $ ; Jump forever.
the_secret :
db "X"
; Padding and magic BIOS number.
times 510 -($ - $$) db 0
dw 0xaa55
本では、それがいることを述べている:我々はプログラムを実行する場合
2番目の2つの試みだけが 'X'を印刷するのに成功していることがわかります。 私のQEMU BIOSは「Xを印刷していることを暗示している
:私の結果はこれです
$ nasm BOOK_EXAMPLE.asm -f bin -o BOOK_EXAMPLE.bin $ qemu-system-i386 BOOK_EXAMPLE.bin
:それは私から取得していた結果ではありません
まあ、 "3回目の試行でのみ。私は本の例を修正しなかった、私は何が欠けているのだろうか。私のバイナリコードの
UPDATE
オブジェクトのダンプが0x58
すなわち "X" 用の六角ASCIIコードがメモリアドレスであることを示している= 0x7c1d
$ od -t x1 -A x BOOK_EXAMPLE.bin
000000 b4 0e b0 1d cd 10 a0 1d 00 cd 10 bb 1d 00 81 c3
000010 00 7c 8a 07 cd 10 a0 1e 7c cd 10 eb fe 58 00 00
000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
000200
0x7c00
+ 0x001d
は、そのため私は1つを置き換えます
mov al, [0x7c1d ]
:以下とのコード行
今、出力が期待通りである:最後の1が使用している