g++ x64 register Problem

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
sevobal
Member
Member
Posts: 63
Joined: Sun Oct 22, 2006 7:11 am

g++ x64 register Problem

Post 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
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: g++ x64 register Problem

Post 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.
Last edited by 01000101 on Thu Feb 05, 2009 4:13 am, edited 1 time in total.
sevobal
Member
Member
Posts: 63
Joined: Sun Oct 22, 2006 7:11 am

Re: g++ x64 register Problem

Post 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) */
	
}
Post Reply