Page 1 of 1

g++ x64 register Problem

Posted: Thu Feb 05, 2009 3:33 am
by sevobal
Hi,
I've tried to use the inline assembler of g++ to access the x64 register r8:

Code: Select all

void Video::clear()
{
	asm("movl $0,%%r8");         /* Clear Screen */
	asm("int  $0x30");           /* Call Video driver (text mode) */	
}
But when I try to compile the whole code with g++ I got the following error message: "Video.cpp:26: Error: Bad register name '%%r8'"

What's my mistake?

Thanks for your help :D

Re: g++ x64 register Problem

Posted: Thu Feb 05, 2009 4:07 am
by 01000101
because you're not using extended inline assembly (using asm(" "): out:in:clobber), you only need one % for register references.

So it should be %r8 instead of %%r8.

Re: g++ x64 register Problem

Posted: Thu Feb 05, 2009 4:10 am
by sevobal
Thank you very much!

Here's the working code:

Code: Select all

void Video::clear()
{
	asm("movq $0, %r8");         /* Clear Screen */
	asm("int  $0x30");           /* Call Video driver (text mode) */
	
}