如何解决Bootloader没有跳转到内核,汇编
我正在从《从0到1的操作系统》一书中学习操作系统。我正在尝试使用第7章中的代码,在那里他们构建了一个小型引导程序,并创建了一个名为sample的小型程序,在此程序中获得了引导程序。跳转到示例代码。在文本中,他们希望我使用gdb在0x500处设置断点,以检查下一个汇编代码是否来自sample.asm。但是,当我在gdb中将0x500处设置断点时,运行程序直至断点后,GDB会输出
Program received signal SIGTRAP,Trace/breakpoint trap.
0x0000000000000000 in ?? ()
布局asm表示“没有可用的装配体”
我还检查了int 0x13之后的cf标志,该标志为0,它表示读取扇区没有错误。
我的问题是我跳到错误的地址还是我的代码有其他问题?
bootloader.asm;
;*************************************************
; bootloader.asm
; A Simple Bootloader
;*************************************************
org 0x7c00
bits 16
start: jmp boot
;; constants and variable definitions
msg db "Welcome to My Operating System!",0ah,0dh,0h
boot:
cli ; no interrupts
cld ; all that we need to init
mov ax,0x50
;; set buffer
mov es,ax
xor bx,bx
mov al,1 ; read one sector
mov ch,0 ; track 0
mov cl,2 ; sector to read
mov dh,0 ; head number
mov dl,0 ; drive number
mov ah,0x02 ; read sectors from disk
int 0x13 ; call the BIOS routine
jmp 0x50:0x0 ; jump and execute the sector!
hlt ; halt the system
; We have to be 512 bytes. Clear the rest of the bytes with 0
times 510 - ($-$$) db 0
dw 0xAA55 ; Boot Signature
sample.asm
; ******************************************
; sample.asm
; A Sample Program
; ******************************************
mov eax,1
add eax,1
我编写了引导加载程序,然后将其采样到Linux上的img文件中,
nasm -f bin bootloader.asm -o bootloader
dd if=/dev/zero of=disk.img bs=512 count=2880
dd if=bootloader of=disk.img conv=notrunc
dd if=sample of=disk.img bs=512 seek=1 conv=notrunc
然后使用了QEMU
qemu-system-x86_64 -machine q35 -fda disk.img -gdb tcp::26000 -S
然后使用gdb连接到它;
set architecture i386:x86-64
target remote localhost:26000
b *0x500
c
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。