summaryrefslogtreecommitdiff
path: root/tests/fixtures/model-lifecycle.s
blob: 4c190d5573b1557135a35cf8c83f5616cdbd53fa (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
49
50
51
52
53
; Build from examples/:
;   ../utils/mcpu-as -o model-lifecycle.o model-lifecycle.s
;   ../utils/mcpu-ld --stack-size=512 -o model-lifecycle model-lifecycle.o
;
; Run one INIT-only pass or one LIFE step:
;   ../utils/mcpu-run --init-only --int-reg=r64@0x00000 model-lifecycle
;   ../utils/mcpu-run --steps=1 --int-reg=r64@0x00000 model-lifecycle
;
; Expected outputs: 40 and 42 respectively.
;
; LibCPU lifecycle/model-segment example.
; cpu-run --steps=1 --int-reg=r64@0x00000 model-lifecycle  -> 42
; cpu-run --init-only --int-reg=r64@0x00000 model-lifecycle -> 40

.control
model_step:
        .real 64, 1.0

.input
external_delta:
        .integer 64, 2

.output
current_state:
        .integer 64, 0

.trace
telemetry_state:
        .integer 64, 0

.init
_start:
        LDI     r64@0x00000, 40
        END

.text
_life:
loop:
        LEA     r64@0x00008, external_delta
        LOADP   r64@0x00010, r64@0x00008
        IADD    r64@0x00000, r64@0x00000, r64@0x00010

        LEA     r64@0x00018, current_state
        STOREP  r64@0x00018, r64@0x00000
        LEA     r64@0x00020, telemetry_state
        STOREP  r64@0x00020, r64@0x00000

        END
        JMP     loop

.fini
_fini:
        END