Change Endianness of a Word in SPIN2
ke4pjw
Posts: 1,231
Is there a way to change the endianness of a WORD in SPIN2?
I do not believe that a ROR= 8 will work, because I suspect it would shift though the adjacent WORD.
Should I just load the information into a LONG, perform the appropriate ROR and forget about trying to save memory?

Comments
No such thing happens - all values are computed in 32 bit, if you have a word variable, that just means that it only stores the bottom half of values stored into it.
But just RORing is not what you want in such a case. What you want is some equivalent of the MOVBYTS instruction. Inexplicably, that doesn't exist, so you need to create a local variable and do something like
Flexspin also has an intrinsic:
value := __builtin_bswap16(value)Works fine if you combine a rol and ror:
That worked well. Would be nice if there was a hub version of movbyts or and spin2 equivalent.
I'd like that, too. Until it happens (how about it, @cgracey?) you can encapsulate it in a method (assuming you're not compiling Spin2 [where I think you can just do it inline])
pub move_bytes(value, arrangment) : result org mov result, value movbyts result, arrangment end