stupid questions about PASM2
msrobots
Posts: 3,709
in Propeller 2
OK the first one
Am I correct that call...ret does NOT return the state of Z or C but preserves the one outside the call unless I do RET WC WZ?
Am I correct that call...ret does NOT return the state of Z or C but preserves the one outside the call unless I do RET WC WZ?
Comments
so after a RET I get the flags from the sub, right? What you mean by 'other way around'?
Enjoy!
Mike
curious,
Mike
1. A subroutine wants to return any flags it changes to the calling routine.
eg: on return I set/clear Z &/or C flags to pass results of the subroutine, so Z might be passed/success where NZ is fail/error
2. A subroutine needs to use flags but the calling program does not want them changed.
Both of these methods have their advantages and disadvantages.
The P1 always uses 1. above. If 2. is required, then the subroutine needs to save the flags on entry, and restore them before returning.
On the P2...
1. works with
_RET_ <opcode> <operands>
and
RET
2. works only with
RET {wc/wz/wcz} where the Z &/or C is preserved only if the modifier is used.
Enjoy!
Mike