Questions about the P2 instrution set for anyone but Chip

124»

Comments

  • I wanted to focus on the offending code.

    Here is the complete code... I think it is failing hardware, but I have thought that before.
    The story is I spent a couple of days soldering a couple of LaserPings to a slip ring and mounting the thing to a Parallax feedback 360 servo... assuming that the code would be a no brainer... first I couldn't get the smart pins to cooperate.. then I couldn't get the edge detectors to cooperate... and now I am reduced to this:) The idea is that when you make momentary contact with 3.3v... the moment is spit out to serial, with the first clock and the total period reported AND the LED lights up during contact... this actually does work!!! But seeing that LED stay dimly lit has me befuzzled.
  • The code snippet starts around line 74
  • ok... I see it... thanks.
  • looked at it for two ....ing days... Lordy
  • Questions...

    I presume that this is invalid
        _ret_   call     #label
    
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Thinking some more...
    It would just require the verilog to NOT push the new return address onto the stack. I wonder if Chip thought about this?
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • how about doing a JMP instead of _RET_ CALL.....?

    there is probably a ret at the end of the code of label?

    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.
  • Cluso99 wrote: »
    Questions...

    I presume that this is invalid
        _ret_   call     #label
    

    The _RET_ only executes if not preempted by a branch. This means that '_RET_ DJNZ X,#loop' will only RETurn when the looping is done. In your example, the CALL would always take precedence over the _RET_.
  • Peter JakackiPeter Jakacki Posts: 7,816
    edited May 11 Vote Up0Vote Down
    Now here's another one. I've been setting the carry with "modc 1 wc" but I'm told it should be "modc %1111 wc" however this test with MODZ says only the lsb is used.

    First, the test word in TAQOZ which is simply called MODZ at the high level.
    ' MODZ ( n -- set ) 
    _MODZ			altd	tos,#0
    			modz	0 wz
    			mov	tos,#0
    		if_z	mov	tos,#1
    			ret
    
    
    So it will return a 1 if the z is set.
    Now the test....
    TAQOZ# 0 16 ADO CRLF I .B SPACE I MODZ . LOOP  
    $00 0
    $01 1
    $02 0
    $03 1
    $04 0
    $05 1
    $06 0
    $07 1
    $08 0
    $09 1
    $0A 0
    $0B 1
    $0C 0
    $0D 1
    $0E 0
    $0F 1 ok
    
    Only the lsb was recognized.

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Latest binary V5.4 includes EASYFILE +++++ Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET +++++ TAQOZ documentation
    Brisbane, Australia
  • Now here's another one. I've been setting the carry with "modc 1 wc" but I'm told it should be "modc %1111 wc" however this test with MODZ says only the lsb is used.

    First, the test word in TAQOZ which is simply called MODZ at the high level.
    ' MODZ ( n -- set ) 
    _MODZ			altd	tos,#0
    			modz	0 wz
    			mov	tos,#0
    		if_z	mov	tos,#1
    			ret
    
    
    So it will return a 1 if the z is set.
    Now the test....
    TAQOZ# 0 16 ADO CRLF I .B SPACE I MODZ . LOOP  
    $00 0
    $01 1
    $02 0
    $03 1
    $04 0
    $05 1
    $06 0
    $07 1
    $08 0
    $09 1
    $0A 0
    $0B 1
    $0C 0
    $0D 1
    $0E 0
    $0F 1 ok
    
    Only the lsb was recognized.

    Using %0001 means z = !c & !z.
  • Ahhh, so it does...
    TAQOZ# 1 MODZ . 0 ok
    TAQOZ# 1 MODZ . 0 ok
    TAQOZ# 1 MODZ 1 MODZ . 1 ok
    TAQOZ# 1 MODZ 1 MODZ 1 MODZ . 0 ok
    

    But that's kinda scary that we are using all these instructions that haven't been documented yet!

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Latest binary V5.4 includes EASYFILE +++++ Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET +++++ TAQOZ documentation
    Brisbane, Australia
  • From "instructions_v32.txt"
    ---------------
    MODCZ constants
    ---------------
    
    _CLR                    =       %0000
    _NC_AND_NZ              =       %0001
    _NZ_AND_NC              =       %0001
    _GT                     =       %0001
    _NC_AND_Z               =       %0010
    _Z_AND_NC               =       %0010
    _NC                     =       %0011
    _GE                     =       %0011
    _C_AND_NZ               =       %0100
    _NZ_AND_C               =       %0100
    _NZ                     =       %0101
    _NE                     =       %0101
    _C_NE_Z                 =       %0110
    _Z_NE_C                 =       %0110
    _NC_OR_NZ               =       %0111
    _NZ_OR_NC               =       %0111
    _C_AND_Z                =       %1000
    _Z_AND_C                =       %1000
    _C_EQ_Z                 =       %1001
    _Z_EQ_C                 =       %1001
    _Z                      =       %1010
    _E                      =       %1010
    _NC_OR_Z                =       %1011
    _Z_OR_NC                =       %1011
    _C                      =       %1100
    _LT                     =       %1100
    _C_OR_NZ                =       %1101
    _NZ_OR_C                =       %1101
    _C_OR_Z                 =       %1110
    _Z_OR_C                 =       %1110
    _LE                     =       %1110
    _SET                    =       %1111
    
    
    Melbourne, Australia
  • So I also need instructions on where to look for instructions too! Thanks.

    So modz %1100 wz copies C into Z. But what if we don't use wz?

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Latest binary V5.4 includes EASYFILE +++++ Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET +++++ TAQOZ documentation
    Brisbane, Australia
  • So modz %1100 wz copies C into Z. But what if we don't use wz?

    Z state wold remain unchanged.
    Melbourne, Australia
  • Yes, but would there ever be a reason to not specify wz or is it simply mandatory?

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Latest binary V5.4 includes EASYFILE +++++ Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET +++++ TAQOZ documentation
    Brisbane, Australia
  • cgracey wrote: »
    Cluso99 wrote: »
    Questions...

    I presume that this is invalid
        _ret_   call     #label
    

    The _RET_ only executes if not preempted by a branch. This means that '_RET_ DJNZ X,#loop' will only RETurn when the looping is done. In your example, the CALL would always take precedence over the _RET_.

    Thanks Chip. Actually if we had though about it earlier, it could have been simple to make it work. Just don't push the call's return address onto the stack. This way, the call's return would bypass this call's return address, and go directly to the previous return address. Saves 2 clocks to boot ;)
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Cluso99Cluso99 Posts: 14,101
    edited May 11 Vote Up0Vote Down
    Instruction MODCZ/Z/C

    What do you think this instruction does?
                    modz    1                       wz      ' =0001
    
    Nope! It inverts Z! So in the test below you will see NZNZNZNZNZ... ;)

    Here are the tests...
    		mov	lmm_x, #0       wz	' preset "Z"
    loop
    '		modz    1111	      wz	' set "Z"
    '		modz    0000          wz      ' set "NZ"
                    modz    1             wz      ' invert "Z" (0001)
    	if_z	mov	lmm_x, #"Z"
    	if_nz	mov	lmm_x, #"N"
    		CALL	#@_HubTx
    		jmp	#loop
    

    Postedit:
    I have just seen the above discussion with ccodes.
    Not sure about anything other than 0000 and 1111 anymore. No time now tho'.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • modz 1 wz
    
    is the equivalent of
    modz _nc_and_nz wz
    
    Melbourne, Australia
  • Confirmation of "modz 1 wz" operation.
    	modcz	_clr,_clr wcz	'clear c , clear z
    	modz	1 wz	'z = !c & !z, z = 1
    	modcz	_set,_clr wcz	'set c, clear z
    	modz	1 wz	'z = !c & !z, z = 0
    	nop
    
    Returns the following flag states
    >(P2 Debugger V3.34_V32c)================================================================================================
    00000: FD7C006F              MODCZ   _CLR,_CLR WCZ
    Flags (CZ) = __
    >*
    (P2 Debugger V3.34_V32c)================================================================================================
    00001: FD6C026F              MODCZ   _CLR,_NC_AND_NZ WZ
    Flags (CZ) = __
    >*
    (P2 Debugger V3.34_V32c)================================================================================================
    00002: FD7DE06F              MODCZ   _SET,_CLR WCZ
    Flags (CZ) = _Z
    >*
    (P2 Debugger V3.34_V32c)================================================================================================
    00003: FD6C026F              MODCZ   _CLR,_NC_AND_NZ WZ
    Flags (CZ) = C_
    >*
    (P2 Debugger V3.34_V32c)================================================================================================
    00004: 00000000              NOP
    Flags (CZ) = C_
    >
    

    Melbourne, Australia
Sign In or Register to comment.