Shop OBEX P1 Docs P2 Docs Learn Events
CALL WC, WZ — Parallax Forums

CALL WC, WZ

The latest instructions.txt indicate that the WC and WZ effects are available for CALL. However, PNUT disallows their use. Should they be allowed? And, if so, what do they do in the context of a CALL?

Also, to verify, if you include WC and/or WZ on RET, does that restore C and/or Z from the value popped off the stack?

Comments

  • I'm seeing an issue with RET WC,WZ
    The returned flags appear to be transposed.
    dat		orgh	0
    		org
    
    		or	dirb,#$ff	
    
    		setcz	#%10 wc,wz	'show original flags
    		setbz	outb,#0
    		setbc	outb,#1
    
    		call	#oz
    		setbz	outb,#2		'show returned flags
    		setbc	outb,#3
    
    me		jmp	#me
    
    oz		setcz	#%11 wc,wz	'force flags
    		ret	wc,wz
    

  • cgraceycgracey Posts: 14,134
    CALL reg WC,WZ

    ...works, because the register can supply C and Z, but this is not the case in the 20-bit constant version.
  • From the BOTONE thread:
    ozpropdev wrote: »
    @seairth
    Are you using RET WC,WZ in your test code.
    I'm seeing an issue here that might explain your strange results.

    That might have been it! I had actually modified your test snippet to print C and Z after Val. I was relying on RET WC,WZ to restore the C/Z values from before CALL. In a later version, I ended up just storing C and Z separately, then restoring it explicitly with SETCZ.

    I did verify that the C and Z fields are being set in the binary, so it appears there is something else going on...
  • cgracey wrote: »
    CALL reg WC,WZ

    ...works, because the register can supply C and Z, but this is not the case in the 20-bit constant version.

    Oh. Good point. I wasn't using the CALL D form. :P
Sign In or Register to comment.