Assembler

tanye

tanye

Mitglied
Thread Starter
Dabei seit
21.09.2011
Beiträge
67
Reaktionspunkte
0
Moin Zusammen,


Kennt sich jemand mit Assembler Programmierung unter Mac OS aus ? Ich hab' ne Weile unter Linux programmiert in Assembler bin es aber langsam leid weil ich denke, dass mein Mac das auch problemlos hinkriegen sollte ...
Angenommen nun ich hab folgendes Programm :

Code:
.data
    HelloWorldString:
    .ascii "Hello World\n"

.text

.globl _start

_start:
    # load all the arguments for write()
    movl $4, %eax
    movl $1, %ebx
    movl $HelloWorldString, %ecx
    movl $12, %edx
    # raises software interrupt to call write()
    int $0x80

    # call exit()
    movl $1, %eax
    movl $0, %ebx
    int $0x80

1.) Kompilieren via : as -o HelloWorld.o HelloWorld.s
2.) Linken via : ld -o HelloWorld HelloWorld.o
3.) Ausführen via : ./HelloWorld

Schon nach dem kompilieren krieg ich immer die gleiche Fehlermeldung :

ld: warning: -macosx_version_min not specified, assuming 10.7
Undefined symbols for architecture x86_64:
"start", referenced from:
-u command line option
(maybe you meant: _start)
ld: symbol(s) not found for inferred architecture x86_64

Ich hab auch schon in der man bezüglich Assembler unter Macintosh gelesen :

https://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/Assembler/010-Using_the_Assembler/using_asm.html#//apple_ref/doc/uid/TP30000820-TPXREF101

Bin daraus aber auch nicht schlauer geworden ...

Schönes WE noch, Tanye
 
steht doch eigentlich auch schon da:
du musst es start statt _start nennen, dann geht zumindest das linken.
dein code ist was anderes, "illegal instruction: 4" gibt der bei mir aus...
 
steht doch eigentlich auch schon da:
du musst es start statt _start nennen, dann geht zumindest das linken.
dein code ist was anderes, "illegal instruction: 4" gibt der bei mir aus...

Das funktioniert auch nicht, aber ich bekomm "ld: warning: -macosx_version_min not specified, assuming 10.7"

Ich mein ich hab ne AT&T Syntax, nicht einmal Intel.Und ein ganz simples Hello World Beispiel ... Ich seh keinen Fehler im Code, was bedeutet denn dass -mac_os_version_min not specified ist ?
 
das ist nur eine warning, die kannst du ignorieren oder setz die option halt.
-macosx_version_min version
This is set to indicate the oldest Mac OS X version that that
the output is to be used on. Specifying a later version
enables the linker to assumes features of that OS in the out-
put file. The format of version is a Mac OS X version number
such as 10.4 or 10.5

der fehler kommt ja auch beim ausführen, du kannst das binary ja starten trotz der warning.
 
das ist nur eine warning, die kannst du ignorieren oder setz die option halt.


der fehler kommt ja auch beim ausführen, du kannst das binary ja starten trotz der warning.

Das führt zu der gleichen Fehlermeldung, die du oben genannt hast. Illegal Instruction:4
 
Wenn ich das mit -arch i386 mache, hab ich kein Illegal Instruction:4

Code:
 xen@ radeon ~ 523
 $ as -arch i386 -o HelloWorldasm.o HelloWorldasm.asm 
 xen@ radeon ~ 524
 $ ld -o HelloWorldasm HelloWorldasm.o
ld: warning: -macosx_version_min not specificed, assuming 10.7
 xen@ radeon ~ 525
 $ ./HelloWorldasm 
 xen@ radeon ~ 526

Ob das besser ist, kann ich aber auch nicht sagen. Der Exitcode ist != 0, aber ich hab auch keine Ahnung von ASM.
 
Wenn ich das mit -arch i386 mache, hab ich kein Illegal Instruction:4

Code:
 xen@ radeon ~ 523
 $ as -arch i386 -o HelloWorldasm.o HelloWorldasm.asm 
 xen@ radeon ~ 524
 $ ld -o HelloWorldasm HelloWorldasm.o
ld: warning: -macosx_version_min not specificed, assuming 10.7
 xen@ radeon ~ 525
 $ ./HelloWorldasm 
 xen@ radeon ~ 526

Ob das besser ist, kann ich aber auch nicht sagen. Der Exitcode ist != 0, aber ich hab auch keine Ahnung von ASM.

Jop same problem here ... funktioniert noch immer nicht.
 
Hallo,

ich mache es mir leicht:

1) Die Warnung bekommst Du leicht weg, indem Du ld den Parameter
Code:
-macosx_version_min 10.7
mitgibst. (Oder 10.8, oder was Du da für richtig hälst)

2) BSD Assembly ist ein bisschen anders als Linux, und Mach-O ist anders als ELF. Ich empfehle Dir, da einfach mal in ein paar Tutorials reinzusehen:
http://michaux.ca/articles/assembly-hello-world-for-os-x

Gruss

Alex
 
Zurück
Oben Unten