delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2007/10/24/19:02:11

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
From: "Gerrit van Niekerk" <gerritvn AT gpvno DOT co DOT za>
Organization: GPvNO
To: djgpp AT delorie DOT com
Date: Thu, 25 Oct 2007 01:00:56 +0200
MIME-Version: 1.0
Subject: Using inline asm
Message-ID: <471FEAC8.5179.2FAB88DB@gerritvn.gpvno.co.za>
X-mailer: Pegasus Mail for Windows (4.41)
Reply-To: djgpp AT delorie DOT com

How can I get GCC to move a register value to a C variable? As I 
understand the Info documentation, this is how I should do it:

int CheckProcessor (void)
{
   int iRet;
   asm ("cpuid");
   asm ("movl %eax,%0" : "=g" (iRet));
   return iRet;
}

This gives me an error on the second "asm" line:
(445) Error: error: invalid 'asm': operand number missing after %-letter

I have tried different constraint codes, but they all give the same problem. 
How should I do it?


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019