Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Jul 9th, 2005, 12:27 PM   #1
MrSmiley
Programmer
 
MrSmiley's Avatar
 
Join Date: May 2005
Posts: 41
Rep Power: 0 MrSmiley is on a distinguished road
INLINE conversions

Ok, so I am getting off of Visual Studios 6 and moving to Dev-C++(Which uses GCC). Well I'm currently writing an app that taps your Hardware information to get CPUID. It compiles fine in VS6 but since GCC uses AT&T asm, I'm stuck doing something completly different. So, I was wondering if anyone could tell me the proper way to translate this...

_asm{ 
xor eax, eax 
cpuid 
mov cpumax, eax 
// put vendor string in cpusignature 
mov edi, t 
mov dword ptr [edi], ebx 
mov dword ptr [edi+4], edx 
mov dword ptr [edi+8], ecx 
mov byte ptr [edi+12], 0 
}

Also if anyone knows how to get either the FSB or Multi from CPUID that information would be greatly appreciated.
MrSmiley is offline   Reply With Quote
Old Jul 9th, 2005, 3:03 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Generally speaking, to translate to ATT syntax, do the following:

Add a suffix to the instruction indicating the operand size (even though it's usually implicit in the register operands), prepend the register name with a '%', and reverse the source and destination operands.

Example: mov bl, al ==> movb %al, %bl.

Immediate values are indicated by a '$':
movl $0xffff, %eax

Indirect memory references use parentheses:
mov dword ptr [edi+4], edx ==> movl %edx, (%edi+4)

That's sort of from the seat of my pants, might have something wrong. GCC also has another mechanism using an instruction template with register constraints, but it seems unnecessarily complicated to me.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 9th, 2005, 3:39 PM   #3
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
There is a compiler switch you can use to avoid the at&t mess. "-masm=intel" There is an example here. The formatting was buggered when the forum switched but it's readable. Also I wonder if this Dev-C++ everyone uses has a full installation of gcc or just enough to get by? I'll check it out for myself. Personally I'm more of a notepad/command-line kiddie.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz 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 5:15 AM.

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