blob: 3dccab3fe0dd3ff73c38203ca0d63796989bc888 (
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
|
; PSW volatility across the CALL ABI example.
;
; Build/run from examples/:
; ../utils/mcpu-as -o psw-call-abi.o psw-call-abi.s
; ../utils/mcpu-ld --stack-size=512 -o psw-call-abi psw-call-abi.o
; ../utils/mcpu-run --int-reg=r64@0x00010 psw-call-abi
;
; Expected output: 42
;
.text
_start_life:
; Establish ZF=1 before the call: -1 + 1 -> 0 in signed r8.
LDI r8@0x00000, -1
LDI r8@0x00001, 1
IADD r8@0x00002, r8@0x00000, r8@0x00001
; CALL itself preserves PSW, but the callee is free to clobber
; PSW[15:0]. This function deliberately clears ZF with 1 + 1.
CALL clobber_status
; The old ZF is not part of the calling convention. Observe the
; callee-produced ZF=0 and report 42.
JNZ status_is_volatile
LDI r64@0x00010, 99
HALT
clobber_status:
LDI r8@0x00003, 1
LDI r8@0x00004, 1
IADD r8@0x00005, r8@0x00003, r8@0x00004
RET
status_is_volatile:
LDI r64@0x00010, 42
HALT
|