Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 23rd, 2006, 4:11 PM   #1
niteice
Programmer
 
niteice's Avatar
 
Join Date: Aug 2005
Posts: 98
Rep Power: 3 niteice is on a distinguished road
Send a message via AIM to niteice
GCC Inline Assembly

So I have some CPU detection code written up. It works perfectly in Visual C++, but I figured it couldn't hurt to have a version that works with GCC as well. I read up on how to properly do inline assembly in that, but everything seems to be conflicting, and the GCC manual was no help at all. It's my understanding that you need to specify which registers you modified, but no matter how I do it, I always get a syntax error. For example:
        // first, get the max cpuid level and mfg string
          __asm__ (
                "movl $0,%eax                \n\t"
                "cpuid                       \n\t"
                "movl %eax, maxLevel        \n\t"
                // now mfg string
                "movl %ebx, outID               \n\t"
                "movl %edx, (outID+4)           \n\t"
                "movl %ecx, (outID+8)           \n\t"
                "movl $0, (outID+12)            \n\t"
                : "=m" (maxLevel), "=m" (outID)
                :
                : "%eax", "%ebx", "%ecx", "%edx"
        );
(ignore potential oddities, this is my first foray into assembly and i ran it through an intel->at&t conversion script)

It looks exactly how the GCC manual states it should be. This always gives a syntax error on the ) at the end. Same thing happens with all of the other sections of assembly. Any ideas on the proper way to do this?
niteice is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC