25 Commits

Author SHA1 Message Date
Ronald Caesar
2cc7f297c9 engine: intern constants
This does two things so I'll split them.

(1) Add function intern_constant() which adds a constant to the
constants array and returns the index.

The assembly for this function is beautiful. Only one load and store on
a successfull path.

Dump of assembler code for function intern_constant:
   0x0000000000010ee0 <+0>:     ldr     w8, [x4]
   0x0000000000010ee4 <+4>:     cbnz    w8, 0x10f08 <intern_constant+40>
   0x0000000000010ee8 <+8>:     ldrh    w8, [x2]
   0x0000000000010eec <+12>:    cmp     x3, x8
   0x0000000000010ef0 <+16>:    b.ls    0x10f10 <intern_constant+48>  // b.plast
   0x0000000000010ef4 <+20>:    str     w0, [x1, x8, lsl #2]
   0x0000000000010ef8 <+24>:    add     w9, w8, #0x1
   0x0000000000010efc <+28>:    orr     w0, w8, #0x10000
   0x0000000000010f00 <+32>:    strh    w9, [x2]
   0x0000000000010f04 <+36>:    ret
   0x0000000000010f08 <+40>:    mov     w0, #0x10000                    // #65536
   0x0000000000010f0c <+44>:    ret
   0x0000000000010f10 <+48>:    mov     w8, #0xffffff9c                 // #-100
   0x0000000000010f14 <+52>:    mov     w0, #0x10000                    // #65536
   0x0000000000010f18 <+56>:    str     w8, [x4]
   0x0000000000010f1c <+60>:    ret
End of assembler dump.

(2) I've decided that the entire translation code will fit in
bal_engine.c so the bal_ir_immiter and bal_translator files are not
needed anymore. I moved their preprocessor definitions into bal_engine.c

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-23 20:45:07 -04:00
Ronald Caesar
3274568415 build: release v0.4.0
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 19:14:58 -04:00
Ronald Caesar
98992b54c3 tests: replace fuzzer with exaustive test
Tests the entire 32-bit instruction space (4.29B).

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 05:24:17 -04:00
Ronald Caesar
6006b5e9e9 build: mark doc target as ALL_BUILD
Windows does not support the doc target, which causes the CI to fail.
Marking the doc target as ALL should fix this.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 23:23:22 -04:00
Ronald Caesar
15fc9028e7 github: add cmark dependancy to runners
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 21:45:02 -04:00
Ronald Caesar
3f78168ce5 tools: create a rustdoc like documentation generator
While I do not like the Rust Language as a whole, their documentation
generator is the best I've ever seen. in any language. I want to
implement something like it for Ballistic.

Like I said in the README, I have absolutely zero motivation to create
a documentation generator so `cdoc.c` is made completely with AI. The
code is messy but the generated HTML files look beautiful.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 20:23:12 -04:00
Ronald Caesar
de8e6e5a4d tools: add ballistic cli program
This program is used to test Ballistic engine's translation logic.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 23:28:28 -04:00
Ronald Caesar
3d02fab4b7 memory: add default allocator
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 19:45:44 -04:00
Ronald Caesar
1a1ce44c87 engine: add incomplete translator loop
Everything has been setup except for the main translation loop which
have to be done another day. Its after midnight for me right now :(

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 00:06:15 -04:00
Ronald Caesar
a214d8fcdb build: bump to v0.3.0
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-11 01:59:45 -04:00
Ronald Caesar
909d491535 build: add compiler variable length array warning
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-11 01:58:58 -04:00
Ronald Caesar
77d3e7f5cc tools: add coverage cli program
A simple program that prints to stdout the top 20 most common
instructions in an ARM64 binary file.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-11 01:51:53 -04:00
Ronald Caesar
46c19425cf engine: add engine init function
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-10 02:58:45 -04:00
Ronald Caesar
8eccc04fae Release v0.2.0
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:33:05 -04:00
Ronald Caesar
4aa8335612 decoder: Make decoder API public
The decoder API is now suitable to be made public. decoder.h is the sole
entry point for the decoder and it has been moved to `include/`

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:43 -04:00
Ronald Caesar
1dce881f33 build: Add generate_a64_table.py to cmake
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:41 -04:00
Ronald Caesar
c24f4f6e80 tests: Add decoder fuzzer
I realized that a fuzzer made in python is way slower than a fuzzer in
C. So here you go.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:40 -04:00
Ronald Caesar
99e91b4921 decoder/tools: Add decoder_cli program
This program takes a 32-bit hexidecimal representing an ARM instruction
and prints its corresponding mnemonic. This program will be used in
tandem with a python fuzzing script to verify the decoder table
generated by tools/generate_a64_table.py.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:39 -04:00
Ronald Caesar
c0b4f95010 build: Fix windows compiler warnings
Apperantly -Wall does exactly what it says it does on Windows and enables
every single warning. This is why the build fails on Windows and not on
Linux or MacOS.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:39 -04:00
Ronald Caesar
bd323a946e decoder/tests: Add small tests
This is just to test if the decoder even works. Ii will implement a
fuzzer to test the decoder against 10,000 randomly generated
instructions.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:38 -04:00
Ronald Caesar
0fee614994 decoder: Implement initial A64 instruction decoder
Adds a python script, tools/generate_a64_table.py, to parse ARM's
machine readable XML. The script generates a static C lookup table
containing instruction mnemonics, masks, and values.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:36 -04:00
Ronald Caesar
c0cbeb609d build: Disable cpu feature detection option
This will not be implemented any time soon so this might mislead
developers new to the project.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 15:49:08 -04:00
Xphalnos
c033264d26 Update CMakeLists.txt 2025-12-07 20:10:17 +01:00
Ronald Caesar
5f5cfe8d6c build: remove architecture detection
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 15:03:19 -04:00
Ronald Caesar
83d784e029 decoder: add arm decoder stub
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 14:56:46 -04:00