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 your 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

Similar Threads
thread Thread Starter Forum Replies Last Post
Using Inline or External Assembler with Xcode ? Elhardt Mac Programming 29 Oct 5, 2013 02:10 AM
iPad: Newsstand icons no longer inline. Why? skipsands Jailbreaks and iOS Hacks 0 Jun 10, 2013 04:37 PM
Inline Instagram removed from Tweetbot danmcq iPhone and iPod touch Apps 2 Apr 5, 2013 01:45 PM
Inline Editing in new CKEditor ckeuser Web Design and Development 2 Dec 10, 2012 06:40 AM

Forum Jump

All times are GMT -5. The time now is 02:42 AM.

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

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