Any way to extract S field of a register to another in a single instruction?
rogloh
Posts: 6,113
in Propeller 2
What am I missing? If I use SETS D, S I think I need to clear the D register first, or if I do a AND S, #$1ff I destroy S.
Surely this is doable...
Surely this is doable...

Comments
'.................................................................................................. ' HYPER WRITES without latency ' a b c ' W B R (a) word write ' O U E (b) burst write ' R R G (c) register write ' D S ' T w_flash_burst tjz count, #nowrite_lut ' b ensure transfer count is non-zero mov a, #0 wcz ' b zero out test reg and set z flag for later, c=0 sets a, addr1 ' b get 9 LSBs of flash address add a, count ' b add the count sub a, #1 ' b find the last address andn a, #$1ff ' b clear lower bits tjnz a, #sizeerror ' b exit if this wraps past 512 byte boundaryAlso not sure about the 2 clock pipeline delay in setting a either.
mov a, addr1 add a, count sub a, #1 andn a, #$1ff wz ' wz optional tjnz a, #sizeerrorand this would work toomov a, addr1 add a, count sub a, #1 testb a, #9 wcz ' if_c/nz jmp #sizeerrorThe sets should not have pipeline problems if we are not executing from it.
tjz count, #nowrite_lut mov a, addr1 and a, #$1ff add a, count sub a, #1 andn a, #$1ff wcz ' wz optional tjnz a, #sizeerrorMUXQ would work but still requires a SETQ setup sometime earlier. Not really any different to clearing D first.
Is this any good?
The original 7 instruction code I show just seems too inefficient. The original footprint I had in place only checked zero and a total 512 byte limit but no 512 byte boundary crossing was 5 instructions and I'm trying to not grow it much to extend to cases where any transfer crosses a 512 byte boundary is identified and rejected.
I would quite like the "andn a, #$1ff wcz" at the end though because it leaves the flags in the right condition.
Update: there's also the FLES / FLE / FGE/ FGES stuff too. That might be something useful too.
@evanh. a is just a free temp register so it can be left in any state.
tjz count, #nowrite_lut alts addr1, #$1ff mov a, #0-0 add a, count andn a, #$1ff wcz ' wz optional tjnz a, #sizeerrorAnd a, #$1ff
Add a,count
CMP a, #$201 or cmpr if you need the opposite c.
This saves the sub.
sizeerror is probably close by, but one issue with TJxx D,#S is that cannot jump from anywhere in COG RAM to anywhere in LUT RAM and vice-versa. Alternative: