![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: May 2005
Posts: 41
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
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! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|