如何从加载在NASM汇编BIOS INT 13H磁盘上的内核? [英] How to load a kernel from disk with BIOS int 13h in NASM assembly?
问题描述
我一直坚持这个数周现在不知道我要去哪里错了,因为NASM还没有给我任何错误。在code是因为评论pretty自我解释。
I've been stuck with this for weeks now and have no idea where I'm going wrong because NASM hasn't given me any errors. The code is pretty self explanatory because of the comments.
这是从BIOS
;--------------------------------------------
; 'boot.asm'
; loaded from BIOS
[org 0x7C00]
[bits 16]
;--------------------------------------------
main:
mov ah, 0x0E ; print function
mov al, '.' ; ascii char
int 0x10 ; IO int
resetdisk:
mov ah, 0x00 ; reset function
mov dl, 0x00 ; drive
int 0x13 ; disk int
jc resetdisk
readdisk:
mov bx, 0x8000 ; segment
mov es, bx
mov bx, 0x0000 ; offset
mov ah, 0x02 ; read function
mov al, 0x03 ; sectors
mov ch, 0x00 ; cylinder
mov cl, 0x02 ; sector
mov dh, 0x00 ; head
mov dl, 0x00 ; drive
int 0x13 ; disk int
jc readdisk
jmp [es:bx] ; buffer
;--------------------------------------------
times 510 - ($ - $$) db 0x00
db 0x55, 0xAA
这是code,应该是(但不)加载
This is the code that should be (but isn't) loaded
;--------------------------------------------
; 'load.asm'
; loaded from 'boot.asm'
[org 0x8000]
[bits 16]
;--------------------------------------------
main:
mov ah, 0x0E ; print function
mov al, '.' ; ascii char
int 0x10 ; IO int
jmp $ ; hang
的任何的帮助将非常AP preciated。
Any help would be much appreciated.
帕特里克
推荐答案
JMP [ES:BX]
不跳转到地址 ES :BX
。这个命令做了近跳转到存储在字地址在 ES:BX
。这就是为什么很多老版本的汇编作出拼写这种指令的为 JMP单词PTR [ES:BX]
甚至 JMP附近PTR [ES: BX]
;它更清晰这样什么事情发生。你可能想在这里什么是远跳转到一个固定的位置:
jmp [es:bx]
doesn't jump to the address es:bx
. This command does a near jump to the address stored in the word at es:bx
. This is why lots of older assemblers made you spell this kind of instruction as jmp word ptr [es:bx]
or even jmp near ptr [es:bx]
; it's clearer this way what is going to happen. What you probably want here is a far jump to a fixed location:
; jmp far 8000:0000
db 0eah
dw 00000h ; offset
dw 08000h ; segment
如果你想跳到 ES:BX
,使用 RETF
:
push es
push bx
retf
这篇关于如何从加载在NASM汇编BIOS INT 13H磁盘上的内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!