Skip to content

Commit 0a283b6

Browse files
committed
Create README.md
1 parent 01adefb commit 0a283b6

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
I'm switching from [`nasm`](http://www.nasm.us/) to [`fasm`](http://flatassembler.net/), because the latter has
2+
a more expressive macro facility. The downside of `fasm` is that it doesn't support OSX. But, with some Google-fu and Makefile-fu,
3+
I have made it support OSX, with the same level of portability and convenience that I had previously achieved
4+
with `nasm`! (The key insights were found in [this forum thread](http://board.flatassembler.net/topic.php?t=13413).)
5+
6+
In order to use the Makefile here, you will need [`objconv`](http://www.agner.org/optimize/#objconv), and you will also
7+
need an already-working `fasm`. If you're on OSX, that might be quite difficult, so I'm including a working OSX
8+
`fasm` binary as a download in this repository.
9+
10+
Verify that you have these installed:
11+
12+
$ fasm
13+
flat assembler version 1.71.17
14+
usage: fasm <source> [output]
15+
$ objconv
16+
17+
Object file converter version 2.32 for x86 and x86-64 platforms.
18+
Copyright (c) 2013 by Agner Fog. Gnu General Public License.
19+
20+
Then, it's as simple as
21+
22+
```ShellSession
23+
$ git clone https://github.com/davidad/fasm_example_64.git
24+
Cloning into 'fasm_example_64'...
25+
remote: Counting objects: 13, done.
26+
remote: Compressing objects: 100% (10/10), done.
27+
remote: Total 13 (delta 3), reused 13 (delta 3)
28+
Unpacking objects: 100% (13/13), done.
29+
$ cd fasm_example_64
30+
$ make
31+
ln -s osx.inc syscalls.inc
32+
fasm hello64.asm hello64.o
33+
flat assembler version 1.71.17 (16384 kilobytes memory)
34+
2 passes, 467 bytes.
35+
objconv -fmacho -ar:start:_start -nu hello64.o hello64.mach.o
36+
37+
Input file: hello64.o, output file: hello64.mach.o
38+
Converting from ELF64 to Mach-O Little Endian64
39+
Adding leading underscores to symbol names
40+
41+
0 Debug sections removed
42+
0 Exception sections removed
43+
0 Changes in leading underscores on symbol names
44+
1 Symbol names changed
45+
1 Public symbol names aliased
46+
ld hello64.mach.o -o hello64.mach.exe
47+
ld: warning: -macosx_version_min not specified, assuming 10.6
48+
ln -f hello64.mach.exe hello64
49+
rm hello64.o hello64.mach.exe hello64.mach.o
50+
$ ./hello64
51+
Hello world!
52+
```

0 commit comments

Comments
 (0)