gpt4 book ai didi

assembly - 引导加载程序不断将 eax 添加到 al

转载 作者:行者123 更新时间:2023-12-05 03:02:00 25 4
gpt4 key购买 nike

我正在尝试构建我的第一个引导加载程序,它确实有效,但根据 gdb 的说法,还有一件事我不明白。

这是我用 nasm 编写的 Bootstrap :

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

最佳答案

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

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

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

关于assembly - 引导加载程序不断将 eax 添加到 al,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55265712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com