blob: 9b45785045ac2613ae4437b52c5cf044701ddf47 (
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
|
; STACK instruction example.
;
; Build/run from examples/:
; ../utils/mcpu-as -o stack.o stack.s
; ../utils/mcpu-ld --stack-size=128 -o stack stack.o
; ../utils/mcpu-run --int-reg=r64@0x00028 stack
;
; Expected output: 22
;
.text
_start_life:
LDI r64@0x00000, 11
LDI r64@0x00008, 22
; STACK grows downward. cpu-run initializes SP to stack_size.
PUSH r64@0x00000
PUSH r64@0x00008
; Current stack top contains 22, SP+8 contains 11.
LDSP r64@0x00010, 8
STSP 0, r64@0x00000
POP r64@0x00018
POP r64@0x00020
; Reserve a 16-byte local frame without automatic padding.
ADJSP -16
STSP 0, r64@0x00008
LDSP r64@0x00028, 0
ADJSP 16
HALT
|