Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kainjow

Moderator emeritus
Original poster
Jun 15, 2000
7,958
7
I am trying to play around with some assembly commands in Xcode and I'm getting a "Invalid mnemonic 'mov'" error. I have a basic Foundation Tool project setup:

Code:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
  asm
  {
    mov 0x1, eax
  }	
  return 0;
}

I have Google'd a lot and haven't found anything helpful really. I'm assuming I'm missing a compiler switch or something?

(I eventually want to get the CPUID opcode to work, but that gives the same error)
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
Is gcc getting an -arch i386 somewhere? I can duplicate that message if I force ppc.

For that mov in your example, I'd also check the operand order (the att vs. intel syntax thing drives me nuts, I always forget which is which and ultimately do the right thing, go back to C :p )
 

Flynnstone

macrumors 65816
Feb 25, 2003
1,438
96
Cold beer land
This is my opinion : avoid assembler.
Just about anything can be done in C. I write embedded firmware. I / my project, limit assembler to bootup code. That is setting basic access and peripherals. Such as turning on RAM systems and setting up stacks.
You want to access a certain memory location, you can use C.
Sorry if sounds like a rant. I suppose it is. Just trying to help.

I've done much x86 assembler in the mid 80s. So this is similar to me saying don't put your hand in a meat grinder. I'm not sure which is worse :eek:
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
(I eventually want to get the CPUID opcode to work, but that gives the same error)

Spotlight is your friend: Command-space, type in "cpuid", and it finds a file "cpuid.h" which should contain everything you need.
 

aLoC

macrumors 6502a
Nov 10, 2006
726
0
I don't get that error, I get "suffix or operands invalid for 'mov' "
If I reverse the operands, e.g. mov eax, 0x1 it compiles and runs fine.

This is an Intel iMac, opening XCode and doing a new "Foundation Tool" project.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.