; 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