Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

64 bits gas mov instruction

1,627 views
Skip to first unread message

Peter Cheung

unread,
Feb 5, 2013, 11:16:07 PM2/5/13
to
Hi all

__asm__ __volatile__(
"movl $0x1100000,%%eax;"
"mov %%eax,%%cr3;"
"mov %%cr0,%%eax;"
"or $0x80000000,%%eax;"
"mov %%eax,%%cr0"::"a"(pageDirectories[0])
);

I compile it using 64 bits gcc and i got:
kernel.c:473: Error: unsupported instruction `mov'
kernel.c:473: Error: unsupported instruction `mov'
kernel.c:473: Error: unsupported instruction `mov'

I tried, movl, movw and even %%rax, still no luck, please help

thanks
from Peter (cmk...@hotmail.com)

grady...@gmail.com

unread,
Feb 6, 2013, 10:55:32 PM2/6/13
to
> from Peter (redacted)


shouldn't 64 bit mov be movq

CN

unread,
Feb 9, 2013, 3:30:54 PM2/9/13
to
First of all, if the assembler is in 64-bit mode, you need to use 64-bit
registers (i.e. %%rax) in all MOV'es between a register and a CR.

Second, you're doing something wrong. This code enables paging. That
means that coming into this code, the CPU is in 32-bit mode. However,
since you build with 64-bit GCC, your assembler generates 64-bit code by
default. Also, any compiled C code (which I assume exists before and
after this __asm__ statement) produces 64-bit code. The two modes are
not binary compatible, you can't do that.

If you want the rest of your kernel.c to produce 64-bit code, you should
move the "enable paging" code into a separate file, either purely
assembler or C containing 32-bit code. Then build it with "gcc -m32" --
that switches GCC to generating 32-bit code.

If you want your kernel.c to produce 32-bit code, then just add -m32 to
GCC options when building that file. That should make the above
statement build without errors.
0 new messages