2

I know I succeed in writing my code to that address using int 13h because I can see it at that memory location. What I can't do is jump there.

I put 0x1000 (three zeros there) into es and 0x0000 into bx and I know that [es:bx] means the address calculated by (es * 0x10) + bx which does equal 0x10000 (four zeros there). But eip, the instruction pointer, never does go there.

I've tried jmp [es:bx], jmp 0x1000:0x0000, and a bunch of other permutations that NASM doesn't even accept.

My boot loader as it currently is (which still isn't working) is here. I booted it up in Qemu and did a memsave on the first 50 bytes at 0x10000, opened it up with tweak, and saw my "kernel" code there (simple . But EIP still refuses to be 0x10000, or reach it and then hang where I want it, is what I mean). Full images of the situation here

4

2 回答 2

2

远跳转不能使用仅用于段的内存位置。您可以通过以下几种方法来做到这一点:

1) 段和偏移量的简单硬编码地址。

jmp 0x1000:0

2)使用全地址间接跳转:

entry dw 0x0000 ; offset
      dw 0x1000 ; segment

jmp far dword ptr [entry] ; far jump (syntax might differ)

3)远回报

push SYSADDR ; segment
push 0       ; offset
retf         ; far return

在 DOS 时代使用的一个常见技巧是修补指令:

  mov ax, SYSADDR
  mov word ptr [myjump+3], ax
myjump:
  jmp 0x0000:0x0000

或使用其中的一部分作为变量:

myjump:
  db 0xEA           ; far jmp opcode 
  dw 0x0000         ; offset part
  SYSADDR dw 0x1000 ; segment part

免责声明:以上所有内容均来自记忆,我可能弄错了某些部分(例如,段/偏移量的顺序非常混乱)。

于 2012-06-25T13:53:01.083 回答
0

你应该能够做你正在尝试的事情。这是一个做同样事情的例子,大概是出于同样的原因:

; http://www.free2code.net/tutorials/view/writing_your_own_operating_system-12/page1.html
...
mov bx,0x1000  ;Es and Bx put together are where to load the program too 
               ; (see jmp x1000:0x00)
mov es,bx
mov bx,0x00
int 13h        ;Int 13 is all functions for disks
...
于 2012-06-22T22:27:58.683 回答