summaryrefslogtreecommitdiff
path: root/tests/fixtures/hll/program-main.S
blob: 31613437262b805d1f6ec2c707b26185f9a15f7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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