引导加载程序不断向al添加eax

问题描述 投票:2回答:1

我正在尝试构建我的第一个bootloader,它确实有效,但根据gdb,有一件事情发生,我不明白。

这是我用nasm编写的bootloader:

org 0x7c00
bits 16
start: jmp boot

msg db "Bootinggggg!", 0

Print:
lodsb ;loading si to al
cmp al,0 ;loop
je PrintDone
mov ah,0eh
mov bl,14 ;yellow color
int 10h
jmp Print 

PrintDone:
ret

boot:
mov ah,00h
mov al,0eh
int 10h ;stepping into graphic mode
mov si,msg
call Print
cli
cld
hlt


times 510-($-$$) db 0
dw 0xAA55 

我在我的unbuntu机器上使用qemu并可视化8086架构。在gdb中使用ni命令几次后,gdb显示该程序只是无休止地将eax添加到al。我多次按下ni,它只是不断添加它。但是,当我按下继续它实际上工作,因为你可以看到它打印字符串。为什么会这样?

screenshot

assembly gdb nasm x86-16 bootloader
1个回答
3
投票

你正在拆解空白记忆。 00 00add %al, (%eax)add [eax], al的编码。您可以使用this online disassembler轻松检查

0:  00 00                   add    BYTE PTR [eax],al

请注意,该指令不是向al添加eax。它将al添加到eax指向的地址处的值

© www.soinside.com 2019 - 2024. All rights reserved.