├── fasm
├── objconv
├── fasm_new_32.o
├── fasm_new_32_m.o
├── fasm_src
├── fasm.o
├── examples
│ └── libcdemo
│ │ ├── libcdemo.o
│ │ ├── ccall.inc
│ │ └── libcdemo.asm
├── readme.txt
├── tools
│ ├── libc
│ │ ├── ccall.inc
│ │ ├── prepsrc.asm
│ │ ├── symbols.asm
│ │ ├── system.inc
│ │ └── listing.asm
│ ├── readme.txt
│ ├── win32
│ │ ├── system.inc
│ │ ├── prepsrc.asm
│ │ ├── symbols.asm
│ │ └── listing.asm
│ ├── dos
│ │ ├── loader.inc
│ │ ├── prepsrc.asm
│ │ ├── symbols.asm
│ │ ├── system.inc
│ │ └── listing.asm
│ ├── prepsrc.inc
│ └── symbols.inc
├── license.txt
└── source
│ ├── version.inc
│ ├── DOS
│ ├── dpmi.inc
│ ├── fasm.asm
│ └── system.inc
│ ├── messages.inc
│ ├── variable.inc
│ ├── Linux
│ ├── x64
│ │ ├── modes.inc
│ │ ├── fasm.asm
│ │ └── system.inc
│ ├── fasm.asm
│ └── system.inc
│ ├── errors.inc
│ ├── libc
│ ├── fasm.asm
│ └── system.inc
│ ├── Win32
│ ├── fasm.asm
│ └── system.inc
│ └── symbdump.inc
├── objconv_src
├── extras.zip
├── objconv.exe
├── source.zip
├── source
│ ├── macho.h
│ ├── stdafx.cpp
│ ├── build.sh
│ ├── stdafx.h
│ ├── error.h
│ ├── maindef.h
│ ├── library.h
│ └── objconv.vcproj
├── objconv-instructions.pdf
└── changelog.txt
├── README
├── hello32.asm
├── hello64.asm
└── USAGE
/fasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/fasm
--------------------------------------------------------------------------------
/objconv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/objconv
--------------------------------------------------------------------------------
/fasm_new_32.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/fasm_new_32.o
--------------------------------------------------------------------------------
/fasm_new_32_m.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/fasm_new_32_m.o
--------------------------------------------------------------------------------
/fasm_src/fasm.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/fasm_src/fasm.o
--------------------------------------------------------------------------------
/objconv_src/extras.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/objconv_src/extras.zip
--------------------------------------------------------------------------------
/objconv_src/objconv.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/objconv_src/objconv.exe
--------------------------------------------------------------------------------
/objconv_src/source.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/objconv_src/source.zip
--------------------------------------------------------------------------------
/objconv_src/source/macho.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/objconv_src/source/macho.h
--------------------------------------------------------------------------------
/objconv_src/objconv-instructions.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/objconv_src/objconv-instructions.pdf
--------------------------------------------------------------------------------
/fasm_src/examples/libcdemo/libcdemo.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohnDDuncanIII/fasm/HEAD/fasm_src/examples/libcdemo/libcdemo.o
--------------------------------------------------------------------------------
/objconv_src/source/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // objconv.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
--------------------------------------------------------------------------------
/fasm_src/readme.txt:
--------------------------------------------------------------------------------
1 |
2 | The fasm.o is an object file in ELF format. To get the final executable for
3 | your system, you need to use the appropriate tool to link it with the C
4 | library available on your platform. With the GNU tools it is enough to use
5 | this command:
6 |
7 | gcc fasm.o -o fasm
8 |
--------------------------------------------------------------------------------
/fasm_src/examples/libcdemo/ccall.inc:
--------------------------------------------------------------------------------
1 |
2 | macro ccall proc,[arg]
3 | { common
4 | local size
5 | size = 0
6 | mov ebp,esp
7 | if ~ arg eq
8 | forward
9 | size = size + 4
10 | common
11 | sub esp,size
12 | end if
13 | and esp,-16
14 | if ~ arg eq
15 | add esp,size
16 | reverse
17 | pushd arg
18 | common
19 | end if
20 | call proc
21 | mov esp,ebp }
22 |
23 |
--------------------------------------------------------------------------------
/fasm_src/tools/libc/ccall.inc:
--------------------------------------------------------------------------------
1 |
2 | macro ccall proc,[arg]
3 | { common
4 | push ebp
5 | mov ebp,esp
6 | local size
7 | size = 0
8 | if ~ arg eq
9 | forward
10 | size = size + 4
11 | common
12 | sub esp,size
13 | end if
14 | and esp,-16
15 | if ~ arg eq
16 | add esp,size
17 | reverse
18 | pushd arg
19 | common
20 | end if
21 | call proc
22 | leave }
23 |
24 |
--------------------------------------------------------------------------------
/objconv_src/source/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build script for building objconv on Linux, BSD and Mac OS X platforms.
4 |
5 | # Instructions:
6 |
7 | # You may need to change the path to bash above as required by your system
8 |
9 | # Make sure the current directory contains all the .cpp files for objconv,
10 | # and only one copy of each, and no other .cpp files
11 |
12 | # Then run ./build.sh
13 | # The compilation may take half a minute.
14 |
15 | # Alternatively, run the following line:
16 |
17 | g++ -o objconv -O2 *.cpp
18 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | # fasm-osx
2 | flat assembler - the open source assembly language compiler for x86 and x86-64 processors
3 |
4 | This repository contains a flat assembler version that will run on Macintosh OS X 10.6-10.11.
5 |
6 | the fasm version included in this repository (1.71.51) has succesfully assembled the 64-bit `rwasa' web-server fomr the [HeavyThing library](https://2ton.com.au/HeavyThing/) on OS X 10.11 El-Capitan.
7 |
8 | # Inspired/taken from:
9 | http://board.flatassembler.net/topic.php?t=13413
10 | http://board.flatassembler.net/topic.php?t=9954
--------------------------------------------------------------------------------
/fasm_src/examples/libcdemo/libcdemo.asm:
--------------------------------------------------------------------------------
1 |
2 | ; fasm example of using the C library in Unix systems
3 |
4 | ; compile the source with commands like:
5 | ; fasm libcdemo.asm libcdemo.o
6 | ; gcc libcdemo.o -o libcdemo
7 | ; strip libcdemo
8 |
9 | format ELF
10 |
11 | include 'ccall.inc'
12 |
13 | section '.text' executable
14 |
15 | public main
16 | extrn printf
17 | extrn getpid
18 |
19 | main:
20 | call getpid
21 | ccall printf, msg,eax
22 | ret
23 |
24 | section '.data' writeable
25 |
26 | msg db "Current process ID is %d.",0xA,0
27 |
--------------------------------------------------------------------------------
/hello32.asm:
--------------------------------------------------------------------------------
1 | format ELF
2 | section '.text' executable
3 | public main
4 | extrn printf
5 | extrn exit
6 | struc db [data]
7 | {
8 | common
9 | . db data
10 | .size = $ - .
11 | }
12 |
13 | main:
14 | push ebp
15 | mov ebp, esp
16 | push ebx
17 | mov ebx, esp
18 | and esp, 0xfffffff0
19 | sub esp, 12
20 | push ebx
21 | add esp, 16
22 |
23 | mov dword [esp], msgHelloWorld
24 | call printf
25 |
26 | sub esp, 16
27 | pop ebx
28 | mov esp, ebx
29 | pop ebx
30 | mov esp, ebp
31 | pop ebp
32 | mov eax, 0
33 | ret
34 | section '.data' writeable
35 | msgHelloWorld db 'Hello world from FASM!',0xA,0
--------------------------------------------------------------------------------
/hello64.asm:
--------------------------------------------------------------------------------
1 | format ELF64
2 |
3 | section '.text' executable
4 | public main
5 | extrn printf
6 | extrn exit
7 |
8 | ;macro for create .size constant automatically
9 | struc db [data]{
10 | common
11 | . db data
12 | .size = $ - .
13 | }
14 |
15 | ;testing using syscall
16 |
17 | main:
18 | mov rax, 0x2000004 ; sys_write
19 | mov rdi, 1 ; stdout
20 | mov rsi, qword msgHelloWorld ; string
21 | mov rdx, msgHelloWorld.size ; length
22 | syscall
23 | mov rax, 0x2000001 ; sys_exit
24 | xor rdi, rdi ; exit code
25 | syscall
26 |
27 |
28 | section '.data' writeable
29 | msgHelloWorld db 'Hello 64bit World from FASM!',0x0A,0
30 |
--------------------------------------------------------------------------------
/USAGE:
--------------------------------------------------------------------------------
1 | COMPILE OSX 32bits "Hello World"
2 | --------------------------------
3 |
4 | ./fasm hello32.asm hello32.o
5 | ./objconv -fmacho32 -nu hello32.o hello32_m.o
6 | ld -arch i386 -macosx_version_min 10.6 -o hello32 hello32_m.o /usr/lib/crt1.o /usr/lib/libc.dylib
7 | file hello32
8 | ./hello32
9 |
10 | COMPILE OSX 64bits "Hello World"
11 | --------------------------------
12 |
13 | ./fasm hello64.asm hello64.o
14 | ./objconv -fmacho64 -nu hello64.o hello64_m.o
15 | ld -arch x86_64 -macosx_version_min 10.6 -o hello64 hello64_m.o /usr/lib/crt1.o /usr/lib/libc.dylib
16 | file hello64
17 | ./hello64
18 |
19 | COMPILE fasm
20 | --------------------------------
21 | ./fasm fasm_src/source/libc/fasm.asm fasm_new_32.o
22 | ./objconv -fmac -nu fasm_new_32.o fasm_new_32_m.o
23 | ld -arch i386 -macosx_version_min 10.6 -o fasm_32_new fasm_new_32_m.o /usr/lib/crt1.o /usr/lib/libc.dylib
24 | file fasm
25 | ./fasm
26 |
--------------------------------------------------------------------------------
/fasm_src/tools/readme.txt:
--------------------------------------------------------------------------------
1 |
2 | This directory contains some tools, which extract various types of information
3 | from the symbolic information file generated by flat assembler, and present
4 | them in a human-readable form.
5 |
6 | The listing tool creates a listing of assembled code - this tool needs to be
7 | executed in the exact configuration, in which the assembly was taking place.
8 | All the source files and the output file aswell must not have been moved or
9 | modified - if any of them was altered before generating the listing, it is
10 | going to contain garbage instead of useful information. For example, if you
11 | assembled the file with the command like:
12 |
13 | fasm example.asm example.exe -s example.fas
14 |
15 | you should generate listing by immediately running this command from the same
16 | directory:
17 |
18 | listing example.fas example.lst
19 |
20 | In addition, the "-a" switch is recommended to use in the case of executable
21 | formats, as it allows to get the run-time addresses for all the assembled code
22 | and data.
23 |
24 | The preprocessed source and symbols dump tools are simpler ones - they only
25 | need the symbolic information file as input and generate proper output text
26 | regardless of the availability of other files.
27 |
--------------------------------------------------------------------------------
/fasm_src/tools/win32/system.inc:
--------------------------------------------------------------------------------
1 |
2 | display_string:
3 | invoke GetStdHandle,[display_handle]
4 | mov edx,eax
5 | mov edi,esi
6 | or ecx,-1
7 | xor al,al
8 | repne scasb
9 | neg ecx
10 | sub ecx,2
11 | invoke WriteFile,edx,esi,ecx,bytes_count,0
12 | retn
13 | alloc:
14 | invoke VirtualAlloc,0,eax,MEM_COMMIT,PAGE_READWRITE
15 | or eax,eax
16 | jz allocation_error
17 | clc
18 | retn
19 | allocation_error:
20 | stc
21 | retn
22 | free:
23 | invoke VirtualFree,eax,0,MEM_RELEASE
24 | retn
25 | open:
26 | invoke CreateFile,edx,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0
27 | cmp eax,-1
28 | je file_error
29 | mov ebx,eax
30 | clc
31 | retn
32 | file_error:
33 | stc
34 | retn
35 | create:
36 | invoke CreateFile,edx,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0
37 | cmp eax,-1
38 | je file_error
39 | mov ebx,eax
40 | clc
41 | retn
42 | write:
43 | invoke WriteFile,ebx,edx,ecx,bytes_count,0
44 | or eax,eax
45 | jz file_error
46 | clc
47 | retn
48 | read:
49 | push ecx
50 | invoke ReadFile,ebx,edx,ecx,bytes_count,0
51 | pop edx
52 | or eax,eax
53 | jz file_error
54 | cmp edx,[bytes_count]
55 | jne file_error
56 | clc
57 | retn
58 | close:
59 | invoke CloseHandle,ebx
60 | retn
61 | lseek:
62 | movzx eax,al
63 | invoke SetFilePointer,ebx,edx,0,eax
64 | cmp eax,-1
65 | je file_error
66 | retn
67 |
--------------------------------------------------------------------------------
/fasm_src/tools/libc/prepsrc.asm:
--------------------------------------------------------------------------------
1 |
2 | format ELF
3 | public main
4 |
5 | include 'ccall.inc'
6 |
7 | section '.text' executable align 16
8 |
9 | main:
10 | mov ecx,[esp+4]
11 | mov [argc],ecx
12 | mov ebx,[esp+8]
13 | mov [argv],ebx
14 |
15 | mov [display_handle],1
16 |
17 | call get_params
18 | jnc make_dump
19 |
20 | mov esi,_usage
21 | call display_string
22 | ccall exit,2
23 |
24 | make_dump:
25 | call preprocessed_source
26 | ccall exit,0
27 |
28 | error:
29 | mov [display_handle],2
30 | mov esi,_error_prefix
31 | call display_string
32 | pop esi
33 | call display_string
34 | mov esi,_error_suffix
35 | call display_string
36 | ccall exit,0
37 |
38 | get_params:
39 | mov ecx,[argc]
40 | mov ebx,[argv]
41 | add ebx,4
42 | dec ecx
43 | jz bad_params
44 | get_param:
45 | mov esi,[ebx]
46 | mov al,[esi]
47 | cmp [input_file],0
48 | jne get_output_file
49 | mov [input_file],esi
50 | jmp next_param
51 | get_output_file:
52 | cmp [output_file],0
53 | jne bad_params
54 | mov [output_file],esi
55 | jmp next_param
56 | bad_params:
57 | stc
58 | ret
59 | next_param:
60 | add ebx,4
61 | dec ecx
62 | jnz get_param
63 | cmp [input_file],0
64 | je bad_params
65 | cmp [output_file],0
66 | je bad_params
67 | clc
68 | ret
69 |
70 | include 'system.inc'
71 |
72 | include '..\prepsrc.inc'
73 |
74 | section '.data' writeable align 4
75 |
76 | input_file dd 0
77 | output_file dd 0
78 |
79 | _usage db 'preprocessed source dumper for flat assembler',0Dh,0Ah
80 | db 'usage: prepsrc