Page 1 of 1

Something wrong with bochs?

Posted: Fri Feb 08, 2013 12:17 am
by MarkZar
I'm learning to write a tiny os, and debug it using bochs. But now something strange happend. Following is the code which has been moved to 0x9000:0x0100
1.png
As you can see, the beginning part of the code is jmp .+97, whose corresponding machine code is E96100, but the machine code isn't it! Open the file with ghex, and you can see the right machine code: EB61, in corresponding with the assembly code: jmp .+63h.
2.gif
Then I looked the following codes in bochs using x/10 0x9000:0x0100:
3.png
I found that the following codes is the same with those in ghex, only that there is one more 00 in bochs's codes, just as I pointed out just now.

So how to explain that E96100? If you try to disassemble the E96100 to assembly code, you may find there is not corresponding relations with E96100 and jmp .+97, what's wrong with that?

Re: Something wrong with bochs?

Posted: Fri Feb 08, 2013 12:42 am
by jnc100
MarkZar wrote:If you try to disassemble the E96100 to assembly code, you may find there is not corresponding relations with E96100 and jmp .+97, what's wrong with that?
0xe9 0x61 0x00 does indeed disassemble to jmp +97.

As regards your problems, are you sure you are properly loading your kernel to the location you think you are? I suspect a problem with your bootloader.

Regards,
John.

Re: Something wrong with bochs?

Posted: Fri Feb 08, 2013 1:47 am
by Brendan
Hi,
MarkZar wrote:I found that the following codes is the same with those in ghex, only that there is one more 00 in bochs's codes, just as I pointed out just now.
For the first 2 (or 3) bytes, 0xEB, 0x61 is "jmp short +0x61" and 0xE9, 0x61, 0x00 is "jmp near +0x0061". The only difference is likely to be whether or not you told the assembler to optimise.

The rest of the bytes are identical, and I suspect your confusion is because it's little-endian- e.g. thinking that 0x00010102 is equivelent to the bytes "0x02, 0x01, 0x01, 0x00" when it's actually "0x00, 0x01, 0x01, 0x02".


Cheers,

Brendan

Re: Something wrong with bochs?

Posted: Fri Feb 08, 2013 4:02 am
by MarkZar
Thanks, John and Brendan, it seems that something happend when compile/link the file. nothing wrong with bochs. :D