summaryrefslogtreecommitdiff
path: root/tests/fixtures/hll
diff options
context:
space:
mode:
authorkx <kx@radix-linux.su>2026-10-09 18:00:15 +0300
committerkx <kx@radix-linux.su>2026-10-09 18:00:15 +0300
commit065da3509019b15dd0e678072e6be629e5330bef (patch)
tree69c934c9e786ac048b4fbe8f4c4c5571661521f4 /tests/fixtures/hll
parentd130fe27fa753be02ed76fd9b277aa3c3d928eb9 (diff)
downloadlibmcpu-0.4.0.tar.xz
Version 0.4.00.4.0
Diffstat (limited to 'tests/fixtures/hll')
-rw-r--r--tests/fixtures/hll/libc-stub.S42
-rw-r--r--tests/fixtures/hll/model-pendulum-life.S133
-rw-r--r--tests/fixtures/hll/program-main.S48
3 files changed, 223 insertions, 0 deletions
diff --git a/tests/fixtures/hll/libc-stub.S b/tests/fixtures/hll/libc-stub.S
new file mode 100644
index 0000000..d4fd878
--- /dev/null
+++ b/tests/fixtures/hll/libc-stub.S
@@ -0,0 +1,42 @@
+; Test/development MCPU Libc emulator.
+;
+; This source is NEVER installed. The register marker is intentionally a
+; testing convention only; it is not part of the CRT <-> MCPU Libc ABI.
+
+.global __mcpu_libc_init
+.global __mcpu_init_array
+.global __mcpu_fini_array
+.global __mcpu_libc_fini
+
+.text
+__mcpu_libc_init:
+ CLR r64@0x70008
+ ICMP r64@0x70000, r64@0x70008
+ JNZ .L_stub_bad
+ LDI r64@0x70000, 1
+ RET
+
+__mcpu_init_array:
+ LDI r64@0x70008, 1
+ ICMP r64@0x70000, r64@0x70008
+ JNZ .L_stub_bad
+ LDI r64@0x70000, 2
+ RET
+
+__mcpu_fini_array:
+ LDI r64@0x70008, 4
+ ICMP r64@0x70000, r64@0x70008
+ JNZ .L_stub_bad
+ LDI r64@0x70000, 5
+ RET
+
+__mcpu_libc_fini:
+ LDI r64@0x70008, 5
+ ICMP r64@0x70000, r64@0x70008
+ JNZ .L_stub_bad
+ LDI r64@0x70000, 6
+ RET
+
+.L_stub_bad:
+ LDI r64@0x70000, 999
+ RET
diff --git a/tests/fixtures/hll/model-pendulum-life.S b/tests/fixtures/hll/model-pendulum-life.S
new file mode 100644
index 0000000..5ad6ddb
--- /dev/null
+++ b/tests/fixtures/hll/model-pendulum-life.S
@@ -0,0 +1,133 @@
+; Assembler emulator of future mcpu-cc MODEL output.
+;
+; The lifecycle shape is a compact pendulum-style MODEL regression fixture.
+; INIT snapshots CONTROL
+; into DATA, LIFE advances one model step and publishes one TRACE frame, and
+; fini() marks graceful model finalization.
+;
+; This reduced fixture tests the HLL MODEL/CRT protocol, not RK4 numerics.
+
+.global init
+.global life
+.global fini
+
+.control
+.align 8
+control_n:
+ .integer 64, 3
+control_error_step:
+ .integer 64, 0
+
+.data
+.align 8
+model_n:
+ .integer 64, 0
+model_error_step:
+ .integer 64, 0
+model_step:
+ .integer 64, 0
+model_fini_marker:
+ .integer 64, 0
+
+.trace
+.align 8
+trace_step:
+ .integer 64, 0
+
+.text
+; int32 init(int64 argc, PTR64 argv)
+init:
+ LDI r64@0x70200, 2
+ ICMP r64@0x70000, r64@0x70200
+ JNZ .L_init_bad_order
+
+ ; The test invokes the MODEL without extra arguments.
+ LDSP r64@0x70208, 8
+ LDI r64@0x70210, 1
+ ICMP r64@0x70208, r64@0x70210
+ JNZ .L_init_bad_args
+
+ ; Negative CONTROL.n deliberately requests an init failure.
+ LEA r64@0x70218, control_n
+ LOADP r64@0x70220, r64@0x70218
+ CLR r64@0x70228
+ ICMP r64@0x70220, r64@0x70228
+ JS .L_init_fail
+
+ STORE model_n, r64@0x70220
+ LEA r64@0x70218, control_error_step
+ LOADP r64@0x70230, r64@0x70218
+ STORE model_error_step, r64@0x70230
+
+ CLR r64@0x70238
+ STORE model_step, r64@0x70238
+ STORE model_fini_marker, r64@0x70238
+
+ LDI r64@0x70000, 3
+ CLR r32@0x7fffc
+ RET
+
+.L_init_fail:
+ LDI r64@0x70000, 3
+ LDI r32@0x7fffc, 17
+ RET
+
+.L_init_bad_order:
+ LDI r64@0x70000, 910
+ LDI r32@0x7fffc, 18
+ RET
+
+.L_init_bad_args:
+ LDI r64@0x70000, 911
+ LDI r32@0x7fffc, 19
+ RET
+
+; int32 life(void)
+life:
+ LOAD r64@0x70300, model_step
+ LDI r64@0x70308, 1
+ IADD r64@0x70300, r64@0x70300, r64@0x70308
+ STORE model_step, r64@0x70300
+
+ ; Optional positive LIFE error requested by CONTROL.error_step.
+ LOAD r64@0x70310, model_error_step
+ CLR r64@0x70318
+ ICMP r64@0x70310, r64@0x70318
+ JZ .L_no_life_error
+ ICMP r64@0x70300, r64@0x70310
+ JNZ .L_no_life_error
+ LDI r32@0x7fffc, 9
+ RET
+
+.L_no_life_error:
+ ; Pendulum-style sequential stop: step == n + 1 means natural end.
+ LOAD r64@0x70320, model_n
+ IADD r64@0x70328, r64@0x70320, r64@0x70308
+ ICMP r64@0x70300, r64@0x70328
+ JZ .L_life_end
+
+ LEA r64@0x70330, trace_step
+ STOREP r64@0x70330, r64@0x70300
+
+ ; LIFE_CONTINUE == INT32_MIN.
+ LDI r32@0x7fffc, -2147483648
+ RET
+
+.L_life_end:
+ CLR r32@0x7fffc
+ RET
+
+fini:
+ LDI r64@0x70200, 3
+ ICMP r64@0x70000, r64@0x70200
+ JNZ .L_model_fini_bad
+
+ LDI r64@0x70000, 4
+ LDI r64@0x70208, 1
+ STORE model_fini_marker, r64@0x70208
+ MOV r64@0x70010, r64@0x70208
+ RET
+
+.L_model_fini_bad:
+ LDI r64@0x70000, 912
+ RET
diff --git a/tests/fixtures/hll/program-main.S b/tests/fixtures/hll/program-main.S
new file mode 100644
index 0000000..3161343
--- /dev/null
+++ b/tests/fixtures/hll/program-main.S
@@ -0,0 +1,48 @@
+; Assembler emulator of future mcpu-cc PROGRAM output.
+;
+; It intentionally defines only main() and fini(); lifecycle symbols belong
+; to CRT and must be inserted automatically by mcpu-ld.
+
+.global main
+.global fini
+
+.text
+main:
+ ; Startup hooks must already have completed.
+ LDI r64@0x70100, 2
+ ICMP r64@0x70000, r64@0x70100
+ JNZ .L_main_bad
+
+ ; argc must include argv[0] plus the two test arguments.
+ LDSP r64@0x70108, 8
+ LDI r64@0x70110, 3
+ ICMP r64@0x70108, r64@0x70110
+ JNZ .L_main_bad
+
+ ; argv[argc] is the required NULL terminator.
+ LDSP r64@0x70118, 16
+ PADDI r64@0x70120, r64@0x70118, 24
+ LOADP r64@0x70128, r64@0x70120
+ CLR r64@0x70130
+ ICMP r64@0x70128, r64@0x70130
+ JNZ .L_main_bad
+
+ LDI r64@0x70000, 3
+ LDI r32@0x7fffc, 42
+ RET
+
+.L_main_bad:
+ LDI r64@0x70000, 900
+ LDI r32@0x7fffc, 43
+ RET
+
+fini:
+ LDI r64@0x70100, 3
+ ICMP r64@0x70000, r64@0x70100
+ JNZ .L_fini_bad
+ LDI r64@0x70000, 4
+ RET
+
+.L_fini_bad:
+ LDI r64@0x70000, 901
+ RET