The immediate iteration count and instruction count in REPS and REPD are one-based in the assembly language source, though they are encoded as zero-based in the opcode.
REPS #16,#1 encodes %00000000001111 for the '#16' and %000000 for the '#1'.
When REPD uses a D register to express iterations, it follows the same rule, where execution of the block will occur only once when the D register holds $00000000, or 2^32 times when D holds $FFFFFFFF.
I've been on taking a break over the holidays, but I'm getting back on the documentation work.
I posted this on the doc thread earlier, but here is the latest, again. See the section on REPS/REPD:
I'm not sure I understand what the OFFP instruction does. It seems like it toggles the direction of a pin. Is that correct? Is there any way to set the direction of a pin other than by using the DIRA-DIRD registers?
I'm not sure I understand what the OFFP instruction does. It seems like it toggles the direction of a pin. Is that correct? Is there any way to set the direction of a pin other than by using the DIRA-DIRD registers?
If you use one of the pin output instructions (SETP, CLRP, NOTP ...) the direction is automatically set to output, you don't need to set DIRx first. If you want then the pin to be an input you can use OFFP one time to set it to input. So: Yes there is another way beside setting DIRx.
If you use one of the pin output instructions (SETP, CLRP, NOTP ...) the direction is automatically set to output, you don't need to set DIRx first. If you want then the pin to be an input you can use OFFP one time to set it to input. So: Yes there is another way beside setting DIRx.
Andy
Thanks! That wasn't clear to me from the preliminary instruction set document. Does GETP automatically set the pin to an input?
I'm trying to write some inline functions for manipulating pins and am finding it awkward that the pin instructions use the C or Z flag for the pin value rather than a register. I've come up with these two sequences to get and set a pin but it seems like there has to be a better way. Any ideas?
r0 long 0
r1 long 0
' get the value of a pin
' r0 contains the pin number
' returns pin value in r0
my_getpin getpin r0 wc
if_c mov r0, #1
if_nc mov r0, #0
my_getpin_ret ret
' set the value of a pin
' r0 contains the pin number
' r1 contains the pin value
my_setpin cmp r1, #0 wz
if_z clrp r0
if_nz setp r0
my_setpin_ret ret
Can you just use RCL to rotate the carry bit into the register?
Something like:
rcl R0,#1
After you get the pin input into C.
Yes but then I'll have to clear the register first and that will be the same number of instructions as I'm using now. It might look better though without the conditions. Thanks for the suggestion.
I haven't started stringing instructions together yet. My first impressions were these new pin instructions would make quick work of sending/receiving a string of bits to/from a pin. Single bits may not pick up any efficiencies unless we're missing a trick.
I haven't started stringing instructions together yet. My first impressions were these new pin instructions would make quick work of sending/receiving a string of bits to/from a pin. Single bits may not pick up any efficiencies unless we're missing a trick.
It has got me thinking about PASM again! :0)
I think the new instructions will work well in PASM code but I'm not sure if the C compiler will be able to make use of them easily. The P2 is much more of a CISC machine than P1 and compilers have always had a hard time making good use of some CISC instructions.
I'm not sure I understand what the OFFP instruction does. It seems like it toggles the direction of a pin. Is that correct? Is there any way to set the direction of a pin other than by using the DIRA-DIRD registers?
It seems our early documentation is wrong. Here is OFFP:
OFFP D/#n - clears both the DIR bit and PIN bit for the pin (input with output bit low)
Thanks! That wasn't clear to me from the preliminary instruction set document. Does GETP automatically set the pin to an input?
GETP and GETNP do not affect the DIR bit. They only read the input, regardless of its DIR state. In other words, if a pin is outputting a low, but is externally being forced high, you will read the high state.
GETP and GETNP do not affect the DIR bit. They only read the input, regardless of its DIR state. In other words, if a pin is outputting a low, but is externally being forced high, you will read the high state.
Has anyone written a disassembler for the Propeller 2 instruction set? I have updated GAS to assemble P2 instructions but don't have the disassembler updated yet.
Comments
Wise decision
Nice decision
Instruction's PDF Updated in first post
Happy new year to all
From Sweden.
REPS #16,#1 encodes %00000000001111 for the '#16' and %000000 for the '#1'.
When REPD uses a D register to express iterations, it follows the same rule, where execution of the block will occur only once when the D register holds $00000000, or 2^32 times when D holds $FFFFFFFF.
I've been on taking a break over the holidays, but I'm getting back on the documentation work.
I posted this on the doc thread earlier, but here is the latest, again. See the section on REPS/REPD:
Prop2_Docs.txt
GETP
D/#n
Get pin number given by register “D (0-511)” or “n (0-127)”into !Z or C flags.
GETPN
D/#n
Get pin number given by register “D (0-511)” or “n (0-127)”into Z or !C flags.
OFFP
D/#n
Toggle pin number given by register “D (0-511)” or “n (0-127)” off or on. DIR
NOTP
D/#n
Invert pin number given by the value in register “D (0-511)” or “n (0-127)”. OUT
CLRP
D/#n
Clear pin number given by the value in register “D (0-511)” or “n (0-127)”. OUT
SETP
D/#n
Set pin number given by the value in register “D (0-511)” or “n (0-127)”. OUT
SETPC
D/#n
Set pin number given by the value in register “D (0-511)” or “n (0-127)” to C
SETPNC
D/#n
Set pin number given by the value in register “D (0-511)” or “n (0-127)” to !C
SETPZ
D/#n
Set pin number given by the value in register “D (0-511)” or “n (0-127)” to Z
SETPNZ
D/#n
Set pin number given by the value in register “D (0-511)” or “n (0-127)” to !Z
If you use one of the pin output instructions (SETP, CLRP, NOTP ...) the direction is automatically set to output, you don't need to set DIRx first. If you want then the pin to be an input you can use OFFP one time to set it to input. So: Yes there is another way beside setting DIRx.
Andy
As Andy just mentioned, the pin specific instructions set states just given pin numbers. Just dropping the table there didn't do a lot of good.
Something like:
rcl R0,#1
After you get the pin input into C.
It has got me thinking about PASM again! :0)
You could use MUXC or MUXNC to set all the bits of a destination register to C or !C.
Also, you could uses RCR D,1, then SETPC to set a pin to the state of bit 0 of D. Or do the CMP D, 0 wz, then SETPZ.
It seems our early documentation is wrong. Here is OFFP:
OFFP D/#n - clears both the DIR bit and PIN bit for the pin (input with output bit low)
GETP and GETNP do not affect the DIR bit. They only read the input, regardless of its DIR state. In other words, if a pin is outputting a low, but is externally being forced high, you will read the high state.
Is it possible You can post any simple block diagram how to program counters / theirs possibilits
I'm covering the branch instructions now. I'll do the counters next. Thanks.
Thanks
PDF in first post updated
Prop2_Docs.txt.pdf updated in first post
I forgot to mention this in the doc's. I'll add it tonight.
In the meantime, you must use 'SETPORT D/#n' where bits 5 and 6 of the operand determine which port (0..3) the WAITPEQ/WAITPNE will look at.