Special form of ROL and ROR spin instruction with arbitrary length rotate distance?
Hi guys;
Anybody have a spin snippet for implementing a variable distance rotate?
The standard spin ROL or ROR only works on the ends of a 32 bit long.
I would like to supply a variable that contains values of 2 to 32 to control the shifts..
I assume one end of the rotate is bit 0.
Extra points for the SHL SHR SAL SAR versions. (Ya I know SAR doesn't exist.)
Even more points if both ends of the shifts can be specified.
Any references or examples?
Thanks guys!!
Duane J
Anybody have a spin snippet for implementing a variable distance rotate?
The standard spin ROL or ROR only works on the ends of a 32 bit long.
I would like to supply a variable that contains values of 2 to 32 to control the shifts..
I assume one end of the rotate is bit 0.
Extra points for the SHL SHR SAL SAR versions. (Ya I know SAR doesn't exist.)
Even more points if both ends of the shifts can be specified.
Any references or examples?
Thanks guys!!
Duane J

Comments
PUB roxn(value, s, e, n) | distance distance := ||(s[COLOR="#D3D3D3"]{& 31}[/COLOR]- e[COLOR="#D3D3D3"]{& 31}[/COLOR]) n //= ++distance dirb := value dirb[s..e] := dirb[s..e] << n | dirb[s..e] >> (distance - n) return dirbI apologize for my slow acknowledgment.
I just got to the point where I am trying to use your code.
I can't get it to work. I was assuming the use of DIRB was a trick in my Prop I, which doesn't have a "B" port.
I can't use DIRA as my "A" port is being used.
My manual dosn't say I can use the "double dot", "..", operator with regular variables.
Am I missing something?
BTW, I'm attempting to add your ROXN command as an extension to the DongleBasic instruction set.
Thanks!
Duane J
POC (demoboard or quickstart)
PUB null | v dira[16..23]~~ v := %10000001 repeat v := roxn(v, 7, 4, 1) ' left v := roxn(v, 0, 3, 1) ' right outa[16..23] := v waitcnt(clkfreq/2 + cnt) PUB roxn([COLOR="#FFA500"]value[/COLOR], s, e, n) | distance distance := ||(s[COLOR="#D3D3D3"]{& 31}[/COLOR]- e[COLOR="#D3D3D3"]{& 31}[/COLOR]) n //= ++distance [COLOR="#FFA500"]dirb := value[/COLOR] dirb[s..e] := dirb[s..e] << n | dirb[s..e] >> (distance - n) return dirb DATAlternatively just post the code section which handles your new command and we go from there.