Skip to content

Commit 375b0c0

Browse files
Added library implementation for freebsd 32-bit, fixed examples building for freebsd 64-bit, updated STRUCTURE.md and Makefile files due to project structure changes, changed README.md and MACRO_USAGE.md
1 parent 2c27a1f commit 375b0c0

File tree

23 files changed

+293
-89
lines changed

23 files changed

+293
-89
lines changed

MACRO_USAGE.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ push reg1, reg2, reg3
5454
pop reg3, reg2, reg1
5555
```
5656

57+
**Note:**
58+
59+
Not available in the library for FreeBSD(32-bit).
60+
5761

5862
**Arguments:**</br>
5963
`regN` — actual registers to push or pop depending on the target architecture.
@@ -129,6 +133,10 @@ Returns an error code in the architecture-specific register.
129133
mkdir dir_name, permissions
130134
```
131135

136+
**Note:**
137+
138+
Not available in the library for FreeBSD(32-bit).
139+
132140

133141
**Arguments:**</br>
134142
`dir_name` — name of the directory to create, given as a string literal or a pointer to a string.</br>
@@ -152,6 +160,10 @@ Returns an error code in the architecture-specific register.
152160
rmdir dir_name
153161
```
154162

163+
**Note:**
164+
165+
Not available in the library for FreeBSD(32-bit).
166+
155167

156168
**Arguments:**</br>
157169
`dir_name` — name of the directory to remove, given as a string literal or a pointer to a string.
@@ -253,7 +265,7 @@ time
253265

254266
**Note:**
255267

256-
Not available in the library for DOS, Linux (ARM 32-bit and ARM 64-bit), and BSD.
268+
Not available in the library for DOS, Linux (ARM 32-bit and ARM 64-bit) and FreeBSD(32-bit and 64-bit).
257269

258270

259271

@@ -268,7 +280,7 @@ run command
268280

269281
**Note:**
270282

271-
Not available in the library for DOS and Linux (ARM 32-bit and ARM 64-bit).
283+
Not available in the library for DOS, Linux (ARM 32-bit and ARM 64-bit) and FreeBSD(32-bit).
272284

273285

274286
**Arguments:**</br>

Makefile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
DIRS_LINUX = examples_arm32 examples_arm64 examples_x64 examples_x86
2-
DIRS_BSD = examples_x64
2+
DIRS_FREEBSD = examples_x64 examples_x86
33
DIRS_DOS = examples_x16_com examples_x16_exe
44

55
ASM_LINUX_X64 = $(wildcard examples/Linux/examples_x64/*.asm)
66
ASM_LINUX_X86 = $(wildcard examples/Linux/examples_x86/*.asm)
77
ASM_LINUX_ARM32 = $(wildcard examples/Linux/examples_arm32/*.asm)
88
ASM_LINUX_ARM64 = $(wildcard examples/Linux/examples_arm64/*.asm)
9-
ASM_BSD_X64 = $(wildcard examples/BSD/examples_x64/*.asm)
9+
ASM_FREEBSD_X64 = $(wildcard examples/FreeBSD/examples_x64/*.asm)
10+
ASM_FREEBSD_X86 = $(wildcard examples/FreeBSD/examples_x86/*.asm)
1011
ASM_DOS_COM = $(wildcard examples/DOS/examples_x16_com/*.asm)
1112
ASM_DOS_EXE = $(wildcard examples/DOS/examples_x16_exe/*.asm)
1213

@@ -36,12 +37,17 @@ Linux:
3637
fasmarm $$src $$dst; \
3738
done
3839

39-
BSD:
40-
@for dir in $(DIRS_BSD); do \
41-
mkdir -p build/BSD/$$dir >/dev/null 2>&1; \
40+
FreeBSD:
41+
@for dir in $(DIRS_FREEBSD); do \
42+
mkdir -p build/FreeBSD/$$dir >/dev/null 2>&1; \
4243
done
43-
@for src in $(ASM_BSD_X64); do \
44-
dst=build/BSD/$${src#examples/BSD/}; \
44+
@for src in $(ASM_FREEBSD_X64); do \
45+
dst=build/FreeBSD/$${src#examples/FreeBSD/}; \
46+
dst=$${dst%.asm}; \
47+
fasm $$src $$dst; \
48+
done
49+
@for src in $(ASM_FREEBSD_X86); do \
50+
dst=build/FreeBSD/$${src#examples/FreeBSD/}; \
4551
dst=$${dst%.asm}; \
4652
fasm $$src $$dst; \
4753
done
@@ -61,7 +67,7 @@ DOS:
6167
fasm $$src $$dst; \
6268
done
6369

64-
all: Linux BSD DOS
70+
all: Linux FreeBSD DOS
6571

6672
clean:
6773
@rm -rf build

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
![Language](https://img.shields.io/badge/language%20-%20Assembly-red)
44
![CPU](https://img.shields.io/badge/CPU-x16%2C%20x86%2C%20x64%2C%20ARM32%2C%20ARM64-orange)
5-
![OS](https://img.shields.io/badge/OS-Linux%2C%20DOS%2C%20BSD-0078D4)
5+
![OS](https://img.shields.io/badge/OS-Linux%2C%20DOS%2C%20FreeBSD-0078D4)
66
![License](https://img.shields.io/github/license/lina-torovoltas/FasmMacrosLib)
77
![GitHub release](https://img.shields.io/github/v/release/lina-torovoltas/FasmMacrosLib)
88
![Downloads](https://img.shields.io/github/downloads/lina-torovoltas/FasmMacrosLib/total)</br>
99
FasmMacroLib is a macro library designed to simplify FASM programming upon Linux, DOS and BSD.</br>
10-
It supports x86, x64, ARM and ARM64 for Linux, x16 for DOS and x64 for BSD.
10+
It supports Linux (x86, x64, ARM, ARM64), DOS (x16), and FreeBSD (x86, x64).
1111

1212
## Installation
1313

@@ -19,17 +19,17 @@ include 'linux_x64.inc' ; for Linux x64
1919
include 'linux_arm32.inc' ; for Linux arm32
2020
include 'linux_arm64.inc' ; for Linux arm64
2121
include 'dos_x16.inc' ; for DOS x16
22-
include 'bsd_x64.inc' ; for BSD x64
22+
include 'freebsd_x86.inc' ; for FreeBSD x86
23+
include 'freebsd_x64.inc' ; for FreeBSD x64
2324
```
2425

2526
## Dependencies
2627

2728
- `make` utility for building
2829
- `fasm` assembler for x16, x86 and x64 targets
2930
- `fasmarm` assembler for ARM32 and ARM64 targets
30-
- `brandelf` utility for marking ELF binaries as BSD-compatible
3131

32-
Make sure both `make`, `fasm`, `fasmarm` and `brandelf` are installed and available in thy system PATH before building.
32+
Make sure both `make`, `fasm` and `fasmarm` are installed and available in thy system PATH before building.
3333

3434
## Usage
3535

@@ -52,12 +52,6 @@ cd FasmMacroLib
5252
make all
5353
```
5454

55-
### Note:
56-
To make the binaries work upon BSD, thou must mark them using brandelf:
57-
```bash
58-
brandelf -t FreeBSD path/to/binary
59-
```
60-
6155
## Contributing
6256

6357
Contributions are welcome!</br>

STRUCTURE.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,53 @@
99
├── README.md
1010
├── STRUCTURE.md
1111
├── macrolib
12-
│ ├── BSD
13-
│ │ └── bsd_x64.inc
1412
│ ├── DOS
1513
│ │ └── dos_x16.inc
14+
│ ├── FreeBSD
15+
│ │ ├── freebsd_x64.inc
16+
│ │ └── freebsd_x86.inc
1617
│ └── Linux
1718
│ ├── linux_arm32.inc
1819
│ ├── linux_arm64.inc
1920
│ ├── linux_x64.inc
2021
│ └── linux_x86.inc
2122
└── examples
22-
├── BSD
23-
│ └── examples_x64
23+
├── DOS
24+
│ ├── examples_x16_com
25+
│ │ ├── clear.asm
26+
│ │ ├── exit.asm
27+
│ │ ├── make_dir.asm
28+
│ │ ├── print.asm
29+
│ │ ├── print_number.asm
30+
│ │ ├── print_times.asm
31+
│ │ ├── remove_dir.asm
32+
│ │ └── stackops.asm
33+
│ └── examples_x16_exe
2434
│ ├── clear.asm
2535
│ ├── exit.asm
2636
│ ├── make_dir.asm
2737
│ ├── print.asm
2838
│ ├── print_number.asm
2939
│ ├── print_times.asm
3040
│ ├── remove_dir.asm
31-
│ ├── run_command.asm
3241
│ └── stackops.asm
33-
├── DOS
34-
│ ├── examples_x16_com
42+
├── FreeBSD
43+
│ ├── examples_x64
3544
│ │ ├── clear.asm
3645
│ │ ├── exit.asm
3746
│ │ ├── make_dir.asm
3847
│ │ ├── print.asm
3948
│ │ ├── print_number.asm
4049
│ │ ├── print_times.asm
4150
│ │ ├── remove_dir.asm
51+
│ │ ├── run_command.asm
4252
│ │ └── stackops.asm
43-
│ └── examples_x16_exe
53+
│ └── examples_x86
4454
│ ├── clear.asm
4555
│ ├── exit.asm
46-
│ ├── make_dir.asm
4756
│ ├── print.asm
4857
│ ├── print_number.asm
49-
│ ├── print_times.asm
50-
│ ├── remove_dir.asm
51-
│ └── stackops.asm
58+
│ └── print_times.asm
5259
└── Linux
5360
├── examples_arm32
5461
│ ├── clear.asm

examples/BSD/examples_x64/clear.asm

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/BSD/examples_x64/exit.asm

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/BSD/examples_x64/run_command.asm

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; This code works only on 64-bit FreeBSD!!!
2+
3+
format ELF64 executable 9
4+
include '../../../macrolib/FreeBSD/freebsd_x64.inc'
5+
entry start
6+
7+
8+
9+
segment readable executable
10+
11+
start:
12+
clr rax, rdi
13+
mov rax, 1
14+
syscall
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; This code works only on 64-bit FreeBSD!!!
2+
3+
format ELF64 executable 9
4+
include '../../../macrolib/FreeBSD/freebsd_x64.inc'
5+
entry start
6+
7+
8+
9+
segment readable executable
10+
11+
start:
12+
exit 0

examples/BSD/examples_x64/make_dir.asm renamed to examples/FreeBSD/examples_x64/make_dir.asm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
; This code works only on 64-bit BSD!!!
1+
; This code works only on 64-bit FreeBSD!!!
22

3-
format ELF64 executable 3
4-
include '../../../macrolib/BSD/bsd_x64.inc'
3+
format ELF64 executable 9
4+
include '../../../macrolib/FreeBSD/freebsd_x64.inc'
55
entry start
66

77

0 commit comments

Comments
 (0)