Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 27, 2007, 12:16 PM   #1
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
x86 Inline Assembly

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)
kainjow is offline   0 Reply With Quote
Old Jan 27, 2007, 01:22 PM   #2
iMeowbot
macrumors 601
 
iMeowbot's Avatar
 
Join Date: Aug 2003
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 )
iMeowbot is offline   0 Reply With Quote
Old Jan 27, 2007, 02:24 PM   #3
Flynnstone
macrumors 65816
 
Flynnstone's Avatar
 
Join Date: Feb 2003
Location: 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
__________________
"You can't solve you're problems with the same level of thinking that created the problems." - Einstein
New iMac 24"/G5 1.8/...
Flynnstone is offline   0 Reply With Quote
Old Jan 27, 2007, 04:41 PM   #4
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by kainjow View Post
(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.
gnasher729 is offline   0 Reply With Quote
Old Jan 28, 2007, 06:32 AM   #5
aLoC
macrumors 6502a
 
Join Date: Nov 2006
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.
aLoC is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Similar Threads
thread Thread Starter Forum Replies Last Post
jump's in inline assembler Larrson Mac Programming 4 Mar 5, 2009 03:31 AM
Assembly x86 question richard4339 Mac Programming 11 Feb 27, 2007 11:05 AM
x86 Assembly Questions Sean7512 Mac Programming 1 Nov 8, 2006 04:02 PM
OMG!!! Tiger for x86 processors has been leaked to the net and runs on any x86 box!! motulist OS X 2 Jun 12, 2005 08:53 AM


All times are GMT -5. The time now is 05:04 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC