stupid questions about PASM2

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?

I am just another Code Monkey.
A determined coder can write COBOL programs in any language. -- Author unknown.
Press any key to continue, any other key to quit

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.

Comments

  • I wish! It's the other way around.
    We have the vastness of the internet and yet billions of people decided to spend most of their time within a horribly designed, fake-news emporium of a website that sucks every possible piece of personal information out of you so it can sell it to others. And they see nothing wrong with that.
  • shhhh., I thought I read it somewhere,

    so after a RET I get the flags from the sub, right? What you mean by 'other way around'?

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • I can't use _RET_ and have it preserve the calling flags so that conditional execution works across calls. I have to use RET WCZ instead.
    We have the vastness of the internet and yet billions of people decided to spend most of their time within a horribly designed, fake-news emporium of a website that sucks every possible piece of personal information out of you so it can sell it to others. And they see nothing wrong with that.
  • so _ret_ or RET will return the changed flags but RET WCZ will preserve them and restore the flags to the point of the call?

    curious,

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • There are two cases you need to consider.

    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.
    My Prop boards: P8XBlade2 , RamBlade , CpuBlade , TriBlade
    P1 Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    P1: Tools (Index) , Emulators (Index) , ZiCog (Z80)
    P2: Tools & Code , Tricks & Traps
  • thank you @Cluso99 that is a useful explanation.

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
Sign In or Register to comment.