Both of bochs and qemu cann't executable "movabs"?

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
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

Both of bochs and qemu cann't executable "movabs"?

Post by windows8 »

Code: Select all

movabs $_start64,%rcx
jmp *%rcx
This code cannot work,but this code can work:

Code: Select all

movq 1f,%rcx
jmp *%rcx
1: .quad _start64
Although | don't have to use "movabs",I cannot prevent the gcc/g++........
I have not encountered this situation before,I searched google but it didn't help me......

This is output of "objdump -S kernel"

Code: Select all

  8000100224:	48 b8 00 02 10 00 80 	movabs $0x8000100200,%rax
  800010022b:	00 00 00 
Thanks for your help!
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Both of bochs and qemu cann't executable "movabs"?

Post by alexfru »

The intent is clear, the instruction itself should work. I suspect something's wrong with the address, e.g. how you obtain it (linker issue?).

OTOH, it could be that you're missing or having an extra indirection. Do you really need a star in there?
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

Re: Both of bochs and qemu cann't executable "movabs"?

Post by windows8 »

alexfru wrote:The intent is clear, the instruction itself should work. I suspect something's wrong with the address, e.g. how you obtain it (linker issue?).

OTOH, it could be that you're missing or having an extra indirection. Do you really need a star in there?
But wherever I put this code,it doesn't work at all.

I test this code just now:

Code: Select all

movabs $~0,%rax
cli
hlt
It doesn't work.

Code: Select all

cli
hlt
Of course,this code can work.

It seems impossible,I don't know where the wrong was.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Both of bochs and qemu cann't executable "movabs"?

Post by bluemoon »

What you meant by "not work"? Is there any hint from bochs?

by the way, movabs (or simply mov r64, imm64) is only available in long mode, are you in long mode when executing such instruction?
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

Re: Both of bochs and qemu cann't executable "movabs"?

Post by windows8 »

bluemoon wrote:What you meant by "not work"? Is there any hint from bochs?

by the way, movabs (or simply mov r64, imm64) is only available in long mode, are you in long mode when executing such instruction?
The Virtual Machine reboot at once.

Yes,I am in long mode.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Both of bochs and qemu cann't executable "movabs"?

Post by bluemoon »

windows8 wrote:The Virtual Machine reboot at once.
Yes,I am in long mode.
This is contradicting.
To enter long mode properly you need exception handlers. This should give a trace instead of "reboot at once".
Also, bochs should have said something when it reboot (due to triple fault I believe).
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

Re: Both of bochs and qemu cann't executable "movabs"?

Post by windows8 »

bluemoon wrote:
windows8 wrote:The Virtual Machine reboot at once.
Yes,I am in long mode.
This is contradicting.
To enter long mode properly you need exception handlers. This should give a trace instead of "reboot at once".
Also, bochs should have said something when it reboot (due to triple fault I believe).
It happens when I just entered long mode (in /arch/boot/boot.s),"callq kmain" (to /kernel/init/main.cpp) is not executed.
Is it really necessary to set exception handlers here?

It seems I found the reason,I set GDT to a wrong value....

Thanks.
User avatar
iansjack
Member
Member
Posts: 4709
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Both of bochs and qemu cann't executable "movabs"?

Post by iansjack »

It is, strictly speaking, not essential to have exception handlers. But, if you don't, it causes so many problems that it is foolish not to do so.

I don't know about others, but I would really appreciate it if people who can't be bothered to write simple exception handlers didn't waste forum space by asking why their code isn't working. You've got to help yourself just a little bit before relying upon others to do your debugging for you.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Both of bochs and qemu cann't executable "movabs"?

Post by Combuster »

See Posting Checklist. The biggest problem here is the total lack of logs, even after several screens worth of debate going nowhere because of just this. Having interrupt handlers are nice, but you need to be able to get them running in the first place.

My crystal ball can't seem to decide on his addressing scheme being screwed up, or not being in long mode at all.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: Both of bochs and qemu cann't executable "movabs"?

Post by no92 »

Combuster wrote:My crystal ball can't seem to decide on his addressing scheme being screwed up, or not being in long mode at all.
I finally start to adore your crystal ball. :D
User avatar
iansjack
Member
Member
Posts: 4709
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Both of bochs and qemu cann't executable "movabs"?

Post by iansjack »

no92 wrote:
Combuster wrote:My crystal ball can't seem to decide on his addressing scheme being screwed up, or not being in long mode at all.
I finally start to adore your crystal ball. :D
I don't know. It never seems to work very well. ;)
Post Reply