我正在尝试在实模式下学习汇编。我想读取硬盘的引导扇区,所以下面是代码
org 100h
start:
xor ax, ax
mov es, ax ; ES <- 0
mov cx, 1 ; cylinder 0, sector 1
mov dx, 0080h ; DH = 0 (head), drive = 80h (0th hard disk)
mov bx, buff ; segment offset of the buffer
mov ax, 0201h ; AH = 02 (disk read), AL = 01 (number of sectors to read)
int 13h
jnc .read
.read:
mov ax, cs ; set up segments
mov ds, ax
mov es, ax
mov al, 03h
mov ah, 0
int 10h
mov si, buff
call print_string
.done:
jmp .done
print_string:
lodsb ; grab a byte from SI
test al, al ; logical or AL by itself
jz .done ; if the result is zero, get out
mov ah, 0x0E
int 0x10 ; otherwise, print out the character!
jmp print_string
.done:
ret
buff dw 512
我的执行环境是DosBox0.70,exe文件是.COM。我希望在屏幕上看到 512 字节,但是当我运行我的 .COM 文件时,它只是空白屏幕。我可以看到它背后的几个原因
1)给出的代码没有从 Bios 中断正确返回(int 13h)。2)字符串应该以 null 终止,这不会发生在这里。
但不确定是否是上述原因导致它发生,如果是,我该如何应对这些问题?