Something wrong with bochs?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
MarkZar
Posts: 13
Joined: Thu Feb 07, 2013 11:53 pm

Something wrong with bochs?

Post 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?
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Something wrong with bochs?

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Something wrong with bochs?

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
MarkZar
Posts: 13
Joined: Thu Feb 07, 2013 11:53 pm

Re: Something wrong with bochs?

Post by MarkZar »

Thanks, John and Brendan, it seems that something happend when compile/link the file. nothing wrong with bochs. :D
Post Reply