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 _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_.
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,#0modz0wzmov tos,#0if_zmov tos,#1ret
So it will return a 1 if the z is set.
Now the test....
TAQOZ# 016 ADO CRLF I .B SPACE I MODZ . LOOP
$000$011$020$031$040$051$060$071$080$091$0A0$0B1$0C0$0D1$0E0$0F1 ok
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,#0modz0wzmov tos,#0if_zmov tos,#1ret
So it will return a 1 if the z is set.
Now the test....
TAQOZ# 016 ADO CRLF I .B SPACE I MODZ . LOOP
$000$011$020$031$040$051$060$071$080$091$0A0$0B1$0C0$0D1$0E0$0F1 ok
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
Comments
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.
I presume that this is invalid
_ret_ call #label
It would just require the verilog to NOT push the new return address onto the stack. I wonder if Chip thought about this?
there is probably a ret at the end of the code of label?
Mike
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_.
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.
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!
--------------- 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
So modz %1100 wz copies C into Z. But what if we don't use wz?
Z state wold remain unchanged.
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
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'.
modz 1 wz
is the equivalent ofmodz _nc_and_nz wz
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_ >