blob: bfc99654f0e82e7b7cdab38fa6023bd85dd4f20a (
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
|
; Build/run from examples/:
; ../utils/mcpu-as -o call.o call.s
; ../utils/mcpu-ld --stack-size=128 -o call call.o
; ../utils/mcpu-run --int-reg=r64@0x00010 call
;
; Expected output: 33
;
; LibCPU CALL ABI example.
;
; add2(a,b): this two-r64 argument block is exactly 16 bytes, so the
; traditional right-to-left PUSH sequence also satisfies the formal ABI.
; CALL then pushes
; the 64-bit return PC, therefore on callee entry:
; SP+0 = return address
; SP+8 = first argument a
; SP+16 = second argument b
;
; Before CALL, SP is 16-byte aligned. The r64 result is returned in the canonical ABI return view
; r64@0x7fff8. The caller removes its own arguments with ADJSP.
.text
_start_life:
LDI r64@0x00000, 11
LDI r64@0x00008, 22
PUSH r64@0x00008 ; second/rightmost argument b
PUSH r64@0x00000 ; first/leftmost argument a
CALL add2
ADJSP 16 ; caller cleanup
MOV r64@0x00010, r64@0x7fff8
HALT
add2:
LDSP r64@0x00100, 8 ; a
LDSP r64@0x00108, 16 ; b
IADD r64@0x7fff8, r64@0x00100, r64@0x00108
RET
|