diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..ddcfdad
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1,2 @@
+_bin/
+_out/
\ No newline at end of file
diff --git a/tests/empty/expected/output-alf_104.alf b/tests/empty/expected/output-alf_104.alf
new file mode 100644
index 0000000..a5968e4
Binary files /dev/null and b/tests/empty/expected/output-alf_104.alf differ
diff --git a/tests/empty/expected/output-alf_105.alf b/tests/empty/expected/output-alf_105.alf
new file mode 100644
index 0000000..b759b38
Binary files /dev/null and b/tests/empty/expected/output-alf_105.alf differ
diff --git a/tests/empty/expected/output-ar.txt b/tests/empty/expected/output-ar.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/empty/expected/output-code.bin b/tests/empty/expected/output-code.bin
new file mode 100644
index 0000000..e69de29
diff --git a/tests/empty/expected/output-dolphin.ini b/tests/empty/expected/output-dolphin.ini
new file mode 100644
index 0000000..e69de29
diff --git a/tests/empty/expected/output-gecko.txt b/tests/empty/expected/output-gecko.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/empty/expected/output-kamek.Base.bin b/tests/empty/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..79fc9e2
Binary files /dev/null and b/tests/empty/expected/output-kamek.Base.bin differ
diff --git a/tests/empty/expected/output-kamek.V2.bin b/tests/empty/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..79fc9e2
Binary files /dev/null and b/tests/empty/expected/output-kamek.V2.bin differ
diff --git a/tests/empty/expected/output-map-dynamic.map b/tests/empty/expected/output-map-dynamic.map
new file mode 100644
index 0000000..c922538
--- /dev/null
+++ b/tests/empty/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 __ctor_loc
+ 00000000 000000 __ctor_end
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000000 000000 _e_text
+ 00000000 000000 _f_ctors
+ 00000000 000000 _e_ctors
+ 00000000 000000 _f_dtors
+ 00000000 000000 _e_dtors
+ 00000000 000000 _f_rodata
+ 00000000 000000 _e_rodata
+ 00000000 000000 _f_data
+ 00000000 000000 _e_data
diff --git a/tests/empty/expected/output-map-static.map b/tests/empty/expected/output-map-static.map
new file mode 100644
index 0000000..931fd5b
--- /dev/null
+++ b/tests/empty/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 __ctor_loc
+ 82000000 000000 __ctor_end
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000000 000000 _e_text
+ 82000000 000000 _f_ctors
+ 82000000 000000 _e_ctors
+ 82000000 000000 _f_dtors
+ 82000000 000000 _e_dtors
+ 82000000 000000 _f_rodata
+ 82000000 000000 _e_rodata
+ 82000000 000000 _f_data
+ 82000000 000000 _e_data
diff --git a/tests/empty/expected/output-riiv.xml b/tests/empty/expected/output-riiv.xml
new file mode 100644
index 0000000..e69de29
diff --git a/tests/empty/test.cpp b/tests/empty/test.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/tests/kamek_b_bl/expected/output-alf_104.alf b/tests/kamek_b_bl/expected/output-alf_104.alf
new file mode 100644
index 0000000..d8be8e2
Binary files /dev/null and b/tests/kamek_b_bl/expected/output-alf_104.alf differ
diff --git a/tests/kamek_b_bl/expected/output-alf_105.alf b/tests/kamek_b_bl/expected/output-alf_105.alf
new file mode 100644
index 0000000..318d021
Binary files /dev/null and b/tests/kamek_b_bl/expected/output-alf_105.alf differ
diff --git a/tests/kamek_b_bl/expected/output-ar.txt b/tests/kamek_b_bl/expected/output-ar.txt
new file mode 100644
index 0000000..b2598c5
--- /dev/null
+++ b/tests/kamek_b_bl/expected/output-ar.txt
@@ -0,0 +1,2 @@
+04000000 4B000000
+04000004 4AFFFFFD
\ No newline at end of file
diff --git a/tests/kamek_b_bl/expected/output-code.bin b/tests/kamek_b_bl/expected/output-code.bin
new file mode 100644
index 0000000..7e7bad9
Binary files /dev/null and b/tests/kamek_b_bl/expected/output-code.bin differ
diff --git a/tests/kamek_b_bl/expected/output-dolphin.ini b/tests/kamek_b_bl/expected/output-dolphin.ini
new file mode 100644
index 0000000..d4c5aa1
--- /dev/null
+++ b/tests/kamek_b_bl/expected/output-dolphin.ini
@@ -0,0 +1,2 @@
+0x82000000:dword:0x4B000000
+0x82000004:dword:0x4AFFFFFD
\ No newline at end of file
diff --git a/tests/kamek_b_bl/expected/output-gecko.txt b/tests/kamek_b_bl/expected/output-gecko.txt
new file mode 100644
index 0000000..f6e084f
--- /dev/null
+++ b/tests/kamek_b_bl/expected/output-gecko.txt
@@ -0,0 +1,2 @@
+06000000 00000008
+4B000000 4AFFFFFD
\ No newline at end of file
diff --git a/tests/kamek_b_bl/expected/output-kamek.Base.bin b/tests/kamek_b_bl/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..5bbfda3
Binary files /dev/null and b/tests/kamek_b_bl/expected/output-kamek.Base.bin differ
diff --git a/tests/kamek_b_bl/expected/output-kamek.V2.bin b/tests/kamek_b_bl/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..cf7f192
Binary files /dev/null and b/tests/kamek_b_bl/expected/output-kamek.V2.bin differ
diff --git a/tests/kamek_b_bl/expected/output-map-dynamic.map b/tests/kamek_b_bl/expected/output-map-dynamic.map
new file mode 100644
index 0000000..e4619f4
--- /dev/null
+++ b/tests/kamek_b_bl/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000008 000000 __ctor_loc
+ 00000008 000000 __ctor_end
+ 00000008 000000 _e_text
+ 00000008 000000 _f_ctors
+ 00000008 000000 _e_ctors
+ 00000008 000000 _f_dtors
+ 00000008 000000 _e_dtors
+ 00000008 000000 _f_rodata
+ 00000008 000000 _e_rodata
+ 00000008 000000 _f_data
+ 00000008 000000 _e_data
diff --git a/tests/kamek_b_bl/expected/output-map-static.map b/tests/kamek_b_bl/expected/output-map-static.map
new file mode 100644
index 0000000..c7e480c
--- /dev/null
+++ b/tests/kamek_b_bl/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000008 000000 __ctor_loc
+ 82000008 000000 __ctor_end
+ 82000008 000000 _e_text
+ 82000008 000000 _f_ctors
+ 82000008 000000 _e_ctors
+ 82000008 000000 _f_dtors
+ 82000008 000000 _e_dtors
+ 82000008 000000 _f_rodata
+ 82000008 000000 _e_rodata
+ 82000008 000000 _f_data
+ 82000008 000000 _e_data
diff --git a/tests/kamek_b_bl/expected/output-riiv.xml b/tests/kamek_b_bl/expected/output-riiv.xml
new file mode 100644
index 0000000..8e2696d
--- /dev/null
+++ b/tests/kamek_b_bl/expected/output-riiv.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/kamek_b_bl/test.S b/tests/kamek_b_bl/test.S
new file mode 100644
index 0000000..842d242
--- /dev/null
+++ b/tests/kamek_b_bl/test.S
@@ -0,0 +1,5 @@
+#include
+
+func:
+ kamek_b 0x81000000
+ kamek_bl 0x81000000
diff --git a/tests/kamek_const_float/expected/output-alf_104.alf b/tests/kamek_const_float/expected/output-alf_104.alf
new file mode 100644
index 0000000..34b7b2d
Binary files /dev/null and b/tests/kamek_const_float/expected/output-alf_104.alf differ
diff --git a/tests/kamek_const_float/expected/output-alf_105.alf b/tests/kamek_const_float/expected/output-alf_105.alf
new file mode 100644
index 0000000..6df8d14
Binary files /dev/null and b/tests/kamek_const_float/expected/output-alf_105.alf differ
diff --git a/tests/kamek_const_float/expected/output-ar.txt b/tests/kamek_const_float/expected/output-ar.txt
new file mode 100644
index 0000000..8b670f4
--- /dev/null
+++ b/tests/kamek_const_float/expected/output-ar.txt
@@ -0,0 +1,3 @@
+04000000 3C608200
+04000004 C0230008
+04000008 3F99999A
\ No newline at end of file
diff --git a/tests/kamek_const_float/expected/output-code.bin b/tests/kamek_const_float/expected/output-code.bin
new file mode 100644
index 0000000..340ee19
Binary files /dev/null and b/tests/kamek_const_float/expected/output-code.bin differ
diff --git a/tests/kamek_const_float/expected/output-dolphin.ini b/tests/kamek_const_float/expected/output-dolphin.ini
new file mode 100644
index 0000000..8ecb428
--- /dev/null
+++ b/tests/kamek_const_float/expected/output-dolphin.ini
@@ -0,0 +1,3 @@
+0x82000000:dword:0x3C608200
+0x82000004:dword:0xC0230008
+0x82000008:dword:0x3F99999A
\ No newline at end of file
diff --git a/tests/kamek_const_float/expected/output-gecko.txt b/tests/kamek_const_float/expected/output-gecko.txt
new file mode 100644
index 0000000..9db46da
--- /dev/null
+++ b/tests/kamek_const_float/expected/output-gecko.txt
@@ -0,0 +1,3 @@
+06000000 00000010
+3C608200 C0230008
+3F99999A 00000000
\ No newline at end of file
diff --git a/tests/kamek_const_float/expected/output-kamek.Base.bin b/tests/kamek_const_float/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..0abdbad
Binary files /dev/null and b/tests/kamek_const_float/expected/output-kamek.Base.bin differ
diff --git a/tests/kamek_const_float/expected/output-kamek.V2.bin b/tests/kamek_const_float/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..0abdbad
Binary files /dev/null and b/tests/kamek_const_float/expected/output-kamek.V2.bin differ
diff --git a/tests/kamek_const_float/expected/output-map-dynamic.map b/tests/kamek_const_float/expected/output-map-dynamic.map
new file mode 100644
index 0000000..2eb2bde
--- /dev/null
+++ b/tests/kamek_const_float/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000008 000000 __ctor_loc
+ 00000008 000000 __ctor_end
+ 00000008 000000 _e_text
+ 00000008 000000 _f_ctors
+ 00000008 000000 _e_ctors
+ 00000008 000000 _f_dtors
+ 00000008 000000 _e_dtors
+ 00000008 000000 _f_rodata
+ 00000008 000000 _e_rodata
+ 00000008 000000 _f_data
+ 0000000C 000000 _e_data
diff --git a/tests/kamek_const_float/expected/output-map-static.map b/tests/kamek_const_float/expected/output-map-static.map
new file mode 100644
index 0000000..b315f51
--- /dev/null
+++ b/tests/kamek_const_float/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000008 000000 __ctor_loc
+ 82000008 000000 __ctor_end
+ 82000008 000000 _e_text
+ 82000008 000000 _f_ctors
+ 82000008 000000 _e_ctors
+ 82000008 000000 _f_dtors
+ 82000008 000000 _e_dtors
+ 82000008 000000 _f_rodata
+ 82000008 000000 _e_rodata
+ 82000008 000000 _f_data
+ 8200000C 000000 _e_data
diff --git a/tests/kamek_const_float/expected/output-riiv.xml b/tests/kamek_const_float/expected/output-riiv.xml
new file mode 100644
index 0000000..a4ac769
--- /dev/null
+++ b/tests/kamek_const_float/expected/output-riiv.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/kamek_const_float/test.S b/tests/kamek_const_float/test.S
new file mode 100644
index 0000000..e2b6e0c
--- /dev/null
+++ b/tests/kamek_const_float/test.S
@@ -0,0 +1,4 @@
+#include
+
+func:
+ kamek_const_float f1, 1.2, r3
diff --git a/tests/kamek_ref/expected/output-alf_104.alf b/tests/kamek_ref/expected/output-alf_104.alf
new file mode 100644
index 0000000..ce263b3
Binary files /dev/null and b/tests/kamek_ref/expected/output-alf_104.alf differ
diff --git a/tests/kamek_ref/expected/output-alf_105.alf b/tests/kamek_ref/expected/output-alf_105.alf
new file mode 100644
index 0000000..6fc5baf
Binary files /dev/null and b/tests/kamek_ref/expected/output-alf_105.alf differ
diff --git a/tests/kamek_ref/expected/output-ar.txt b/tests/kamek_ref/expected/output-ar.txt
new file mode 100644
index 0000000..e26d688
--- /dev/null
+++ b/tests/kamek_ref/expected/output-ar.txt
@@ -0,0 +1,12 @@
+04000000 3C608100
+04000004 80630000
+04000008 3C808100
+0400000C 80640004
+04000010 3CA08100
+04000014 98A50008
+04000018 3CC08100
+0400001C 98A6000C
+04000020 3C608100
+04000024 C0230010
+04000028 3C608100
+0400002C D0230014
\ No newline at end of file
diff --git a/tests/kamek_ref/expected/output-code.bin b/tests/kamek_ref/expected/output-code.bin
new file mode 100644
index 0000000..8cb603d
Binary files /dev/null and b/tests/kamek_ref/expected/output-code.bin differ
diff --git a/tests/kamek_ref/expected/output-dolphin.ini b/tests/kamek_ref/expected/output-dolphin.ini
new file mode 100644
index 0000000..e568077
--- /dev/null
+++ b/tests/kamek_ref/expected/output-dolphin.ini
@@ -0,0 +1,12 @@
+0x82000000:dword:0x3C608100
+0x82000004:dword:0x80630000
+0x82000008:dword:0x3C808100
+0x8200000C:dword:0x80640004
+0x82000010:dword:0x3CA08100
+0x82000014:dword:0x98A50008
+0x82000018:dword:0x3CC08100
+0x8200001C:dword:0x98A6000C
+0x82000020:dword:0x3C608100
+0x82000024:dword:0xC0230010
+0x82000028:dword:0x3C608100
+0x8200002C:dword:0xD0230014
\ No newline at end of file
diff --git a/tests/kamek_ref/expected/output-gecko.txt b/tests/kamek_ref/expected/output-gecko.txt
new file mode 100644
index 0000000..4148ab5
--- /dev/null
+++ b/tests/kamek_ref/expected/output-gecko.txt
@@ -0,0 +1,7 @@
+06000000 00000030
+3C608100 80630000
+3C808100 80640004
+3CA08100 98A50008
+3CC08100 98A6000C
+3C608100 C0230010
+3C608100 D0230014
\ No newline at end of file
diff --git a/tests/kamek_ref/expected/output-kamek.Base.bin b/tests/kamek_ref/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..aa6e4a4
Binary files /dev/null and b/tests/kamek_ref/expected/output-kamek.Base.bin differ
diff --git a/tests/kamek_ref/expected/output-kamek.V2.bin b/tests/kamek_ref/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..5f5175a
Binary files /dev/null and b/tests/kamek_ref/expected/output-kamek.V2.bin differ
diff --git a/tests/kamek_ref/expected/output-map-dynamic.map b/tests/kamek_ref/expected/output-map-dynamic.map
new file mode 100644
index 0000000..ed0a7eb
--- /dev/null
+++ b/tests/kamek_ref/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000030 000000 __ctor_loc
+ 00000030 000000 __ctor_end
+ 00000030 000000 _e_text
+ 00000030 000000 _f_ctors
+ 00000030 000000 _e_ctors
+ 00000030 000000 _f_dtors
+ 00000030 000000 _e_dtors
+ 00000030 000000 _f_rodata
+ 00000030 000000 _e_rodata
+ 00000030 000000 _f_data
+ 00000030 000000 _e_data
diff --git a/tests/kamek_ref/expected/output-map-static.map b/tests/kamek_ref/expected/output-map-static.map
new file mode 100644
index 0000000..7f336e4
--- /dev/null
+++ b/tests/kamek_ref/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000030 000000 __ctor_loc
+ 82000030 000000 __ctor_end
+ 82000030 000000 _e_text
+ 82000030 000000 _f_ctors
+ 82000030 000000 _e_ctors
+ 82000030 000000 _f_dtors
+ 82000030 000000 _e_dtors
+ 82000030 000000 _f_rodata
+ 82000030 000000 _e_rodata
+ 82000030 000000 _f_data
+ 82000030 000000 _e_data
diff --git a/tests/kamek_ref/expected/output-riiv.xml b/tests/kamek_ref/expected/output-riiv.xml
new file mode 100644
index 0000000..82d5db3
--- /dev/null
+++ b/tests/kamek_ref/expected/output-riiv.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/kamek_ref/test.S b/tests/kamek_ref/test.S
new file mode 100644
index 0000000..6375d14
--- /dev/null
+++ b/tests/kamek_ref/test.S
@@ -0,0 +1,9 @@
+#include
+
+func:
+ kamek_ref lwz, r3, 0x81000000, r3
+ kamek_ref lwz, r3, 0x81000004, r4
+ kamek_ref stb, r5, 0x81000008, r5
+ kamek_ref stb, r5, 0x8100000c, r6
+ kamek_ref lfs, f1, 0x81000010, r3
+ kamek_ref stfs, f1, 0x81000014, r3
diff --git a/tests/kamek_ref_address/expected/output-alf_104.alf b/tests/kamek_ref_address/expected/output-alf_104.alf
new file mode 100644
index 0000000..08d2532
Binary files /dev/null and b/tests/kamek_ref_address/expected/output-alf_104.alf differ
diff --git a/tests/kamek_ref_address/expected/output-alf_105.alf b/tests/kamek_ref_address/expected/output-alf_105.alf
new file mode 100644
index 0000000..ef24c7f
Binary files /dev/null and b/tests/kamek_ref_address/expected/output-alf_105.alf differ
diff --git a/tests/kamek_ref_address/expected/output-ar.txt b/tests/kamek_ref_address/expected/output-ar.txt
new file mode 100644
index 0000000..9e115b3
--- /dev/null
+++ b/tests/kamek_ref_address/expected/output-ar.txt
@@ -0,0 +1,2 @@
+04000000 3C608100
+04000004 38630000
\ No newline at end of file
diff --git a/tests/kamek_ref_address/expected/output-code.bin b/tests/kamek_ref_address/expected/output-code.bin
new file mode 100644
index 0000000..65eb357
Binary files /dev/null and b/tests/kamek_ref_address/expected/output-code.bin differ
diff --git a/tests/kamek_ref_address/expected/output-dolphin.ini b/tests/kamek_ref_address/expected/output-dolphin.ini
new file mode 100644
index 0000000..df9e500
--- /dev/null
+++ b/tests/kamek_ref_address/expected/output-dolphin.ini
@@ -0,0 +1,2 @@
+0x82000000:dword:0x3C608100
+0x82000004:dword:0x38630000
\ No newline at end of file
diff --git a/tests/kamek_ref_address/expected/output-gecko.txt b/tests/kamek_ref_address/expected/output-gecko.txt
new file mode 100644
index 0000000..1f508fb
--- /dev/null
+++ b/tests/kamek_ref_address/expected/output-gecko.txt
@@ -0,0 +1,2 @@
+06000000 00000008
+3C608100 38630000
\ No newline at end of file
diff --git a/tests/kamek_ref_address/expected/output-kamek.Base.bin b/tests/kamek_ref_address/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..adc3f94
Binary files /dev/null and b/tests/kamek_ref_address/expected/output-kamek.Base.bin differ
diff --git a/tests/kamek_ref_address/expected/output-kamek.V2.bin b/tests/kamek_ref_address/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..87e29e3
Binary files /dev/null and b/tests/kamek_ref_address/expected/output-kamek.V2.bin differ
diff --git a/tests/kamek_ref_address/expected/output-map-dynamic.map b/tests/kamek_ref_address/expected/output-map-dynamic.map
new file mode 100644
index 0000000..e4619f4
--- /dev/null
+++ b/tests/kamek_ref_address/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000008 000000 __ctor_loc
+ 00000008 000000 __ctor_end
+ 00000008 000000 _e_text
+ 00000008 000000 _f_ctors
+ 00000008 000000 _e_ctors
+ 00000008 000000 _f_dtors
+ 00000008 000000 _e_dtors
+ 00000008 000000 _f_rodata
+ 00000008 000000 _e_rodata
+ 00000008 000000 _f_data
+ 00000008 000000 _e_data
diff --git a/tests/kamek_ref_address/expected/output-map-static.map b/tests/kamek_ref_address/expected/output-map-static.map
new file mode 100644
index 0000000..c7e480c
--- /dev/null
+++ b/tests/kamek_ref_address/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000008 000000 __ctor_loc
+ 82000008 000000 __ctor_end
+ 82000008 000000 _e_text
+ 82000008 000000 _f_ctors
+ 82000008 000000 _e_ctors
+ 82000008 000000 _f_dtors
+ 82000008 000000 _e_dtors
+ 82000008 000000 _f_rodata
+ 82000008 000000 _e_rodata
+ 82000008 000000 _f_data
+ 82000008 000000 _e_data
diff --git a/tests/kamek_ref_address/expected/output-riiv.xml b/tests/kamek_ref_address/expected/output-riiv.xml
new file mode 100644
index 0000000..70b8772
--- /dev/null
+++ b/tests/kamek_ref_address/expected/output-riiv.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/kamek_ref_address/test.S b/tests/kamek_ref_address/test.S
new file mode 100644
index 0000000..eb8341a
--- /dev/null
+++ b/tests/kamek_ref_address/test.S
@@ -0,0 +1,4 @@
+#include
+
+func:
+ kamek_ref_address r3, 0x81000000
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-alf_104.alf b/tests/kmBranchDefAsm_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..252369a
Binary files /dev/null and b/tests/kmBranchDefAsm_cpp/expected/output-alf_104.alf differ
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-alf_105.alf b/tests/kmBranchDefAsm_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..ee078e8
Binary files /dev/null and b/tests/kmBranchDefAsm_cpp/expected/output-alf_105.alf differ
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-ar.txt b/tests/kmBranchDefAsm_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..a96454b
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/expected/output-ar.txt
@@ -0,0 +1,24 @@
+04000000 38600001
+04000004 4A000000
+04000008 38600002
+0400000C 4AFFFFF4
+04000010 38600003
+04000014 4800002C
+04000018 38600004
+0400001C 4E800020
+04000020 38600005
+04000024 4A000020
+04000028 38600006
+0400002C 4AFFFFD4
+04000030 38600007
+04000034 4800000C
+04000038 38600008
+0400003C 4E800020
+04000000 4A000000
+04000010 49FFFFF8
+04000020 49FFFFF0
+04000030 49FFFFE8
+05000010 49000010
+05000020 49000008
+05000030 49000000
+05000040 48FFFFF8
\ No newline at end of file
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-code.bin b/tests/kmBranchDefAsm_cpp/expected/output-code.bin
new file mode 100644
index 0000000..f94855f
Binary files /dev/null and b/tests/kmBranchDefAsm_cpp/expected/output-code.bin differ
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-dolphin.ini b/tests/kmBranchDefAsm_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..5ca9743
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/expected/output-dolphin.ini
@@ -0,0 +1,24 @@
+0x82000000:dword:0x38600001
+0x82000004:dword:0x4A000000
+0x82000008:dword:0x38600002
+0x8200000C:dword:0x4AFFFFF4
+0x82000010:dword:0x38600003
+0x82000014:dword:0x4800002C
+0x82000018:dword:0x38600004
+0x8200001C:dword:0x4E800020
+0x82000020:dword:0x38600005
+0x82000024:dword:0x4A000020
+0x82000028:dword:0x38600006
+0x8200002C:dword:0x4AFFFFD4
+0x82000030:dword:0x38600007
+0x82000034:dword:0x4800000C
+0x82000038:dword:0x38600008
+0x8200003C:dword:0x4E800020
+0x80000000:dword:0x4A000000
+0x80000010:dword:0x49FFFFF8
+0x80000020:dword:0x49FFFFF0
+0x80000030:dword:0x49FFFFE8
+0x81000010:dword:0x49000010
+0x81000020:dword:0x49000008
+0x81000030:dword:0x49000000
+0x81000040:dword:0x48FFFFF8
\ No newline at end of file
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-gecko.txt b/tests/kmBranchDefAsm_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..3689ab5
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/expected/output-gecko.txt
@@ -0,0 +1,17 @@
+06000000 00000040
+38600001 4A000000
+38600002 4AFFFFF4
+38600003 4800002C
+38600004 4E800020
+38600005 4A000020
+38600006 4AFFFFD4
+38600007 4800000C
+38600008 4E800020
+04000000 4A000000
+04000010 49FFFFF8
+04000020 49FFFFF0
+04000030 49FFFFE8
+05000010 49000010
+05000020 49000008
+05000030 49000000
+05000040 48FFFFF8
\ No newline at end of file
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-kamek.Base.bin b/tests/kmBranchDefAsm_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..e7807f8
Binary files /dev/null and b/tests/kmBranchDefAsm_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-kamek.V2.bin b/tests/kmBranchDefAsm_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..2ad322e
Binary files /dev/null and b/tests/kmBranchDefAsm_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-map-dynamic.map b/tests/kmBranchDefAsm_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..a6a3bb6
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000040 000000 __ctor_loc
+ 00000040 000000 __ctor_end
+ 00000040 000000 _e_text
+ 00000040 000000 _f_ctors
+ 00000040 000000 _e_ctors
+ 00000040 000000 _f_dtors
+ 00000040 000000 _e_dtors
+ 00000040 000000 _f_rodata
+ 00000040 000000 _e_rodata
+ 00000040 000000 _f_data
+ 00000040 000000 _e_data
+ 00000040 000004 localSym
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-map-static.map b/tests/kmBranchDefAsm_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..dbf9acc
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/expected/output-map-static.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000040 000000 __ctor_loc
+ 82000040 000000 __ctor_end
+ 82000040 000000 _e_text
+ 82000040 000000 _f_ctors
+ 82000040 000000 _e_ctors
+ 82000040 000000 _f_dtors
+ 82000040 000000 _e_dtors
+ 82000040 000000 _f_rodata
+ 82000040 000000 _e_rodata
+ 82000040 000000 _f_data
+ 82000040 000000 _e_data
+ 82000040 000004 localSym
diff --git a/tests/kmBranchDefAsm_cpp/expected/output-riiv.xml b/tests/kmBranchDefAsm_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..cefeb34
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/expected/output-riiv.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/kmBranchDefAsm_cpp/externals.txt b/tests/kmBranchDefAsm_cpp/externals.txt
new file mode 100644
index 0000000..37ace3f
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/externals.txt
@@ -0,0 +1,5 @@
+externalSym=0x81000000
+externalFunc01=0x81000010
+externalFunc02=0x81000020
+externalFunc03=0x81000030
+externalFunc04=0x81000040
\ No newline at end of file
diff --git a/tests/kmBranchDefAsm_cpp/test.cpp b/tests/kmBranchDefAsm_cpp/test.cpp
new file mode 100644
index 0000000..e5b1966
--- /dev/null
+++ b/tests/kmBranchDefAsm_cpp/test.cpp
@@ -0,0 +1,18 @@
+#include
+
+extern int externalSym;
+int localSym;
+
+extern int externalFunc01;
+extern int externalFunc02;
+extern int externalFunc03;
+extern int externalFunc04;
+
+kmBranchDefAsm(0x80000000, 0x80000004) { li r3, 1 }
+kmBranchDefAsm(0x80000010, &externalSym) { li r3, 2 }
+kmBranchDefAsm(0x80000020, &localSym) { li r3, 3 }
+kmBranchDefAsm(0x80000030, 0) { li r3, 4 }
+kmBranchDefAsm(&externalFunc01, 0x80000044) { li r3, 5 }
+kmBranchDefAsm(&externalFunc02, &externalSym) { li r3, 6 }
+kmBranchDefAsm(&externalFunc03, &localSym) { li r3, 7 }
+kmBranchDefAsm(&externalFunc04, 0) { li r3, 8 }
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-alf_104.alf b/tests/kmBranchDefCpp_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..252369a
Binary files /dev/null and b/tests/kmBranchDefCpp_cpp/expected/output-alf_104.alf differ
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-alf_105.alf b/tests/kmBranchDefCpp_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..ee078e8
Binary files /dev/null and b/tests/kmBranchDefCpp_cpp/expected/output-alf_105.alf differ
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-ar.txt b/tests/kmBranchDefCpp_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..a96454b
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/expected/output-ar.txt
@@ -0,0 +1,24 @@
+04000000 38600001
+04000004 4A000000
+04000008 38600002
+0400000C 4AFFFFF4
+04000010 38600003
+04000014 4800002C
+04000018 38600004
+0400001C 4E800020
+04000020 38600005
+04000024 4A000020
+04000028 38600006
+0400002C 4AFFFFD4
+04000030 38600007
+04000034 4800000C
+04000038 38600008
+0400003C 4E800020
+04000000 4A000000
+04000010 49FFFFF8
+04000020 49FFFFF0
+04000030 49FFFFE8
+05000010 49000010
+05000020 49000008
+05000030 49000000
+05000040 48FFFFF8
\ No newline at end of file
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-code.bin b/tests/kmBranchDefCpp_cpp/expected/output-code.bin
new file mode 100644
index 0000000..f94855f
Binary files /dev/null and b/tests/kmBranchDefCpp_cpp/expected/output-code.bin differ
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-dolphin.ini b/tests/kmBranchDefCpp_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..5ca9743
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/expected/output-dolphin.ini
@@ -0,0 +1,24 @@
+0x82000000:dword:0x38600001
+0x82000004:dword:0x4A000000
+0x82000008:dword:0x38600002
+0x8200000C:dword:0x4AFFFFF4
+0x82000010:dword:0x38600003
+0x82000014:dword:0x4800002C
+0x82000018:dword:0x38600004
+0x8200001C:dword:0x4E800020
+0x82000020:dword:0x38600005
+0x82000024:dword:0x4A000020
+0x82000028:dword:0x38600006
+0x8200002C:dword:0x4AFFFFD4
+0x82000030:dword:0x38600007
+0x82000034:dword:0x4800000C
+0x82000038:dword:0x38600008
+0x8200003C:dword:0x4E800020
+0x80000000:dword:0x4A000000
+0x80000010:dword:0x49FFFFF8
+0x80000020:dword:0x49FFFFF0
+0x80000030:dword:0x49FFFFE8
+0x81000010:dword:0x49000010
+0x81000020:dword:0x49000008
+0x81000030:dword:0x49000000
+0x81000040:dword:0x48FFFFF8
\ No newline at end of file
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-gecko.txt b/tests/kmBranchDefCpp_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..3689ab5
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/expected/output-gecko.txt
@@ -0,0 +1,17 @@
+06000000 00000040
+38600001 4A000000
+38600002 4AFFFFF4
+38600003 4800002C
+38600004 4E800020
+38600005 4A000020
+38600006 4AFFFFD4
+38600007 4800000C
+38600008 4E800020
+04000000 4A000000
+04000010 49FFFFF8
+04000020 49FFFFF0
+04000030 49FFFFE8
+05000010 49000010
+05000020 49000008
+05000030 49000000
+05000040 48FFFFF8
\ No newline at end of file
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-kamek.Base.bin b/tests/kmBranchDefCpp_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..e7807f8
Binary files /dev/null and b/tests/kmBranchDefCpp_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-kamek.V2.bin b/tests/kmBranchDefCpp_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..2ad322e
Binary files /dev/null and b/tests/kmBranchDefCpp_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-map-dynamic.map b/tests/kmBranchDefCpp_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..a6a3bb6
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000040 000000 __ctor_loc
+ 00000040 000000 __ctor_end
+ 00000040 000000 _e_text
+ 00000040 000000 _f_ctors
+ 00000040 000000 _e_ctors
+ 00000040 000000 _f_dtors
+ 00000040 000000 _e_dtors
+ 00000040 000000 _f_rodata
+ 00000040 000000 _e_rodata
+ 00000040 000000 _f_data
+ 00000040 000000 _e_data
+ 00000040 000004 localSym
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-map-static.map b/tests/kmBranchDefCpp_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..dbf9acc
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/expected/output-map-static.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000040 000000 __ctor_loc
+ 82000040 000000 __ctor_end
+ 82000040 000000 _e_text
+ 82000040 000000 _f_ctors
+ 82000040 000000 _e_ctors
+ 82000040 000000 _f_dtors
+ 82000040 000000 _e_dtors
+ 82000040 000000 _f_rodata
+ 82000040 000000 _e_rodata
+ 82000040 000000 _f_data
+ 82000040 000000 _e_data
+ 82000040 000004 localSym
diff --git a/tests/kmBranchDefCpp_cpp/expected/output-riiv.xml b/tests/kmBranchDefCpp_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..cefeb34
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/expected/output-riiv.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/kmBranchDefCpp_cpp/externals.txt b/tests/kmBranchDefCpp_cpp/externals.txt
new file mode 100644
index 0000000..37ace3f
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/externals.txt
@@ -0,0 +1,5 @@
+externalSym=0x81000000
+externalFunc01=0x81000010
+externalFunc02=0x81000020
+externalFunc03=0x81000030
+externalFunc04=0x81000040
\ No newline at end of file
diff --git a/tests/kmBranchDefCpp_cpp/test.cpp b/tests/kmBranchDefCpp_cpp/test.cpp
new file mode 100644
index 0000000..5527bf2
--- /dev/null
+++ b/tests/kmBranchDefCpp_cpp/test.cpp
@@ -0,0 +1,18 @@
+#include
+
+extern int externalSym;
+int localSym;
+
+extern int externalFunc01;
+extern int externalFunc02;
+extern int externalFunc03;
+extern int externalFunc04;
+
+kmBranchDefCpp(0x80000000, 0x80000004, int, ) { return 1; }
+kmBranchDefCpp(0x80000010, &externalSym, int, ) { return 2; }
+kmBranchDefCpp(0x80000020, &localSym, int, ) { return 3; }
+kmBranchDefCpp(0x80000030, 0, int, ) { return 4; }
+kmBranchDefCpp(&externalFunc01, 0x80000044, int, ) { return 5; }
+kmBranchDefCpp(&externalFunc02, &externalSym, int, ) { return 6; }
+kmBranchDefCpp(&externalFunc03, &localSym, int, ) { return 7; }
+kmBranchDefCpp(&externalFunc04, 0, int, ) { return 8; }
diff --git a/tests/kmBranchDef_asm/expected/output-alf_104.alf b/tests/kmBranchDef_asm/expected/output-alf_104.alf
new file mode 100644
index 0000000..97108be
Binary files /dev/null and b/tests/kmBranchDef_asm/expected/output-alf_104.alf differ
diff --git a/tests/kmBranchDef_asm/expected/output-alf_105.alf b/tests/kmBranchDef_asm/expected/output-alf_105.alf
new file mode 100644
index 0000000..e8c636d
Binary files /dev/null and b/tests/kmBranchDef_asm/expected/output-alf_105.alf differ
diff --git a/tests/kmBranchDef_asm/expected/output-ar.txt b/tests/kmBranchDef_asm/expected/output-ar.txt
new file mode 100644
index 0000000..6750ead
--- /dev/null
+++ b/tests/kmBranchDef_asm/expected/output-ar.txt
@@ -0,0 +1,6 @@
+04000000 38600001
+04000004 4E800020
+04000008 38600002
+0400000C 4E800020
+04000000 4A000000
+05000000 49000008
\ No newline at end of file
diff --git a/tests/kmBranchDef_asm/expected/output-code.bin b/tests/kmBranchDef_asm/expected/output-code.bin
new file mode 100644
index 0000000..d932a5f
Binary files /dev/null and b/tests/kmBranchDef_asm/expected/output-code.bin differ
diff --git a/tests/kmBranchDef_asm/expected/output-dolphin.ini b/tests/kmBranchDef_asm/expected/output-dolphin.ini
new file mode 100644
index 0000000..bbeda6d
--- /dev/null
+++ b/tests/kmBranchDef_asm/expected/output-dolphin.ini
@@ -0,0 +1,6 @@
+0x82000000:dword:0x38600001
+0x82000004:dword:0x4E800020
+0x82000008:dword:0x38600002
+0x8200000C:dword:0x4E800020
+0x80000000:dword:0x4A000000
+0x81000000:dword:0x49000008
\ No newline at end of file
diff --git a/tests/kmBranchDef_asm/expected/output-gecko.txt b/tests/kmBranchDef_asm/expected/output-gecko.txt
new file mode 100644
index 0000000..3fd1030
--- /dev/null
+++ b/tests/kmBranchDef_asm/expected/output-gecko.txt
@@ -0,0 +1,5 @@
+06000000 00000010
+38600001 4E800020
+38600002 4E800020
+04000000 4A000000
+05000000 49000008
\ No newline at end of file
diff --git a/tests/kmBranchDef_asm/expected/output-kamek.Base.bin b/tests/kmBranchDef_asm/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..c2481a4
Binary files /dev/null and b/tests/kmBranchDef_asm/expected/output-kamek.Base.bin differ
diff --git a/tests/kmBranchDef_asm/expected/output-kamek.V2.bin b/tests/kmBranchDef_asm/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..6613759
Binary files /dev/null and b/tests/kmBranchDef_asm/expected/output-kamek.V2.bin differ
diff --git a/tests/kmBranchDef_asm/expected/output-map-dynamic.map b/tests/kmBranchDef_asm/expected/output-map-dynamic.map
new file mode 100644
index 0000000..11c0e2a
--- /dev/null
+++ b/tests/kmBranchDef_asm/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000010 000000 __ctor_loc
+ 00000010 000000 __ctor_end
+ 00000010 000000 _e_text
+ 00000010 000000 _f_ctors
+ 00000010 000000 _e_ctors
+ 00000010 000000 _f_dtors
+ 00000010 000000 _e_dtors
+ 00000010 000000 _f_rodata
+ 00000010 000000 _e_rodata
+ 00000010 000000 _f_data
+ 00000010 000000 _e_data
diff --git a/tests/kmBranchDef_asm/expected/output-map-static.map b/tests/kmBranchDef_asm/expected/output-map-static.map
new file mode 100644
index 0000000..41dbbd8
--- /dev/null
+++ b/tests/kmBranchDef_asm/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000010 000000 __ctor_loc
+ 82000010 000000 __ctor_end
+ 82000010 000000 _e_text
+ 82000010 000000 _f_ctors
+ 82000010 000000 _e_ctors
+ 82000010 000000 _f_dtors
+ 82000010 000000 _e_dtors
+ 82000010 000000 _f_rodata
+ 82000010 000000 _e_rodata
+ 82000010 000000 _f_data
+ 82000010 000000 _e_data
diff --git a/tests/kmBranchDef_asm/expected/output-riiv.xml b/tests/kmBranchDef_asm/expected/output-riiv.xml
new file mode 100644
index 0000000..3dafd6c
--- /dev/null
+++ b/tests/kmBranchDef_asm/expected/output-riiv.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/tests/kmBranchDef_asm/externals.txt b/tests/kmBranchDef_asm/externals.txt
new file mode 100644
index 0000000..58e4460
--- /dev/null
+++ b/tests/kmBranchDef_asm/externals.txt
@@ -0,0 +1 @@
+externalFunc=0x81000000
\ No newline at end of file
diff --git a/tests/kmBranchDef_asm/test.S b/tests/kmBranchDef_asm/test.S
new file mode 100644
index 0000000..8e0e2fb
--- /dev/null
+++ b/tests/kmBranchDef_asm/test.S
@@ -0,0 +1,10 @@
+#include
+
+.extern externalFunc
+
+kmBranchDef 0x80000000
+ li r3, 1
+ blr
+kmBranchDef externalFunc
+ li r3, 2
+ blr
diff --git a/tests/kmBranch_asm/expected/output-alf_104.alf b/tests/kmBranch_asm/expected/output-alf_104.alf
new file mode 100644
index 0000000..0c2dc11
Binary files /dev/null and b/tests/kmBranch_asm/expected/output-alf_104.alf differ
diff --git a/tests/kmBranch_asm/expected/output-alf_105.alf b/tests/kmBranch_asm/expected/output-alf_105.alf
new file mode 100644
index 0000000..d5fbf48
Binary files /dev/null and b/tests/kmBranch_asm/expected/output-alf_105.alf differ
diff --git a/tests/kmBranch_asm/expected/output-ar.txt b/tests/kmBranch_asm/expected/output-ar.txt
new file mode 100644
index 0000000..e43b449
--- /dev/null
+++ b/tests/kmBranch_asm/expected/output-ar.txt
@@ -0,0 +1,7 @@
+04000000 00000000
+04000000 48000004
+04000010 48FFFFF0
+04000020 49FFFFE0
+05000010 4B000024
+05000020 4BFFFFE0
+05000030 48FFFFD0
\ No newline at end of file
diff --git a/tests/kmBranch_asm/expected/output-code.bin b/tests/kmBranch_asm/expected/output-code.bin
new file mode 100644
index 0000000..593f470
Binary files /dev/null and b/tests/kmBranch_asm/expected/output-code.bin differ
diff --git a/tests/kmBranch_asm/expected/output-dolphin.ini b/tests/kmBranch_asm/expected/output-dolphin.ini
new file mode 100644
index 0000000..1728378
--- /dev/null
+++ b/tests/kmBranch_asm/expected/output-dolphin.ini
@@ -0,0 +1,7 @@
+0x82000000:dword:0x00000000
+0x80000000:dword:0x48000004
+0x80000010:dword:0x48FFFFF0
+0x80000020:dword:0x49FFFFE0
+0x81000010:dword:0x4B000024
+0x81000020:dword:0x4BFFFFE0
+0x81000030:dword:0x48FFFFD0
\ No newline at end of file
diff --git a/tests/kmBranch_asm/expected/output-gecko.txt b/tests/kmBranch_asm/expected/output-gecko.txt
new file mode 100644
index 0000000..5f5b008
--- /dev/null
+++ b/tests/kmBranch_asm/expected/output-gecko.txt
@@ -0,0 +1,8 @@
+06000000 00000008
+00000000 00000000
+04000000 48000004
+04000010 48FFFFF0
+04000020 49FFFFE0
+05000010 4B000024
+05000020 4BFFFFE0
+05000030 48FFFFD0
\ No newline at end of file
diff --git a/tests/kmBranch_asm/expected/output-kamek.Base.bin b/tests/kmBranch_asm/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..b10a17f
Binary files /dev/null and b/tests/kmBranch_asm/expected/output-kamek.Base.bin differ
diff --git a/tests/kmBranch_asm/expected/output-kamek.V2.bin b/tests/kmBranch_asm/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..678249c
Binary files /dev/null and b/tests/kmBranch_asm/expected/output-kamek.V2.bin differ
diff --git a/tests/kmBranch_asm/expected/output-map-dynamic.map b/tests/kmBranch_asm/expected/output-map-dynamic.map
new file mode 100644
index 0000000..e9d7ae6
--- /dev/null
+++ b/tests/kmBranch_asm/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000004 000000 __ctor_loc
+ 00000004 000000 __ctor_end
+ 00000004 000000 _e_text
+ 00000004 000000 _f_ctors
+ 00000004 000000 _e_ctors
+ 00000004 000000 _f_dtors
+ 00000004 000000 _e_dtors
+ 00000004 000000 _f_rodata
+ 00000004 000000 _e_rodata
+ 00000004 000000 _f_data
+ 00000004 000000 _e_data
diff --git a/tests/kmBranch_asm/expected/output-map-static.map b/tests/kmBranch_asm/expected/output-map-static.map
new file mode 100644
index 0000000..bf756ba
--- /dev/null
+++ b/tests/kmBranch_asm/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000004 000000 __ctor_loc
+ 82000004 000000 __ctor_end
+ 82000004 000000 _e_text
+ 82000004 000000 _f_ctors
+ 82000004 000000 _e_ctors
+ 82000004 000000 _f_dtors
+ 82000004 000000 _e_dtors
+ 82000004 000000 _f_rodata
+ 82000004 000000 _e_rodata
+ 82000004 000000 _f_data
+ 82000004 000000 _e_data
diff --git a/tests/kmBranch_asm/expected/output-riiv.xml b/tests/kmBranch_asm/expected/output-riiv.xml
new file mode 100644
index 0000000..6947ffb
--- /dev/null
+++ b/tests/kmBranch_asm/expected/output-riiv.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/kmBranch_asm/externals.txt b/tests/kmBranch_asm/externals.txt
new file mode 100644
index 0000000..05a2afa
--- /dev/null
+++ b/tests/kmBranch_asm/externals.txt
@@ -0,0 +1,4 @@
+externalSym=0x81000000
+externalFunc01=0x81000010
+externalFunc02=0x81000020
+externalFunc03=0x81000030
\ No newline at end of file
diff --git a/tests/kmBranch_asm/test.S b/tests/kmBranch_asm/test.S
new file mode 100644
index 0000000..17a2411
--- /dev/null
+++ b/tests/kmBranch_asm/test.S
@@ -0,0 +1,15 @@
+#include
+
+.extern externalSym
+localSym: .long 0
+
+.extern externalFunc01
+.extern externalFunc02
+.extern externalFunc03
+
+kmBranch 0x80000000, 0x80000004
+kmBranch 0x80000010, externalSym
+kmBranch 0x80000020, localSym
+kmBranch externalFunc01, 0x80000034
+kmBranch externalFunc02, externalSym
+kmBranch externalFunc03, localSym
diff --git a/tests/kmBranch_cpp/expected/output-alf_104.alf b/tests/kmBranch_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..e05feef
Binary files /dev/null and b/tests/kmBranch_cpp/expected/output-alf_104.alf differ
diff --git a/tests/kmBranch_cpp/expected/output-alf_105.alf b/tests/kmBranch_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..27470b4
Binary files /dev/null and b/tests/kmBranch_cpp/expected/output-alf_105.alf differ
diff --git a/tests/kmBranch_cpp/expected/output-ar.txt b/tests/kmBranch_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..7d77f89
--- /dev/null
+++ b/tests/kmBranch_cpp/expected/output-ar.txt
@@ -0,0 +1,6 @@
+04000000 48000004
+04000010 48FFFFF0
+04000020 49FFFFE0
+05000010 4B000024
+05000020 4BFFFFE0
+05000030 48FFFFD0
\ No newline at end of file
diff --git a/tests/kmBranch_cpp/expected/output-code.bin b/tests/kmBranch_cpp/expected/output-code.bin
new file mode 100644
index 0000000..e69de29
diff --git a/tests/kmBranch_cpp/expected/output-dolphin.ini b/tests/kmBranch_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..8c859f9
--- /dev/null
+++ b/tests/kmBranch_cpp/expected/output-dolphin.ini
@@ -0,0 +1,6 @@
+0x80000000:dword:0x48000004
+0x80000010:dword:0x48FFFFF0
+0x80000020:dword:0x49FFFFE0
+0x81000010:dword:0x4B000024
+0x81000020:dword:0x4BFFFFE0
+0x81000030:dword:0x48FFFFD0
\ No newline at end of file
diff --git a/tests/kmBranch_cpp/expected/output-gecko.txt b/tests/kmBranch_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..7d77f89
--- /dev/null
+++ b/tests/kmBranch_cpp/expected/output-gecko.txt
@@ -0,0 +1,6 @@
+04000000 48000004
+04000010 48FFFFF0
+04000020 49FFFFE0
+05000010 4B000024
+05000020 4BFFFFE0
+05000030 48FFFFD0
\ No newline at end of file
diff --git a/tests/kmBranch_cpp/expected/output-kamek.Base.bin b/tests/kmBranch_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..321ca56
Binary files /dev/null and b/tests/kmBranch_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/kmBranch_cpp/expected/output-kamek.V2.bin b/tests/kmBranch_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..489f9ee
Binary files /dev/null and b/tests/kmBranch_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/kmBranch_cpp/expected/output-map-dynamic.map b/tests/kmBranch_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..dd8b8d4
--- /dev/null
+++ b/tests/kmBranch_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 __ctor_loc
+ 00000000 000000 __ctor_end
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000000 000000 _e_text
+ 00000000 000000 _f_ctors
+ 00000000 000000 _e_ctors
+ 00000000 000000 _f_dtors
+ 00000000 000000 _e_dtors
+ 00000000 000000 _f_rodata
+ 00000000 000000 _e_rodata
+ 00000000 000000 _f_data
+ 00000000 000000 _e_data
+ 00000000 000004 localSym
diff --git a/tests/kmBranch_cpp/expected/output-map-static.map b/tests/kmBranch_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..b030be5
--- /dev/null
+++ b/tests/kmBranch_cpp/expected/output-map-static.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 __ctor_loc
+ 82000000 000000 __ctor_end
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000000 000000 _e_text
+ 82000000 000000 _f_ctors
+ 82000000 000000 _e_ctors
+ 82000000 000000 _f_dtors
+ 82000000 000000 _e_dtors
+ 82000000 000000 _f_rodata
+ 82000000 000000 _e_rodata
+ 82000000 000000 _f_data
+ 82000000 000000 _e_data
+ 82000000 000004 localSym
diff --git a/tests/kmBranch_cpp/expected/output-riiv.xml b/tests/kmBranch_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..79ded5f
--- /dev/null
+++ b/tests/kmBranch_cpp/expected/output-riiv.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/kmBranch_cpp/externals.txt b/tests/kmBranch_cpp/externals.txt
new file mode 100644
index 0000000..05a2afa
--- /dev/null
+++ b/tests/kmBranch_cpp/externals.txt
@@ -0,0 +1,4 @@
+externalSym=0x81000000
+externalFunc01=0x81000010
+externalFunc02=0x81000020
+externalFunc03=0x81000030
\ No newline at end of file
diff --git a/tests/kmBranch_cpp/test.cpp b/tests/kmBranch_cpp/test.cpp
new file mode 100644
index 0000000..fae9d13
--- /dev/null
+++ b/tests/kmBranch_cpp/test.cpp
@@ -0,0 +1,15 @@
+#include
+
+extern int externalSym;
+int localSym;
+
+extern int externalFunc01;
+extern int externalFunc02;
+extern int externalFunc03;
+
+kmBranch(0x80000000, 0x80000004);
+kmBranch(0x80000010, &externalSym);
+kmBranch(0x80000020, &localSym);
+kmBranch(&externalFunc01, 0x80000034);
+kmBranch(&externalFunc02, &externalSym);
+kmBranch(&externalFunc03, &localSym);
diff --git a/tests/kmCallDefAsm_cpp/expected/output-alf_104.alf b/tests/kmCallDefAsm_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..6295f9c
Binary files /dev/null and b/tests/kmCallDefAsm_cpp/expected/output-alf_104.alf differ
diff --git a/tests/kmCallDefAsm_cpp/expected/output-alf_105.alf b/tests/kmCallDefAsm_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..daa51eb
Binary files /dev/null and b/tests/kmCallDefAsm_cpp/expected/output-alf_105.alf differ
diff --git a/tests/kmCallDefAsm_cpp/expected/output-ar.txt b/tests/kmCallDefAsm_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..8900b64
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/expected/output-ar.txt
@@ -0,0 +1,6 @@
+04000000 38600001
+04000004 4E800020
+04000008 38600002
+0400000C 4E800020
+04000000 4A000001
+05000000 49000009
\ No newline at end of file
diff --git a/tests/kmCallDefAsm_cpp/expected/output-code.bin b/tests/kmCallDefAsm_cpp/expected/output-code.bin
new file mode 100644
index 0000000..d932a5f
Binary files /dev/null and b/tests/kmCallDefAsm_cpp/expected/output-code.bin differ
diff --git a/tests/kmCallDefAsm_cpp/expected/output-dolphin.ini b/tests/kmCallDefAsm_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..0b9e4bb
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/expected/output-dolphin.ini
@@ -0,0 +1,6 @@
+0x82000000:dword:0x38600001
+0x82000004:dword:0x4E800020
+0x82000008:dword:0x38600002
+0x8200000C:dword:0x4E800020
+0x80000000:dword:0x4A000001
+0x81000000:dword:0x49000009
\ No newline at end of file
diff --git a/tests/kmCallDefAsm_cpp/expected/output-gecko.txt b/tests/kmCallDefAsm_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..2d22d5c
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/expected/output-gecko.txt
@@ -0,0 +1,5 @@
+06000000 00000010
+38600001 4E800020
+38600002 4E800020
+04000000 4A000001
+05000000 49000009
\ No newline at end of file
diff --git a/tests/kmCallDefAsm_cpp/expected/output-kamek.Base.bin b/tests/kmCallDefAsm_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..4ea88bf
Binary files /dev/null and b/tests/kmCallDefAsm_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/kmCallDefAsm_cpp/expected/output-kamek.V2.bin b/tests/kmCallDefAsm_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..2178f18
Binary files /dev/null and b/tests/kmCallDefAsm_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/kmCallDefAsm_cpp/expected/output-map-dynamic.map b/tests/kmCallDefAsm_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..11c0e2a
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000010 000000 __ctor_loc
+ 00000010 000000 __ctor_end
+ 00000010 000000 _e_text
+ 00000010 000000 _f_ctors
+ 00000010 000000 _e_ctors
+ 00000010 000000 _f_dtors
+ 00000010 000000 _e_dtors
+ 00000010 000000 _f_rodata
+ 00000010 000000 _e_rodata
+ 00000010 000000 _f_data
+ 00000010 000000 _e_data
diff --git a/tests/kmCallDefAsm_cpp/expected/output-map-static.map b/tests/kmCallDefAsm_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..41dbbd8
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000010 000000 __ctor_loc
+ 82000010 000000 __ctor_end
+ 82000010 000000 _e_text
+ 82000010 000000 _f_ctors
+ 82000010 000000 _e_ctors
+ 82000010 000000 _f_dtors
+ 82000010 000000 _e_dtors
+ 82000010 000000 _f_rodata
+ 82000010 000000 _e_rodata
+ 82000010 000000 _f_data
+ 82000010 000000 _e_data
diff --git a/tests/kmCallDefAsm_cpp/expected/output-riiv.xml b/tests/kmCallDefAsm_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..697781b
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/expected/output-riiv.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/tests/kmCallDefAsm_cpp/externals.txt b/tests/kmCallDefAsm_cpp/externals.txt
new file mode 100644
index 0000000..4c6c225
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/externals.txt
@@ -0,0 +1 @@
+externalFunc=0x81000000
diff --git a/tests/kmCallDefAsm_cpp/test.cpp b/tests/kmCallDefAsm_cpp/test.cpp
new file mode 100644
index 0000000..a1daf92
--- /dev/null
+++ b/tests/kmCallDefAsm_cpp/test.cpp
@@ -0,0 +1,6 @@
+#include
+
+extern int externalFunc;
+
+kmCallDefAsm(0x80000000) { li r3, 1 }
+kmCallDefAsm(&externalFunc) { li r3, 2 }
diff --git a/tests/kmCallDefCpp_cpp/expected/output-alf_104.alf b/tests/kmCallDefCpp_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..6295f9c
Binary files /dev/null and b/tests/kmCallDefCpp_cpp/expected/output-alf_104.alf differ
diff --git a/tests/kmCallDefCpp_cpp/expected/output-alf_105.alf b/tests/kmCallDefCpp_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..daa51eb
Binary files /dev/null and b/tests/kmCallDefCpp_cpp/expected/output-alf_105.alf differ
diff --git a/tests/kmCallDefCpp_cpp/expected/output-ar.txt b/tests/kmCallDefCpp_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..8900b64
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/expected/output-ar.txt
@@ -0,0 +1,6 @@
+04000000 38600001
+04000004 4E800020
+04000008 38600002
+0400000C 4E800020
+04000000 4A000001
+05000000 49000009
\ No newline at end of file
diff --git a/tests/kmCallDefCpp_cpp/expected/output-code.bin b/tests/kmCallDefCpp_cpp/expected/output-code.bin
new file mode 100644
index 0000000..d932a5f
Binary files /dev/null and b/tests/kmCallDefCpp_cpp/expected/output-code.bin differ
diff --git a/tests/kmCallDefCpp_cpp/expected/output-dolphin.ini b/tests/kmCallDefCpp_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..0b9e4bb
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/expected/output-dolphin.ini
@@ -0,0 +1,6 @@
+0x82000000:dword:0x38600001
+0x82000004:dword:0x4E800020
+0x82000008:dword:0x38600002
+0x8200000C:dword:0x4E800020
+0x80000000:dword:0x4A000001
+0x81000000:dword:0x49000009
\ No newline at end of file
diff --git a/tests/kmCallDefCpp_cpp/expected/output-gecko.txt b/tests/kmCallDefCpp_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..2d22d5c
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/expected/output-gecko.txt
@@ -0,0 +1,5 @@
+06000000 00000010
+38600001 4E800020
+38600002 4E800020
+04000000 4A000001
+05000000 49000009
\ No newline at end of file
diff --git a/tests/kmCallDefCpp_cpp/expected/output-kamek.Base.bin b/tests/kmCallDefCpp_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..4ea88bf
Binary files /dev/null and b/tests/kmCallDefCpp_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/kmCallDefCpp_cpp/expected/output-kamek.V2.bin b/tests/kmCallDefCpp_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..2178f18
Binary files /dev/null and b/tests/kmCallDefCpp_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/kmCallDefCpp_cpp/expected/output-map-dynamic.map b/tests/kmCallDefCpp_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..11c0e2a
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000010 000000 __ctor_loc
+ 00000010 000000 __ctor_end
+ 00000010 000000 _e_text
+ 00000010 000000 _f_ctors
+ 00000010 000000 _e_ctors
+ 00000010 000000 _f_dtors
+ 00000010 000000 _e_dtors
+ 00000010 000000 _f_rodata
+ 00000010 000000 _e_rodata
+ 00000010 000000 _f_data
+ 00000010 000000 _e_data
diff --git a/tests/kmCallDefCpp_cpp/expected/output-map-static.map b/tests/kmCallDefCpp_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..41dbbd8
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000010 000000 __ctor_loc
+ 82000010 000000 __ctor_end
+ 82000010 000000 _e_text
+ 82000010 000000 _f_ctors
+ 82000010 000000 _e_ctors
+ 82000010 000000 _f_dtors
+ 82000010 000000 _e_dtors
+ 82000010 000000 _f_rodata
+ 82000010 000000 _e_rodata
+ 82000010 000000 _f_data
+ 82000010 000000 _e_data
diff --git a/tests/kmCallDefCpp_cpp/expected/output-riiv.xml b/tests/kmCallDefCpp_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..697781b
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/expected/output-riiv.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/tests/kmCallDefCpp_cpp/externals.txt b/tests/kmCallDefCpp_cpp/externals.txt
new file mode 100644
index 0000000..4c6c225
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/externals.txt
@@ -0,0 +1 @@
+externalFunc=0x81000000
diff --git a/tests/kmCallDefCpp_cpp/test.cpp b/tests/kmCallDefCpp_cpp/test.cpp
new file mode 100644
index 0000000..06201e0
--- /dev/null
+++ b/tests/kmCallDefCpp_cpp/test.cpp
@@ -0,0 +1,6 @@
+#include
+
+extern int externalFunc;
+
+kmCallDefCpp(0x80000000, int, ) { return 1; }
+kmCallDefCpp(&externalFunc, int, ) { return 2; }
diff --git a/tests/kmCallDef_asm/expected/output-alf_104.alf b/tests/kmCallDef_asm/expected/output-alf_104.alf
new file mode 100644
index 0000000..6295f9c
Binary files /dev/null and b/tests/kmCallDef_asm/expected/output-alf_104.alf differ
diff --git a/tests/kmCallDef_asm/expected/output-alf_105.alf b/tests/kmCallDef_asm/expected/output-alf_105.alf
new file mode 100644
index 0000000..daa51eb
Binary files /dev/null and b/tests/kmCallDef_asm/expected/output-alf_105.alf differ
diff --git a/tests/kmCallDef_asm/expected/output-ar.txt b/tests/kmCallDef_asm/expected/output-ar.txt
new file mode 100644
index 0000000..8900b64
--- /dev/null
+++ b/tests/kmCallDef_asm/expected/output-ar.txt
@@ -0,0 +1,6 @@
+04000000 38600001
+04000004 4E800020
+04000008 38600002
+0400000C 4E800020
+04000000 4A000001
+05000000 49000009
\ No newline at end of file
diff --git a/tests/kmCallDef_asm/expected/output-code.bin b/tests/kmCallDef_asm/expected/output-code.bin
new file mode 100644
index 0000000..d932a5f
Binary files /dev/null and b/tests/kmCallDef_asm/expected/output-code.bin differ
diff --git a/tests/kmCallDef_asm/expected/output-dolphin.ini b/tests/kmCallDef_asm/expected/output-dolphin.ini
new file mode 100644
index 0000000..0b9e4bb
--- /dev/null
+++ b/tests/kmCallDef_asm/expected/output-dolphin.ini
@@ -0,0 +1,6 @@
+0x82000000:dword:0x38600001
+0x82000004:dword:0x4E800020
+0x82000008:dword:0x38600002
+0x8200000C:dword:0x4E800020
+0x80000000:dword:0x4A000001
+0x81000000:dword:0x49000009
\ No newline at end of file
diff --git a/tests/kmCallDef_asm/expected/output-gecko.txt b/tests/kmCallDef_asm/expected/output-gecko.txt
new file mode 100644
index 0000000..2d22d5c
--- /dev/null
+++ b/tests/kmCallDef_asm/expected/output-gecko.txt
@@ -0,0 +1,5 @@
+06000000 00000010
+38600001 4E800020
+38600002 4E800020
+04000000 4A000001
+05000000 49000009
\ No newline at end of file
diff --git a/tests/kmCallDef_asm/expected/output-kamek.Base.bin b/tests/kmCallDef_asm/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..4ea88bf
Binary files /dev/null and b/tests/kmCallDef_asm/expected/output-kamek.Base.bin differ
diff --git a/tests/kmCallDef_asm/expected/output-kamek.V2.bin b/tests/kmCallDef_asm/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..2178f18
Binary files /dev/null and b/tests/kmCallDef_asm/expected/output-kamek.V2.bin differ
diff --git a/tests/kmCallDef_asm/expected/output-map-dynamic.map b/tests/kmCallDef_asm/expected/output-map-dynamic.map
new file mode 100644
index 0000000..11c0e2a
--- /dev/null
+++ b/tests/kmCallDef_asm/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000010 000000 __ctor_loc
+ 00000010 000000 __ctor_end
+ 00000010 000000 _e_text
+ 00000010 000000 _f_ctors
+ 00000010 000000 _e_ctors
+ 00000010 000000 _f_dtors
+ 00000010 000000 _e_dtors
+ 00000010 000000 _f_rodata
+ 00000010 000000 _e_rodata
+ 00000010 000000 _f_data
+ 00000010 000000 _e_data
diff --git a/tests/kmCallDef_asm/expected/output-map-static.map b/tests/kmCallDef_asm/expected/output-map-static.map
new file mode 100644
index 0000000..41dbbd8
--- /dev/null
+++ b/tests/kmCallDef_asm/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000010 000000 __ctor_loc
+ 82000010 000000 __ctor_end
+ 82000010 000000 _e_text
+ 82000010 000000 _f_ctors
+ 82000010 000000 _e_ctors
+ 82000010 000000 _f_dtors
+ 82000010 000000 _e_dtors
+ 82000010 000000 _f_rodata
+ 82000010 000000 _e_rodata
+ 82000010 000000 _f_data
+ 82000010 000000 _e_data
diff --git a/tests/kmCallDef_asm/expected/output-riiv.xml b/tests/kmCallDef_asm/expected/output-riiv.xml
new file mode 100644
index 0000000..697781b
--- /dev/null
+++ b/tests/kmCallDef_asm/expected/output-riiv.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/tests/kmCallDef_asm/externals.txt b/tests/kmCallDef_asm/externals.txt
new file mode 100644
index 0000000..58e4460
--- /dev/null
+++ b/tests/kmCallDef_asm/externals.txt
@@ -0,0 +1 @@
+externalFunc=0x81000000
\ No newline at end of file
diff --git a/tests/kmCallDef_asm/test.S b/tests/kmCallDef_asm/test.S
new file mode 100644
index 0000000..8f83a19
--- /dev/null
+++ b/tests/kmCallDef_asm/test.S
@@ -0,0 +1,10 @@
+#include
+
+.extern externalFunc
+
+kmCallDef 0x80000000
+ li r3, 1
+ blr
+kmCallDef externalFunc
+ li r3, 2
+ blr
diff --git a/tests/kmCall_asm/expected/output-alf_104.alf b/tests/kmCall_asm/expected/output-alf_104.alf
new file mode 100644
index 0000000..6327e72
Binary files /dev/null and b/tests/kmCall_asm/expected/output-alf_104.alf differ
diff --git a/tests/kmCall_asm/expected/output-alf_105.alf b/tests/kmCall_asm/expected/output-alf_105.alf
new file mode 100644
index 0000000..b903d12
Binary files /dev/null and b/tests/kmCall_asm/expected/output-alf_105.alf differ
diff --git a/tests/kmCall_asm/expected/output-ar.txt b/tests/kmCall_asm/expected/output-ar.txt
new file mode 100644
index 0000000..59afbfa
--- /dev/null
+++ b/tests/kmCall_asm/expected/output-ar.txt
@@ -0,0 +1,7 @@
+04000000 00000000
+04000000 48000005
+04000010 48FFFFF1
+04000020 49FFFFE1
+05000010 4B000025
+05000020 4BFFFFE1
+05000030 48FFFFD1
\ No newline at end of file
diff --git a/tests/kmCall_asm/expected/output-code.bin b/tests/kmCall_asm/expected/output-code.bin
new file mode 100644
index 0000000..593f470
Binary files /dev/null and b/tests/kmCall_asm/expected/output-code.bin differ
diff --git a/tests/kmCall_asm/expected/output-dolphin.ini b/tests/kmCall_asm/expected/output-dolphin.ini
new file mode 100644
index 0000000..0fbca90
--- /dev/null
+++ b/tests/kmCall_asm/expected/output-dolphin.ini
@@ -0,0 +1,7 @@
+0x82000000:dword:0x00000000
+0x80000000:dword:0x48000005
+0x80000010:dword:0x48FFFFF1
+0x80000020:dword:0x49FFFFE1
+0x81000010:dword:0x4B000025
+0x81000020:dword:0x4BFFFFE1
+0x81000030:dword:0x48FFFFD1
\ No newline at end of file
diff --git a/tests/kmCall_asm/expected/output-gecko.txt b/tests/kmCall_asm/expected/output-gecko.txt
new file mode 100644
index 0000000..05d673c
--- /dev/null
+++ b/tests/kmCall_asm/expected/output-gecko.txt
@@ -0,0 +1,8 @@
+06000000 00000008
+00000000 00000000
+04000000 48000005
+04000010 48FFFFF1
+04000020 49FFFFE1
+05000010 4B000025
+05000020 4BFFFFE1
+05000030 48FFFFD1
\ No newline at end of file
diff --git a/tests/kmCall_asm/expected/output-kamek.Base.bin b/tests/kmCall_asm/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..42fe5c5
Binary files /dev/null and b/tests/kmCall_asm/expected/output-kamek.Base.bin differ
diff --git a/tests/kmCall_asm/expected/output-kamek.V2.bin b/tests/kmCall_asm/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..dd98216
Binary files /dev/null and b/tests/kmCall_asm/expected/output-kamek.V2.bin differ
diff --git a/tests/kmCall_asm/expected/output-map-dynamic.map b/tests/kmCall_asm/expected/output-map-dynamic.map
new file mode 100644
index 0000000..e9d7ae6
--- /dev/null
+++ b/tests/kmCall_asm/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000004 000000 __ctor_loc
+ 00000004 000000 __ctor_end
+ 00000004 000000 _e_text
+ 00000004 000000 _f_ctors
+ 00000004 000000 _e_ctors
+ 00000004 000000 _f_dtors
+ 00000004 000000 _e_dtors
+ 00000004 000000 _f_rodata
+ 00000004 000000 _e_rodata
+ 00000004 000000 _f_data
+ 00000004 000000 _e_data
diff --git a/tests/kmCall_asm/expected/output-map-static.map b/tests/kmCall_asm/expected/output-map-static.map
new file mode 100644
index 0000000..bf756ba
--- /dev/null
+++ b/tests/kmCall_asm/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000004 000000 __ctor_loc
+ 82000004 000000 __ctor_end
+ 82000004 000000 _e_text
+ 82000004 000000 _f_ctors
+ 82000004 000000 _e_ctors
+ 82000004 000000 _f_dtors
+ 82000004 000000 _e_dtors
+ 82000004 000000 _f_rodata
+ 82000004 000000 _e_rodata
+ 82000004 000000 _f_data
+ 82000004 000000 _e_data
diff --git a/tests/kmCall_asm/expected/output-riiv.xml b/tests/kmCall_asm/expected/output-riiv.xml
new file mode 100644
index 0000000..895a132
--- /dev/null
+++ b/tests/kmCall_asm/expected/output-riiv.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/kmCall_asm/externals.txt b/tests/kmCall_asm/externals.txt
new file mode 100644
index 0000000..05a2afa
--- /dev/null
+++ b/tests/kmCall_asm/externals.txt
@@ -0,0 +1,4 @@
+externalSym=0x81000000
+externalFunc01=0x81000010
+externalFunc02=0x81000020
+externalFunc03=0x81000030
\ No newline at end of file
diff --git a/tests/kmCall_asm/test.S b/tests/kmCall_asm/test.S
new file mode 100644
index 0000000..ee09490
--- /dev/null
+++ b/tests/kmCall_asm/test.S
@@ -0,0 +1,15 @@
+#include
+
+.extern externalSym
+localSym: .long 0
+
+.extern externalFunc01
+.extern externalFunc02
+.extern externalFunc03
+
+kmCall 0x80000000, 0x80000004
+kmCall 0x80000010, externalSym
+kmCall 0x80000020, localSym
+kmCall externalFunc01, 0x80000034
+kmCall externalFunc02, externalSym
+kmCall externalFunc03, localSym
diff --git a/tests/kmCall_cpp/expected/output-alf_104.alf b/tests/kmCall_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..88aedf1
Binary files /dev/null and b/tests/kmCall_cpp/expected/output-alf_104.alf differ
diff --git a/tests/kmCall_cpp/expected/output-alf_105.alf b/tests/kmCall_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..951f584
Binary files /dev/null and b/tests/kmCall_cpp/expected/output-alf_105.alf differ
diff --git a/tests/kmCall_cpp/expected/output-ar.txt b/tests/kmCall_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..66ca567
--- /dev/null
+++ b/tests/kmCall_cpp/expected/output-ar.txt
@@ -0,0 +1,6 @@
+04000000 48000005
+04000010 48FFFFF1
+04000020 49FFFFE1
+05000010 4B000025
+05000020 4BFFFFE1
+05000030 48FFFFD1
\ No newline at end of file
diff --git a/tests/kmCall_cpp/expected/output-code.bin b/tests/kmCall_cpp/expected/output-code.bin
new file mode 100644
index 0000000..e69de29
diff --git a/tests/kmCall_cpp/expected/output-dolphin.ini b/tests/kmCall_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..38ab00b
--- /dev/null
+++ b/tests/kmCall_cpp/expected/output-dolphin.ini
@@ -0,0 +1,6 @@
+0x80000000:dword:0x48000005
+0x80000010:dword:0x48FFFFF1
+0x80000020:dword:0x49FFFFE1
+0x81000010:dword:0x4B000025
+0x81000020:dword:0x4BFFFFE1
+0x81000030:dword:0x48FFFFD1
\ No newline at end of file
diff --git a/tests/kmCall_cpp/expected/output-gecko.txt b/tests/kmCall_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..66ca567
--- /dev/null
+++ b/tests/kmCall_cpp/expected/output-gecko.txt
@@ -0,0 +1,6 @@
+04000000 48000005
+04000010 48FFFFF1
+04000020 49FFFFE1
+05000010 4B000025
+05000020 4BFFFFE1
+05000030 48FFFFD1
\ No newline at end of file
diff --git a/tests/kmCall_cpp/expected/output-kamek.Base.bin b/tests/kmCall_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..7a86425
Binary files /dev/null and b/tests/kmCall_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/kmCall_cpp/expected/output-kamek.V2.bin b/tests/kmCall_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..4ceb8e7
Binary files /dev/null and b/tests/kmCall_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/kmCall_cpp/expected/output-map-dynamic.map b/tests/kmCall_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..dd8b8d4
--- /dev/null
+++ b/tests/kmCall_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 __ctor_loc
+ 00000000 000000 __ctor_end
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000000 000000 _e_text
+ 00000000 000000 _f_ctors
+ 00000000 000000 _e_ctors
+ 00000000 000000 _f_dtors
+ 00000000 000000 _e_dtors
+ 00000000 000000 _f_rodata
+ 00000000 000000 _e_rodata
+ 00000000 000000 _f_data
+ 00000000 000000 _e_data
+ 00000000 000004 localSym
diff --git a/tests/kmCall_cpp/expected/output-map-static.map b/tests/kmCall_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..b030be5
--- /dev/null
+++ b/tests/kmCall_cpp/expected/output-map-static.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 __ctor_loc
+ 82000000 000000 __ctor_end
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000000 000000 _e_text
+ 82000000 000000 _f_ctors
+ 82000000 000000 _e_ctors
+ 82000000 000000 _f_dtors
+ 82000000 000000 _e_dtors
+ 82000000 000000 _f_rodata
+ 82000000 000000 _e_rodata
+ 82000000 000000 _f_data
+ 82000000 000000 _e_data
+ 82000000 000004 localSym
diff --git a/tests/kmCall_cpp/expected/output-riiv.xml b/tests/kmCall_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..93ac23d
--- /dev/null
+++ b/tests/kmCall_cpp/expected/output-riiv.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/kmCall_cpp/externals.txt b/tests/kmCall_cpp/externals.txt
new file mode 100644
index 0000000..05a2afa
--- /dev/null
+++ b/tests/kmCall_cpp/externals.txt
@@ -0,0 +1,4 @@
+externalSym=0x81000000
+externalFunc01=0x81000010
+externalFunc02=0x81000020
+externalFunc03=0x81000030
\ No newline at end of file
diff --git a/tests/kmCall_cpp/test.cpp b/tests/kmCall_cpp/test.cpp
new file mode 100644
index 0000000..721c729
--- /dev/null
+++ b/tests/kmCall_cpp/test.cpp
@@ -0,0 +1,15 @@
+#include
+
+extern int externalSym;
+int localSym;
+
+extern int externalFunc01;
+extern int externalFunc02;
+extern int externalFunc03;
+
+kmCall(0x80000000, 0x80000004);
+kmCall(0x80000010, &externalSym);
+kmCall(0x80000020, &localSym);
+kmCall(&externalFunc01, 0x80000034);
+kmCall(&externalFunc02, &externalSym);
+kmCall(&externalFunc03, &localSym);
diff --git a/tests/kmPatchExitPoint/expected/output-alf_104.alf b/tests/kmPatchExitPoint/expected/output-alf_104.alf
new file mode 100644
index 0000000..daff94e
Binary files /dev/null and b/tests/kmPatchExitPoint/expected/output-alf_104.alf differ
diff --git a/tests/kmPatchExitPoint/expected/output-alf_105.alf b/tests/kmPatchExitPoint/expected/output-alf_105.alf
new file mode 100644
index 0000000..2d5f97d
Binary files /dev/null and b/tests/kmPatchExitPoint/expected/output-alf_105.alf differ
diff --git a/tests/kmPatchExitPoint/expected/output-ar.txt b/tests/kmPatchExitPoint/expected/output-ar.txt
new file mode 100644
index 0000000..bd2c0b8
--- /dev/null
+++ b/tests/kmPatchExitPoint/expected/output-ar.txt
@@ -0,0 +1,4 @@
+04000000 4A000000
+04000004 4AFFFFFC
+04000008 48000008
+0400000C 4E800020
\ No newline at end of file
diff --git a/tests/kmPatchExitPoint/expected/output-code.bin b/tests/kmPatchExitPoint/expected/output-code.bin
new file mode 100644
index 0000000..caf16a9
Binary files /dev/null and b/tests/kmPatchExitPoint/expected/output-code.bin differ
diff --git a/tests/kmPatchExitPoint/expected/output-dolphin.ini b/tests/kmPatchExitPoint/expected/output-dolphin.ini
new file mode 100644
index 0000000..1edb64d
--- /dev/null
+++ b/tests/kmPatchExitPoint/expected/output-dolphin.ini
@@ -0,0 +1,4 @@
+0x82000000:dword:0x4A000000
+0x82000004:dword:0x4AFFFFFC
+0x82000008:dword:0x48000008
+0x8200000C:dword:0x4E800020
\ No newline at end of file
diff --git a/tests/kmPatchExitPoint/expected/output-gecko.txt b/tests/kmPatchExitPoint/expected/output-gecko.txt
new file mode 100644
index 0000000..1bd54d0
--- /dev/null
+++ b/tests/kmPatchExitPoint/expected/output-gecko.txt
@@ -0,0 +1,3 @@
+06000000 00000010
+4A000000 4AFFFFFC
+48000008 4E800020
\ No newline at end of file
diff --git a/tests/kmPatchExitPoint/expected/output-kamek.Base.bin b/tests/kmPatchExitPoint/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..035efa2
Binary files /dev/null and b/tests/kmPatchExitPoint/expected/output-kamek.Base.bin differ
diff --git a/tests/kmPatchExitPoint/expected/output-kamek.V2.bin b/tests/kmPatchExitPoint/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..9a0c089
Binary files /dev/null and b/tests/kmPatchExitPoint/expected/output-kamek.V2.bin differ
diff --git a/tests/kmPatchExitPoint/expected/output-map-dynamic.map b/tests/kmPatchExitPoint/expected/output-map-dynamic.map
new file mode 100644
index 0000000..8b507ee
--- /dev/null
+++ b/tests/kmPatchExitPoint/expected/output-map-dynamic.map
@@ -0,0 +1,21 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000000 000004 localFunc01__Fv
+ 00000004 000004 localFunc02__Fv
+ 00000008 000004 localFunc03__Fv
+ 0000000C 000004 localFunc04__Fv
+ 00000010 000000 __ctor_loc
+ 00000010 000000 __ctor_end
+ 00000010 000000 _e_text
+ 00000010 000000 _f_ctors
+ 00000010 000000 _e_ctors
+ 00000010 000000 _f_dtors
+ 00000010 000000 _e_dtors
+ 00000010 000000 _f_rodata
+ 00000010 000000 _e_rodata
+ 00000010 000000 _f_data
+ 00000010 000000 _e_data
+ 00000010 000004 localSym
diff --git a/tests/kmPatchExitPoint/expected/output-map-static.map b/tests/kmPatchExitPoint/expected/output-map-static.map
new file mode 100644
index 0000000..9ca6de8
--- /dev/null
+++ b/tests/kmPatchExitPoint/expected/output-map-static.map
@@ -0,0 +1,21 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000000 000004 localFunc01__Fv
+ 82000004 000004 localFunc02__Fv
+ 82000008 000004 localFunc03__Fv
+ 8200000C 000004 localFunc04__Fv
+ 82000010 000000 __ctor_loc
+ 82000010 000000 __ctor_end
+ 82000010 000000 _e_text
+ 82000010 000000 _f_ctors
+ 82000010 000000 _e_ctors
+ 82000010 000000 _f_dtors
+ 82000010 000000 _e_dtors
+ 82000010 000000 _f_rodata
+ 82000010 000000 _e_rodata
+ 82000010 000000 _f_data
+ 82000010 000000 _e_data
+ 82000010 000004 localSym
diff --git a/tests/kmPatchExitPoint/expected/output-riiv.xml b/tests/kmPatchExitPoint/expected/output-riiv.xml
new file mode 100644
index 0000000..92b7577
--- /dev/null
+++ b/tests/kmPatchExitPoint/expected/output-riiv.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/kmPatchExitPoint/externals.txt b/tests/kmPatchExitPoint/externals.txt
new file mode 100644
index 0000000..f1fe089
--- /dev/null
+++ b/tests/kmPatchExitPoint/externals.txt
@@ -0,0 +1 @@
+externalSym=0x81000000
diff --git a/tests/kmPatchExitPoint/test.cpp b/tests/kmPatchExitPoint/test.cpp
new file mode 100644
index 0000000..803f9dc
--- /dev/null
+++ b/tests/kmPatchExitPoint/test.cpp
@@ -0,0 +1,14 @@
+#include
+
+extern int externalSym;
+int localSym;
+
+void localFunc01() {}
+void localFunc02() {}
+void localFunc03() {}
+void localFunc04() {}
+
+kmPatchExitPoint(localFunc01, 0x80000000);
+kmPatchExitPoint(localFunc02, &externalSym);
+kmPatchExitPoint(localFunc03, &localSym);
+kmPatchExitPoint(localFunc04, 0);
diff --git a/tests/linkage_asm/expected/output-alf_104.alf b/tests/linkage_asm/expected/output-alf_104.alf
new file mode 100644
index 0000000..b441ddf
Binary files /dev/null and b/tests/linkage_asm/expected/output-alf_104.alf differ
diff --git a/tests/linkage_asm/expected/output-alf_105.alf b/tests/linkage_asm/expected/output-alf_105.alf
new file mode 100644
index 0000000..9b4e4d3
Binary files /dev/null and b/tests/linkage_asm/expected/output-alf_105.alf differ
diff --git a/tests/linkage_asm/expected/output-ar.txt b/tests/linkage_asm/expected/output-ar.txt
new file mode 100644
index 0000000..abedb5e
--- /dev/null
+++ b/tests/linkage_asm/expected/output-ar.txt
@@ -0,0 +1,14 @@
+04000000 00000000
+04000004 00000000
+04000008 4B00122C
+0400000C 4BFFFFF8
+04000010 4182FFF4
+04000014 38008100
+04000018 38008100
+0400001C 38008200
+04000020 38008100
+04000024 38008101
+04000028 38008200
+0400002C 38001234
+04000030 3800F234
+04000034 38000004
\ No newline at end of file
diff --git a/tests/linkage_asm/expected/output-code.bin b/tests/linkage_asm/expected/output-code.bin
new file mode 100644
index 0000000..0637aa1
Binary files /dev/null and b/tests/linkage_asm/expected/output-code.bin differ
diff --git a/tests/linkage_asm/expected/output-dolphin.ini b/tests/linkage_asm/expected/output-dolphin.ini
new file mode 100644
index 0000000..ba55cae
--- /dev/null
+++ b/tests/linkage_asm/expected/output-dolphin.ini
@@ -0,0 +1,14 @@
+0x82000000:dword:0x00000000
+0x82000004:dword:0x00000000
+0x82000008:dword:0x4B00122C
+0x8200000C:dword:0x4BFFFFF8
+0x82000010:dword:0x4182FFF4
+0x82000014:dword:0x38008100
+0x82000018:dword:0x38008100
+0x8200001C:dword:0x38008200
+0x82000020:dword:0x38008100
+0x82000024:dword:0x38008101
+0x82000028:dword:0x38008200
+0x8200002C:dword:0x38001234
+0x82000030:dword:0x3800F234
+0x82000034:dword:0x38000004
\ No newline at end of file
diff --git a/tests/linkage_asm/expected/output-gecko.txt b/tests/linkage_asm/expected/output-gecko.txt
new file mode 100644
index 0000000..054aefd
--- /dev/null
+++ b/tests/linkage_asm/expected/output-gecko.txt
@@ -0,0 +1,8 @@
+06000000 00000038
+00000000 00000000
+4B00122C 4BFFFFF8
+4182FFF4 38008100
+38008100 38008200
+38008100 38008101
+38008200 38001234
+3800F234 38000004
\ No newline at end of file
diff --git a/tests/linkage_asm/expected/output-kamek.Base.bin b/tests/linkage_asm/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..cdc4bec
Binary files /dev/null and b/tests/linkage_asm/expected/output-kamek.Base.bin differ
diff --git a/tests/linkage_asm/expected/output-kamek.V2.bin b/tests/linkage_asm/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..2c7055e
Binary files /dev/null and b/tests/linkage_asm/expected/output-kamek.V2.bin differ
diff --git a/tests/linkage_asm/expected/output-map-dynamic.map b/tests/linkage_asm/expected/output-map-dynamic.map
new file mode 100644
index 0000000..f770902
--- /dev/null
+++ b/tests/linkage_asm/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000038 000000 __ctor_loc
+ 00000038 000000 __ctor_end
+ 00000038 000000 _e_text
+ 00000038 000000 _f_ctors
+ 00000038 000000 _e_ctors
+ 00000038 000000 _f_dtors
+ 00000038 000000 _e_dtors
+ 00000038 000000 _f_rodata
+ 00000038 000000 _e_rodata
+ 00000038 000000 _f_data
+ 00000038 000000 _e_data
diff --git a/tests/linkage_asm/expected/output-map-static.map b/tests/linkage_asm/expected/output-map-static.map
new file mode 100644
index 0000000..499086d
--- /dev/null
+++ b/tests/linkage_asm/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000038 000000 __ctor_loc
+ 82000038 000000 __ctor_end
+ 82000038 000000 _e_text
+ 82000038 000000 _f_ctors
+ 82000038 000000 _e_ctors
+ 82000038 000000 _f_dtors
+ 82000038 000000 _e_dtors
+ 82000038 000000 _f_rodata
+ 82000038 000000 _e_rodata
+ 82000038 000000 _f_data
+ 82000038 000000 _e_data
diff --git a/tests/linkage_asm/expected/output-riiv.xml b/tests/linkage_asm/expected/output-riiv.xml
new file mode 100644
index 0000000..6dad161
--- /dev/null
+++ b/tests/linkage_asm/expected/output-riiv.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/linkage_asm/externals.txt b/tests/linkage_asm/externals.txt
new file mode 100644
index 0000000..43554d7
--- /dev/null
+++ b/tests/linkage_asm/externals.txt
@@ -0,0 +1,2 @@
+externalSym1=0x81001234
+externalSym2=0x8100f234
\ No newline at end of file
diff --git a/tests/linkage_asm/test.S b/tests/linkage_asm/test.S
new file mode 100644
index 0000000..8f416fe
--- /dev/null
+++ b/tests/linkage_asm/test.S
@@ -0,0 +1,20 @@
+#include
+
+.extern externalSym1, externalSym2
+.long 0
+localSym: .long 0
+
+localFunc:
+ b externalSym1
+ b localSym
+ // beq externalSym1 // not possible
+ beq localSym
+ li r0, externalSym1@h
+ li r0, externalSym2@h
+ li r0, localSym@h
+ li r0, externalSym1@ha
+ li r0, externalSym2@ha
+ li r0, localSym@ha
+ li r0, externalSym1@l
+ li r0, externalSym2@l
+ li r0, localSym@l
diff --git a/tests/linkage_cpp/expected/output-alf_104.alf b/tests/linkage_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..59d205d
Binary files /dev/null and b/tests/linkage_cpp/expected/output-alf_104.alf differ
diff --git a/tests/linkage_cpp/expected/output-alf_105.alf b/tests/linkage_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..05e7962
Binary files /dev/null and b/tests/linkage_cpp/expected/output-alf_105.alf differ
diff --git a/tests/linkage_cpp/expected/output-ar.txt b/tests/linkage_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..9cd4582
--- /dev/null
+++ b/tests/linkage_cpp/expected/output-ar.txt
@@ -0,0 +1,39 @@
+04000000 38600000
+04000004 4E800020
+04000008 38600001
+0400000C 4E800020
+04000010 9421FFF0
+04000014 7C0802A6
+04000018 90010014
+0400001C 93E1000C
+04000020 3BE00000
+04000024 4B001211
+04000028 4B00F20D
+0400002C 4BFFFFDD
+04000030 3C608100
+04000034 38031234
+04000038 7FFF0278
+0400003C 3C608101
+04000040 3803F234
+04000044 7FFF0278
+04000048 3C608200
+0400004C 38030008
+04000050 7FFF0278
+04000054 7FE3FB78
+04000058 83E1000C
+0400005C 80010014
+04000060 7C0803A6
+04000064 38210010
+04000068 4E800020
+0400006C 4B0011C8
+04000070 4BFFFF98
+04000074 38008100
+04000078 38008100
+0400007C 38008200
+04000080 38008100
+04000084 38008101
+04000088 38008200
+0400008C 38001234
+04000090 3800F234
+04000094 38000008
+04000098 4E800020
\ No newline at end of file
diff --git a/tests/linkage_cpp/expected/output-code.bin b/tests/linkage_cpp/expected/output-code.bin
new file mode 100644
index 0000000..604e482
Binary files /dev/null and b/tests/linkage_cpp/expected/output-code.bin differ
diff --git a/tests/linkage_cpp/expected/output-dolphin.ini b/tests/linkage_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..bf6d295
--- /dev/null
+++ b/tests/linkage_cpp/expected/output-dolphin.ini
@@ -0,0 +1,39 @@
+0x82000000:dword:0x38600000
+0x82000004:dword:0x4E800020
+0x82000008:dword:0x38600001
+0x8200000C:dword:0x4E800020
+0x82000010:dword:0x9421FFF0
+0x82000014:dword:0x7C0802A6
+0x82000018:dword:0x90010014
+0x8200001C:dword:0x93E1000C
+0x82000020:dword:0x3BE00000
+0x82000024:dword:0x4B001211
+0x82000028:dword:0x4B00F20D
+0x8200002C:dword:0x4BFFFFDD
+0x82000030:dword:0x3C608100
+0x82000034:dword:0x38031234
+0x82000038:dword:0x7FFF0278
+0x8200003C:dword:0x3C608101
+0x82000040:dword:0x3803F234
+0x82000044:dword:0x7FFF0278
+0x82000048:dword:0x3C608200
+0x8200004C:dword:0x38030008
+0x82000050:dword:0x7FFF0278
+0x82000054:dword:0x7FE3FB78
+0x82000058:dword:0x83E1000C
+0x8200005C:dword:0x80010014
+0x82000060:dword:0x7C0803A6
+0x82000064:dword:0x38210010
+0x82000068:dword:0x4E800020
+0x8200006C:dword:0x4B0011C8
+0x82000070:dword:0x4BFFFF98
+0x82000074:dword:0x38008100
+0x82000078:dword:0x38008100
+0x8200007C:dword:0x38008200
+0x82000080:dword:0x38008100
+0x82000084:dword:0x38008101
+0x82000088:dword:0x38008200
+0x8200008C:dword:0x38001234
+0x82000090:dword:0x3800F234
+0x82000094:dword:0x38000008
+0x82000098:dword:0x4E800020
\ No newline at end of file
diff --git a/tests/linkage_cpp/expected/output-gecko.txt b/tests/linkage_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..c4534b6
--- /dev/null
+++ b/tests/linkage_cpp/expected/output-gecko.txt
@@ -0,0 +1,21 @@
+06000000 000000A0
+38600000 4E800020
+38600001 4E800020
+9421FFF0 7C0802A6
+90010014 93E1000C
+3BE00000 4B001211
+4B00F20D 4BFFFFDD
+3C608100 38031234
+7FFF0278 3C608101
+3803F234 7FFF0278
+3C608200 38030008
+7FFF0278 7FE3FB78
+83E1000C 80010014
+7C0803A6 38210010
+4E800020 4B0011C8
+4BFFFF98 38008100
+38008100 38008200
+38008100 38008101
+38008200 38001234
+3800F234 38000008
+4E800020 00000000
\ No newline at end of file
diff --git a/tests/linkage_cpp/expected/output-kamek.Base.bin b/tests/linkage_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..938bbf0
Binary files /dev/null and b/tests/linkage_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/linkage_cpp/expected/output-kamek.V2.bin b/tests/linkage_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..7f44310
Binary files /dev/null and b/tests/linkage_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/linkage_cpp/expected/output-map-dynamic.map b/tests/linkage_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..941753f
--- /dev/null
+++ b/tests/linkage_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,20 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000000 000008 placeholder__Fv
+ 00000008 000008 localSym__Fv
+ 00000010 00005C localFunc__Fv
+ 0000006C 000030 localFuncAsm__Fv
+ 0000009C 000000 __ctor_loc
+ 0000009C 000000 __ctor_end
+ 0000009C 000000 _e_text
+ 0000009C 000000 _f_ctors
+ 0000009C 000000 _e_ctors
+ 0000009C 000000 _f_dtors
+ 0000009C 000000 _e_dtors
+ 0000009C 000000 _f_rodata
+ 0000009C 000000 _e_rodata
+ 0000009C 000000 _f_data
+ 0000009C 000000 _e_data
diff --git a/tests/linkage_cpp/expected/output-map-static.map b/tests/linkage_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..eda28ee
--- /dev/null
+++ b/tests/linkage_cpp/expected/output-map-static.map
@@ -0,0 +1,20 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000000 000008 placeholder__Fv
+ 82000008 000008 localSym__Fv
+ 82000010 00005C localFunc__Fv
+ 8200006C 000030 localFuncAsm__Fv
+ 8200009C 000000 __ctor_loc
+ 8200009C 000000 __ctor_end
+ 8200009C 000000 _e_text
+ 8200009C 000000 _f_ctors
+ 8200009C 000000 _e_ctors
+ 8200009C 000000 _f_dtors
+ 8200009C 000000 _e_dtors
+ 8200009C 000000 _f_rodata
+ 8200009C 000000 _e_rodata
+ 8200009C 000000 _f_data
+ 8200009C 000000 _e_data
diff --git a/tests/linkage_cpp/expected/output-riiv.xml b/tests/linkage_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..57a2281
--- /dev/null
+++ b/tests/linkage_cpp/expected/output-riiv.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/linkage_cpp/externals.txt b/tests/linkage_cpp/externals.txt
new file mode 100644
index 0000000..43554d7
--- /dev/null
+++ b/tests/linkage_cpp/externals.txt
@@ -0,0 +1,2 @@
+externalSym1=0x81001234
+externalSym2=0x8100f234
\ No newline at end of file
diff --git a/tests/linkage_cpp/test.cpp b/tests/linkage_cpp/test.cpp
new file mode 100644
index 0000000..32bf347
--- /dev/null
+++ b/tests/linkage_cpp/test.cpp
@@ -0,0 +1,38 @@
+#include
+
+extern "C" unsigned int externalSym1();
+extern "C" unsigned int externalSym2();
+
+__attribute__ ((noinline)) unsigned int placeholder() { return 0; };
+__attribute__ ((noinline)) unsigned int localSym() { return 1; };
+
+unsigned int localFunc() {
+ unsigned int value = 0;
+
+ externalSym1();
+ externalSym2();
+ localSym();
+
+ value ^= (unsigned int)externalSym1;
+ value ^= (unsigned int)externalSym2;
+ value ^= (unsigned int)localSym;
+
+ return value;
+}
+
+asm void localFuncAsm() {
+ b externalSym1
+ b localSym
+ // beq externalSym1 // not possible
+ // beq localSym // intentionally not allowed in C++, since you can't guarantee
+ // that the other function will be close enough to fit in a REL14
+ li r0, externalSym1@h
+ li r0, externalSym2@h
+ li r0, localSym@h
+ li r0, externalSym1@ha
+ li r0, externalSym2@ha
+ li r0, localSym@ha
+ li r0, externalSym1@l
+ li r0, externalSym2@l
+ li r0, localSym@l
+}
diff --git a/tests/make_sample_dol_alf.py b/tests/make_sample_dol_alf.py
new file mode 100644
index 0000000..4896e52
--- /dev/null
+++ b/tests/make_sample_dol_alf.py
@@ -0,0 +1,124 @@
+import dataclasses
+from pathlib import Path
+import struct
+
+
+@dataclasses.dataclass
+class Section:
+ addr: int
+ data: bytes
+ is_bss: bool = False
+
+@dataclasses.dataclass
+class Symbol:
+ mangled_name: bytes
+ demangled_name: bytes
+ addr: int
+ size: int
+ is_data: bool
+ section_id: int
+ unk_10: int
+
+def pad(data: bytes, size: int) -> bytes:
+ return data + b'\0' * (size - len(data))
+
+
+text_sections = [
+ Section(0x80000000, pad(b'.text0', 0x1000)),
+ Section(0x80001000, pad(b'.text1', 0x1000)),
+ Section(0x81000000, pad(b'.text2', 0x1000)),
+ Section(0x81001000, pad(b'.text3', 0x1000)),
+]
+data_sections = [
+ Section(0x80002000, pad(b'.data0', 0x1000)),
+ Section(0x80003000, pad(b'.data1', 0x1000)),
+ Section(0x81002000, pad(b'.data2', 0x1000)),
+ Section(0x81003000, pad(b'.data3', 0x1000)),
+]
+symbols = [
+ Symbol(b'mangled1', b'demangled1', 0x80000000, 4, False, 1, 0),
+ Symbol(b'mangled2', b'demangled2', 0x80002000, 4, True, 5, 1),
+]
+bss_section = Section(0x80008000, b'\0' * 0x1000, True)
+entrypoint = 0x80000000
+
+
+def make_dol() -> bytes:
+ dol_data = bytearray(256)
+
+ def write_header_u32(offs: int, value: int) -> None:
+ struct.pack_into('>I', dol_data, offs, value)
+
+ write_header_u32(0xd8, bss_section.addr)
+ write_header_u32(0xdc, len(bss_section.data))
+ write_header_u32(0xe0, entrypoint)
+
+ for i, sec in enumerate(text_sections):
+ sec_offset = len(dol_data)
+ dol_data += sec.data
+ assert len(dol_data) % 4 == 0
+ write_header_u32(0x00 + i * 4, sec_offset)
+ write_header_u32(0x48 + i * 4, sec.addr)
+ write_header_u32(0x90 + i * 4, len(sec.data))
+
+ for i, sec in enumerate(data_sections):
+ sec_offset = len(dol_data)
+ dol_data += sec.data
+ assert len(dol_data) % 4 == 0
+ write_header_u32(0x1c + i * 4, sec_offset)
+ write_header_u32(0x64 + i * 4, sec.addr)
+ write_header_u32(0xac + i * 4, len(sec.data))
+
+ return dol_data
+
+
+def make_alf(version: int) -> bytes:
+ alf_data = bytearray()
+
+ def write_u32(value: int) -> None:
+ nonlocal alf_data
+ alf_data += struct.pack(' None:
+ struct.pack_into(' None:
+ subprocess.run(['wine', str(MWCCEPPC_EXE), *CFLAGS, '-c', '-o', str(o_path), str(cpp_path)])
+ if not o_path.is_file():
+ raise ValueError(f'{MWCCEPPC_EXE} failed to produce {o_path}')
+
+
+def compile_s(s_path: Path, o_path: Path) -> None:
+ subprocess.run(['wine', str(MWASMEPPC_EXE), *ASMFLAGS, '-c', '-o', str(o_path), str(s_path)])
+ if not o_path.is_file():
+ raise ValueError(f'{MWASMEPPC_EXE} failed to produce {o_path}')
+
+
+def kamek_static_link(o_files: list[Path], *, static: int, externals: Path, output_dir: Path) -> None:
+ externals_arg = [f'-externals={externals}'] if externals.is_file() else []
+
+ subprocess.run(
+ [
+ str(KAMEK_EXE),
+ '-q',
+ f'-static=0x{static:08x}',
+ *externals_arg,
+ f'-output-riiv={output_dir / "output-riiv.xml"}',
+ f'-output-dolphin={output_dir / "output-dolphin.ini"}',
+ f'-output-gecko={output_dir / "output-gecko.txt"}',
+ f'-output-ar={output_dir / "output-ar.txt"}',
+ f'-output-code={output_dir / "output-code.bin"}',
+ f'-output-map={output_dir / "output-map-static.map"}',
+ f'-input-dol=sample.dol',
+ f'-output-dol={output_dir / "output-dol.dol"}',
+ f'-input-alf=sample_104.alf',
+ f'-output-alf={output_dir / "output-alf_104.alf"}',
+ *(str(o) for o in o_files),
+ ],
+ check=True,
+ )
+ subprocess.run(
+ [
+ str(KAMEK_EXE),
+ '-q',
+ f'-static=0x{static:08x}',
+ *externals_arg,
+ f'-input-alf=sample_105.alf',
+ f'-output-alf={output_dir / "output-alf_105.alf"}',
+ *(str(o) for o in o_files),
+ ],
+ check=True,
+ )
+
+
+def kamek_dynamic_link(o_files: list[Path], *, externals: Path, versions: Path, output_dir: Path) -> None:
+ externals_arg = [f'-externals={externals}'] if externals.is_file() else []
+
+ subprocess.run(
+ [
+ str(KAMEK_EXE),
+ '-q',
+ '-dynamic',
+ *externals_arg,
+ f'-versions={versions}',
+ f'-output-kamek={output_dir / "output-kamek.$KV$.bin"}',
+ f'-output-map={output_dir / "output-map-dynamic.map"}',
+ *(str(o) for o in o_files),
+ ],
+ check=True,
+ )
+
+
+def main() -> None:
+ do_bless = '--bless' in sys.argv
+
+ for test_dir in sorted(Path().iterdir()):
+ if not test_dir.is_dir():
+ continue
+ if test_dir.name.startswith('_'):
+ continue
+
+ print(f'---- {test_dir.name} ----')
+
+ bin_dir = test_dir / '_bin'
+ out_dir = test_dir / '_out'
+
+ shutil.rmtree(bin_dir, ignore_errors=True)
+ bin_dir.mkdir()
+ shutil.rmtree(out_dir, ignore_errors=True)
+ out_dir.mkdir()
+
+ o_files = []
+ for cpp_file in test_dir.glob('*.cpp'):
+ o_file = bin_dir / cpp_file.with_suffix('.o').name
+ compile_cpp(cpp_file, o_file)
+ o_files.append(o_file)
+ for s_file in test_dir.glob('*.S'):
+ o_file = bin_dir / s_file.with_suffix('.o').name
+ compile_s(s_file, o_file)
+ o_files.append(o_file)
+
+ kamek_static_link(
+ o_files,
+ static=0x82000000,
+ externals=test_dir / 'externals.txt',
+ output_dir=out_dir,
+ )
+ kamek_dynamic_link(
+ o_files,
+ externals=test_dir / 'externals.txt',
+ versions=Path('versions.txt'),
+ output_dir=out_dir,
+ )
+
+ expected_dir = test_dir / 'expected'
+
+ if do_bless:
+ shutil.rmtree(expected_dir, ignore_errors=True)
+ out_dir.rename(expected_dir)
+
+ else:
+ for expected_file in expected_dir.iterdir():
+ actual_file = out_dir / expected_file.name
+
+ if not actual_file.is_file():
+ raise ValueError(f'{actual_file} is missing')
+ if expected_file.read_bytes() != actual_file.read_bytes():
+ raise ValueError(f'{expected_file} and {actual_file} are different!')
+
+ if do_bless:
+ print('All tests blessed')
+ else:
+ print('All tests passed successfully')
+
+
+main()
diff --git a/tests/sample.dol b/tests/sample.dol
new file mode 100644
index 0000000..f52411b
Binary files /dev/null and b/tests/sample.dol differ
diff --git a/tests/sample_104.alf b/tests/sample_104.alf
new file mode 100644
index 0000000..a5968e4
Binary files /dev/null and b/tests/sample_104.alf differ
diff --git a/tests/sample_105.alf b/tests/sample_105.alf
new file mode 100644
index 0000000..b759b38
Binary files /dev/null and b/tests/sample_105.alf differ
diff --git a/tests/versions.txt b/tests/versions.txt
new file mode 100644
index 0000000..2ddfb86
--- /dev/null
+++ b/tests/versions.txt
@@ -0,0 +1,7 @@
+[Base]
+80000000-*: +0x0
+
+[V2]
+extend Base
+80000000-80ffffff: +0x0
+81000000-*: +0x1000
diff --git a/tests/writes_asm/expected/output-alf_104.alf b/tests/writes_asm/expected/output-alf_104.alf
new file mode 100644
index 0000000..1999fc1
Binary files /dev/null and b/tests/writes_asm/expected/output-alf_104.alf differ
diff --git a/tests/writes_asm/expected/output-alf_105.alf b/tests/writes_asm/expected/output-alf_105.alf
new file mode 100644
index 0000000..b775c07
Binary files /dev/null and b/tests/writes_asm/expected/output-alf_105.alf differ
diff --git a/tests/writes_asm/expected/output-ar.txt b/tests/writes_asm/expected/output-ar.txt
new file mode 100644
index 0000000..4340257
--- /dev/null
+++ b/tests/writes_asm/expected/output-ar.txt
@@ -0,0 +1,31 @@
+04000000 00000000
+0C000000 80000004
+04000000 80000008
+0C000010 80000014
+04000010 81000000
+0C000020 80000024
+04000020 82000000
+0C000030 81000000
+04000030 80000038
+0C000040 81000000
+04000040 81000000
+0C000050 81000000
+04000050 82000000
+0C000100 11111111
+04000100 22222222
+0A000110 00003333
+02000110 00004444
+08000120 00000055
+00000120 00000066
+0C000130 40F66666
+04000130 410CCCCD
+0C000140 99999999
+04000140 60000000
+04000200 80000204
+04000210 81000000
+04000220 82000000
+04000300 11111111
+02000310 00002222
+00000320 00000033
+04000330 408CCCCD
+04000340 60000000
\ No newline at end of file
diff --git a/tests/writes_asm/expected/output-code.bin b/tests/writes_asm/expected/output-code.bin
new file mode 100644
index 0000000..593f470
Binary files /dev/null and b/tests/writes_asm/expected/output-code.bin differ
diff --git a/tests/writes_asm/expected/output-dolphin.ini b/tests/writes_asm/expected/output-dolphin.ini
new file mode 100644
index 0000000..db1f04a
--- /dev/null
+++ b/tests/writes_asm/expected/output-dolphin.ini
@@ -0,0 +1,20 @@
+0x82000000:dword:0x00000000
+0x80000000:dword:0x80000008:0x80000004
+0x80000010:dword:0x81000000:0x80000014
+0x80000020:dword:0x82000000:0x80000024
+0x80000030:dword:0x80000038:0x81000000
+0x80000040:dword:0x81000000:0x81000000
+0x80000050:dword:0x82000000:0x81000000
+0x80000100:dword:0x22222222:0x11111111
+0x80000110:word:0x00004444:0x00003333
+0x80000120:byte:0x00000066:0x00000055
+0x80000130:dword:0x410CCCCD:0x40F66666
+0x80000140:dword:0x60000000:0x99999999
+0x80000200:dword:0x80000204
+0x80000210:dword:0x81000000
+0x80000220:dword:0x82000000
+0x80000300:dword:0x11111111
+0x80000310:word:0x00002222
+0x80000320:byte:0x00000033
+0x80000330:dword:0x408CCCCD
+0x80000340:dword:0x60000000
\ No newline at end of file
diff --git a/tests/writes_asm/expected/output-gecko.txt b/tests/writes_asm/expected/output-gecko.txt
new file mode 100644
index 0000000..0ad4379
--- /dev/null
+++ b/tests/writes_asm/expected/output-gecko.txt
@@ -0,0 +1,45 @@
+06000000 00000008
+00000000 00000000
+20000000 80000004
+04000000 80000008
+E2000001 00000000
+20000010 80000014
+04000010 81000000
+E2000001 00000000
+20000020 80000024
+04000020 82000000
+E2000001 00000000
+20000030 81000000
+04000030 80000038
+E2000001 00000000
+20000040 81000000
+04000040 81000000
+E2000001 00000000
+20000050 81000000
+04000050 82000000
+E2000001 00000000
+20000100 11111111
+04000100 22222222
+E2000001 00000000
+28000110 00003333
+02000110 00004444
+E2000001 00000000
+C0000000 00000004
+3C608000 60630120
+88030000 2C000055
+4082000C 38000066
+98030000 4E800020
+20000130 40F66666
+04000130 410CCCCD
+E2000001 00000000
+20000140 99999999
+04000140 60000000
+E2000001 00000000
+04000200 80000204
+04000210 81000000
+04000220 82000000
+04000300 11111111
+02000310 00002222
+00000320 00000033
+04000330 408CCCCD
+04000340 60000000
\ No newline at end of file
diff --git a/tests/writes_asm/expected/output-kamek.Base.bin b/tests/writes_asm/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..9bf9c71
Binary files /dev/null and b/tests/writes_asm/expected/output-kamek.Base.bin differ
diff --git a/tests/writes_asm/expected/output-kamek.V2.bin b/tests/writes_asm/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..8f849b5
Binary files /dev/null and b/tests/writes_asm/expected/output-kamek.V2.bin differ
diff --git a/tests/writes_asm/expected/output-map-dynamic.map b/tests/writes_asm/expected/output-map-dynamic.map
new file mode 100644
index 0000000..e9d7ae6
--- /dev/null
+++ b/tests/writes_asm/expected/output-map-dynamic.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000004 000000 __ctor_loc
+ 00000004 000000 __ctor_end
+ 00000004 000000 _e_text
+ 00000004 000000 _f_ctors
+ 00000004 000000 _e_ctors
+ 00000004 000000 _f_dtors
+ 00000004 000000 _e_dtors
+ 00000004 000000 _f_rodata
+ 00000004 000000 _e_rodata
+ 00000004 000000 _f_data
+ 00000004 000000 _e_data
diff --git a/tests/writes_asm/expected/output-map-static.map b/tests/writes_asm/expected/output-map-static.map
new file mode 100644
index 0000000..bf756ba
--- /dev/null
+++ b/tests/writes_asm/expected/output-map-static.map
@@ -0,0 +1,16 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000004 000000 __ctor_loc
+ 82000004 000000 __ctor_end
+ 82000004 000000 _e_text
+ 82000004 000000 _f_ctors
+ 82000004 000000 _e_ctors
+ 82000004 000000 _f_dtors
+ 82000004 000000 _e_dtors
+ 82000004 000000 _f_rodata
+ 82000004 000000 _e_rodata
+ 82000004 000000 _f_data
+ 82000004 000000 _e_data
diff --git a/tests/writes_asm/expected/output-riiv.xml b/tests/writes_asm/expected/output-riiv.xml
new file mode 100644
index 0000000..4d9eb32
--- /dev/null
+++ b/tests/writes_asm/expected/output-riiv.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/writes_asm/externals.txt b/tests/writes_asm/externals.txt
new file mode 100644
index 0000000..f1fe089
--- /dev/null
+++ b/tests/writes_asm/externals.txt
@@ -0,0 +1 @@
+externalSym=0x81000000
diff --git a/tests/writes_asm/test.S b/tests/writes_asm/test.S
new file mode 100644
index 0000000..7d5d4e9
--- /dev/null
+++ b/tests/writes_asm/test.S
@@ -0,0 +1,27 @@
+#include
+
+.extern externalSym
+localSym: .long 0
+
+kmCondWritePointer 0x80000000, 0x80000004, 0x80000008
+kmCondWritePointer 0x80000010, 0x80000014, externalSym
+kmCondWritePointer 0x80000020, 0x80000024, localSym
+kmCondWritePointer 0x80000030, externalSym, 0x80000038
+kmCondWritePointer 0x80000040, externalSym, externalSym
+kmCondWritePointer 0x80000050, externalSym, localSym
+
+kmCondWrite32 0x80000100, 0x11111111, 0x22222222
+kmCondWrite16 0x80000110, 0x3333, 0x4444
+kmCondWrite8 0x80000120, 0x55, 0x66
+kmCondWriteFloat 0x80000130, 7.7, 8.8
+kmCondWriteNop 0x80000140, 0x99999999
+
+kmWritePointer 0x80000200, 0x80000204
+kmWritePointer 0x80000210, externalSym
+kmWritePointer 0x80000220, localSym
+
+kmWrite32 0x80000300, 0x11111111
+kmWrite16 0x80000310, 0x2222
+kmWrite8 0x80000320, 0x33
+kmWriteFloat 0x80000330, 4.4
+kmWriteNop 0x80000340
diff --git a/tests/writes_cpp/expected/output-alf_104.alf b/tests/writes_cpp/expected/output-alf_104.alf
new file mode 100644
index 0000000..c71e9bf
Binary files /dev/null and b/tests/writes_cpp/expected/output-alf_104.alf differ
diff --git a/tests/writes_cpp/expected/output-alf_105.alf b/tests/writes_cpp/expected/output-alf_105.alf
new file mode 100644
index 0000000..b9e6213
Binary files /dev/null and b/tests/writes_cpp/expected/output-alf_105.alf differ
diff --git a/tests/writes_cpp/expected/output-ar.txt b/tests/writes_cpp/expected/output-ar.txt
new file mode 100644
index 0000000..c37c22c
--- /dev/null
+++ b/tests/writes_cpp/expected/output-ar.txt
@@ -0,0 +1,30 @@
+0C000000 80000004
+04000000 80000008
+0C000010 80000014
+04000010 81000000
+0C000020 80000024
+04000020 82000000
+0C000030 81000000
+04000030 80000038
+0C000040 81000000
+04000040 81000000
+0C000050 81000000
+04000050 82000000
+0C000100 11111111
+04000100 22222222
+0A000110 00003333
+02000110 00004444
+08000120 00000055
+00000120 00000066
+0C000130 40F66666
+04000130 410CCCCD
+0C000140 99999999
+04000140 60000000
+04000200 80000204
+04000210 81000000
+04000220 82000000
+04000300 11111111
+02000310 00002222
+00000320 00000033
+04000330 408CCCCD
+04000340 60000000
\ No newline at end of file
diff --git a/tests/writes_cpp/expected/output-code.bin b/tests/writes_cpp/expected/output-code.bin
new file mode 100644
index 0000000..e69de29
diff --git a/tests/writes_cpp/expected/output-dolphin.ini b/tests/writes_cpp/expected/output-dolphin.ini
new file mode 100644
index 0000000..dc393b7
--- /dev/null
+++ b/tests/writes_cpp/expected/output-dolphin.ini
@@ -0,0 +1,19 @@
+0x80000000:dword:0x80000008:0x80000004
+0x80000010:dword:0x81000000:0x80000014
+0x80000020:dword:0x82000000:0x80000024
+0x80000030:dword:0x80000038:0x81000000
+0x80000040:dword:0x81000000:0x81000000
+0x80000050:dword:0x82000000:0x81000000
+0x80000100:dword:0x22222222:0x11111111
+0x80000110:word:0x00004444:0x00003333
+0x80000120:byte:0x00000066:0x00000055
+0x80000130:dword:0x410CCCCD:0x40F66666
+0x80000140:dword:0x60000000:0x99999999
+0x80000200:dword:0x80000204
+0x80000210:dword:0x81000000
+0x80000220:dword:0x82000000
+0x80000300:dword:0x11111111
+0x80000310:word:0x00002222
+0x80000320:byte:0x00000033
+0x80000330:dword:0x408CCCCD
+0x80000340:dword:0x60000000
\ No newline at end of file
diff --git a/tests/writes_cpp/expected/output-gecko.txt b/tests/writes_cpp/expected/output-gecko.txt
new file mode 100644
index 0000000..6205432
--- /dev/null
+++ b/tests/writes_cpp/expected/output-gecko.txt
@@ -0,0 +1,43 @@
+20000000 80000004
+04000000 80000008
+E2000001 00000000
+20000010 80000014
+04000010 81000000
+E2000001 00000000
+20000020 80000024
+04000020 82000000
+E2000001 00000000
+20000030 81000000
+04000030 80000038
+E2000001 00000000
+20000040 81000000
+04000040 81000000
+E2000001 00000000
+20000050 81000000
+04000050 82000000
+E2000001 00000000
+20000100 11111111
+04000100 22222222
+E2000001 00000000
+28000110 00003333
+02000110 00004444
+E2000001 00000000
+C0000000 00000004
+3C608000 60630120
+88030000 2C000055
+4082000C 38000066
+98030000 4E800020
+20000130 40F66666
+04000130 410CCCCD
+E2000001 00000000
+20000140 99999999
+04000140 60000000
+E2000001 00000000
+04000200 80000204
+04000210 81000000
+04000220 82000000
+04000300 11111111
+02000310 00002222
+00000320 00000033
+04000330 408CCCCD
+04000340 60000000
\ No newline at end of file
diff --git a/tests/writes_cpp/expected/output-kamek.Base.bin b/tests/writes_cpp/expected/output-kamek.Base.bin
new file mode 100644
index 0000000..f9b8556
Binary files /dev/null and b/tests/writes_cpp/expected/output-kamek.Base.bin differ
diff --git a/tests/writes_cpp/expected/output-kamek.V2.bin b/tests/writes_cpp/expected/output-kamek.V2.bin
new file mode 100644
index 0000000..076e6df
Binary files /dev/null and b/tests/writes_cpp/expected/output-kamek.V2.bin differ
diff --git a/tests/writes_cpp/expected/output-map-dynamic.map b/tests/writes_cpp/expected/output-map-dynamic.map
new file mode 100644
index 0000000..dd8b8d4
--- /dev/null
+++ b/tests/writes_cpp/expected/output-map-dynamic.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 00000000 000000 __ctor_loc
+ 00000000 000000 __ctor_end
+ 00000000 000000 _f_init
+ 00000000 000000 _e_init
+ 00000000 000000 _f_text
+ 00000000 000000 _e_text
+ 00000000 000000 _f_ctors
+ 00000000 000000 _e_ctors
+ 00000000 000000 _f_dtors
+ 00000000 000000 _e_dtors
+ 00000000 000000 _f_rodata
+ 00000000 000000 _e_rodata
+ 00000000 000000 _f_data
+ 00000000 000000 _e_data
+ 00000000 000004 localSym
diff --git a/tests/writes_cpp/expected/output-map-static.map b/tests/writes_cpp/expected/output-map-static.map
new file mode 100644
index 0000000..b030be5
--- /dev/null
+++ b/tests/writes_cpp/expected/output-map-static.map
@@ -0,0 +1,17 @@
+Kamek Binary Map
+ Offset Size Name
+ 82000000 000000 __ctor_loc
+ 82000000 000000 __ctor_end
+ 82000000 000000 _f_init
+ 82000000 000000 _e_init
+ 82000000 000000 _f_text
+ 82000000 000000 _e_text
+ 82000000 000000 _f_ctors
+ 82000000 000000 _e_ctors
+ 82000000 000000 _f_dtors
+ 82000000 000000 _e_dtors
+ 82000000 000000 _f_rodata
+ 82000000 000000 _e_rodata
+ 82000000 000000 _f_data
+ 82000000 000000 _e_data
+ 82000000 000004 localSym
diff --git a/tests/writes_cpp/expected/output-riiv.xml b/tests/writes_cpp/expected/output-riiv.xml
new file mode 100644
index 0000000..8169f32
--- /dev/null
+++ b/tests/writes_cpp/expected/output-riiv.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/writes_cpp/externals.txt b/tests/writes_cpp/externals.txt
new file mode 100644
index 0000000..f1fe089
--- /dev/null
+++ b/tests/writes_cpp/externals.txt
@@ -0,0 +1 @@
+externalSym=0x81000000
diff --git a/tests/writes_cpp/test.cpp b/tests/writes_cpp/test.cpp
new file mode 100644
index 0000000..d6cd6f2
--- /dev/null
+++ b/tests/writes_cpp/test.cpp
@@ -0,0 +1,27 @@
+#include
+
+extern int externalSym;
+int localSym;
+
+kmCondWritePointer(0x80000000, 0x80000004, 0x80000008);
+kmCondWritePointer(0x80000010, 0x80000014, &externalSym);
+kmCondWritePointer(0x80000020, 0x80000024, &localSym);
+kmCondWritePointer(0x80000030, &externalSym, 0x80000038);
+kmCondWritePointer(0x80000040, &externalSym, &externalSym);
+kmCondWritePointer(0x80000050, &externalSym, &localSym);
+
+kmCondWrite32(0x80000100, 0x11111111, 0x22222222);
+kmCondWrite16(0x80000110, 0x3333, 0x4444);
+kmCondWrite8(0x80000120, 0x55, 0x66);
+kmCondWriteFloat(0x80000130, 7.7f, 8.8f);
+kmCondWriteNop(0x80000140, 0x99999999);
+
+kmWritePointer(0x80000200, 0x80000204);
+kmWritePointer(0x80000210, &externalSym);
+kmWritePointer(0x80000220, &localSym);
+
+kmWrite32(0x80000300, 0x11111111);
+kmWrite16(0x80000310, 0x2222);
+kmWrite8(0x80000320, 0x33);
+kmWriteFloat(0x80000330, 4.4f);
+kmWriteNop(0x80000340);