Acharya
Acharya

Reputation: 148

Installing GNU Assembler in OSX

No matter how hard I google, I can't seem to find a (relatively) easy-to-follow instruction on how to install the GNU Assembler on a mac.

I know I can use gcc -c (Apple Clang on a Mac) to assemble .s / .S files, but I want to use actual GNU Binutils as.

Upvotes: 8

Views: 10600

Answers (4)

Arav K.
Arav K.

Reputation: 81

yasm works on Mac OSX (I got it from Homebrew), and it has a GNU as syntax parser which can be enabled with -p gas (it may be necessary to also add -r gas). It is not 100% complete, but it covers mostly everything. It can output to a variety of object formats (if cross-compiling is necessary), and in my opinion it's pretty cool. You can also use NASM syntax (which is completely supported) using -p nasm (again, -r nasm may be necessary).

Sorry about necroposting, but this is a still-relevant question and I believe that it needs an acceptable answer.

Upvotes: 4

Stephen Canon
Stephen Canon

Reputation: 106267

The gnu assembler is already installed on your mac (assuming that you installed the dev tools package). If you want to avoid XCode, you can invoke it from the command line with as, or with the preprocessor by using gcc yourfile.s $(OPTIONS).


Edit: as now points to the clang assembler; at the time this answer was written it pointed to (Apple's build of) the GNU assembler.

Upvotes: 0

imacake
imacake

Reputation: 1713

Maybe as instead of gas ? If you want to have gas as command invoke this: echo "alias gas=as" >> $HOME/.profile

It was installed on my Mac Lion when i opened the terminal and typed it. It might have been because of MacPorts and/or XCode as mentioned in the comments of a previous answer.

Upvotes: -2

Fabel
Fabel

Reputation: 1761

The GNU assembler cannot (yet) be used to create native object files (of Mach-O format). But you can of course use it to cross-assemble for some non-native object format, if that is what you want.

Upvotes: 3

Related Questions