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 Dec 24, 2012, 02:58 PM   #1
Bloupies
macrumors newbie
 
Join Date: Dec 2012
NASM et mac os ( french man sorry )

Good evening

I apologize beforehand, I am French. It has been several days since I look for solutions concerning NASM and mAC bone, but I find only the English forums..

I am thus on mac bone and I would like to compile a program assembler

For exemple :

Code:
%include "iut.inc" 
segment .text 
global start 

start:
	mov 	eax, msg_Accueil
	call 	write_string

	mov 	eax,msg_Nombre
	call 	write_string

	call 	read_int
	mov 	ebx,eax
	
	mov 	eax,msg_Base
	call 	write_string

	call 	read_int
	mov		ecx,eax

	call 	SousProg	;APPEL DU SOUS PROGRAMME
	mov		edx,eax
	
	mov 	eax, msgResultat
	call	write_string
		
	mov 	eax, ebx
	call	write_int
		
	mov 	eax, msgResultat1
	call	write_string
	
	mov		eax, ecx
	call	write_int
		
	mov 	eax, msgResultat2
	call	write_string

	mov		eax, edx
	call	write_int
		
	ret

SousProg:
	;EMPILEMENT DES REGISTRES UTILISES
	push	ebx
	push	ecx
	;TRAITEMENT
	

	mov 	ebx,1312
	mov 	ecx,5476
	
	mov		eax,45
	;FIN DU TRAITEMENT
	;J'AI MODIFIE LA VALEUR DE ebx ET DE ecx POUR LES BESOINS DU TRAITEMENT
	
	;RESTAURATION DES REGISTRES UTILISES
	pop		ecx
	pop		ebx
	ret
		
segment .data

msg_Accueil:	db	"Convertion d'un nombre en base b en decimal",10,0
msg_Nombre:		db	"Saissez le nombre a convertir",10,0
msg_Base:		db	"Saissez la base du nombre",10,0
msgResultat:	db	10,"le resultat de la convertion du nombre ",0
msgResultat1	db	" en base ",0
msgResultat2	db	" en decimal est ",0

In class, to I was told that to compile under Linux, it was necessary to make:

Code:
nasm f elf exemple.asm
gcc o exemple exemple.o L. lIUT -lncurses -lpanel
And have librairies : iut.int , libIUT.a

So , when i do
Code:
 nasm -v
in terminal , it's said :
Code:
NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on Aug  4 2012
So , i try to compile :

Code:
MacBook-Pro-de-Rebouh:Assembleur rebouhaymen$ nasm -f elf Ex_SousP_Pile.asm
MacBook-Pro-de-Rebouh:Assembleur rebouhaymen$ gcc -o Ex_SousP_Pile Ex_SousP_Pile.o -L. -lIUT -lncurses -lpanel
ld: warning: ld: warning: ignoring file ./libIUT.a, file was built for archive which is not the architecture being linked (x86_64): ./libIUT.aignoring file Ex_SousP_Pile.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 1 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): Ex_SousP_Pile.o

Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
MacBook-Pro-de-Rebouh:Assembleur rebouhaymen$
Can you help me ? Thanxs you so much ..
Bloupies is offline   0 Reply With Quote
Old Dec 25, 2012, 12:21 AM   #2
ytk
macrumors regular
 
Join Date: Jul 2010
Well, for starters, I have no idea what the contents of iut.inc or libIUT.a are, but it looks at least libIUT.a doesn't contain what you think it does. The magic number (0x7F 45 4C 46) reported is for an ELF executable, not an archive library (which should be 0xCAFEBABE for a universal file, or something like 0x21 3C 61 72 63 68 3E 0A for a single architecture file). To confirm, try running "file libIUT.a" and see what it reports. It should say "current ar archive random library".
ytk is offline   0 Reply With Quote
Old Dec 25, 2012, 02:47 PM   #3
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Mac OS X does not use the ELF format for its binaries. You need to use the macho format instead.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Dec 25, 2012, 09:02 PM   #4
ytk
macrumors regular
 
Join Date: Jul 2010
That's Mach-O, not macho. But a .a file shouldn't contain a binary executable anyway, regardless of the format. Since it's reporting that it's an ELF executable, you have a problem. It sounds like this libIUT.a file may have been compiled (incorrectly) on a Linux system?
ytk is offline   0 Reply With Quote
Old Dec 31, 2012, 04:02 PM   #5
subsonix
macrumors 68030
 
Join Date: Feb 2008
The correct output format flag for OS X in NASM is indeed macho. Apart from that, is the archive perhaps built on Linux? In that case you have to re-compile it for OS X.
subsonix 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
"Utter French!" : new French pronunciation app javamex iPhone and iPod touch Apps 4 Jul 30, 2014 11:18 AM
french site annonce that the graphic cards of the new mac pro are on daughter cards fhenry Mac Pro 15 Oct 27, 2013 10:46 AM
Can someone Upload the built-in French Dictionary in mac os x Aze300 OS X 3 Jan 9, 2013 05:02 PM

Forum Jump

All times are GMT -5. The time now is 01:37 AM.

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

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