summaryrefslogtreecommitdiff
path: root/tests/fixtures/hll/program-main.S
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fixtures/hll/program-main.S')
-rw-r--r--tests/fixtures/hll/program-main.S48
1 files changed, 48 insertions, 0 deletions
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