私はちょうどマシンレベルの x86 コーディングに近づいているので、私の質問の些細なことを許してください。次のコードは、単純なブートローダーを意図しています。フロッピー ディスクの一部のセクタをメモリにダンプし、ロードされたコードにジャンプします。コメントで説明されているように、ロードされたコードで、メモリ変数から読み取ろうとしましたが、成功しませんでした。
[ORG 0]
jmp 07C0h:start ; Goto segment 07C0
start:
; Update the segment registers
mov ax, cs
mov ds, ax
mov es, ax
reset: ; Reset the floppy drive
mov ax, 0
mov dl, 0
int 13h
jc reset
read:
mov ax, 1000h ; ES:BX = 1000:0000
mov es, ax
mov bx, 0
mov ah, 2 ; Load disk data to ES:BX
mov al, 5 ; Load 5 sectors
mov ch, 0 ; Cylinder=0
mov cl, 2 ; Sector=2
mov dh, 0 ; Head=0
mov dl, 0 ; Drive=0
int 13h ; Read!
jc read ; on error
jmp 1000h:0000 ; Jump to the program
times 510-($-$$) db 0
dw 0AA55h
; == Loaded code from second floppy sector ==
prog:
mov ah, 0x0E ; Prints a char. This one works: the '-'
mov al, '-' ; is printed.
mov bx, 0
int 10h
mov bx, 0
a:
mov al, [L1+bx] ; Should read from L1 and print out chars.
inc bx ; But it prints only white spaces. Why?
int 10h
cmp bx, 10
jz h
jmp a
cli
hlt
L1 db "0123456789" ; my string
なぜうまくいかないのか理解できません。どんな助けにも感謝します。