CALL / RET flags preserve
Time for another explanation:
The documentation say that CALL pushes C and Z into stack along with address, and RET pops them back, however if you run this code, it seems that the flags are not preserved:
mov t1, #$08 cmp t1, #$08 wz ' Z=1 if_z call #func ' reset Z ? if_z mov t1, #$FF if_nz mov t1, #$00 debug(uhex_byte(t1)) jmp #$ func cmp t1, #$FF wz ' Z=0 ret t1 long 0
It should set t1=$FF but it is $00 meaning that Z is reset by the called function. To prove it, comment the wz effect on the func row, and the assignment is correct.
Also have some doubt about
_ret_ because while the description for
ret(instruction) say that the flags are restored (but apparently not), the description for
_ret_ (prefix) does not!
What I'm missing ?