Nibble-swap Pasm2 code
evanh
Posts: 15,916
Has anyone got a smaller solution than this for performing a nibble swap?: $12345678 -> $21436587
splitb val splitw val movbyts val, #%01_00_11_10 mergew val mergeb val
Comments
split/merge instructions are circular (5x mergew will bring you back to the same value you started with. splitw moves in the opposite direction. splitb/mergeb are just 2x splitw/mergew), so perhaps
Not tested, may be nonsense Yep, works.
Damn! That's cool! Thanks.
There is a need for documentation of how to perform useful operations.
This is how this p2 gem works.
@wuerfel_21 Great question.
@evanh Great answer.
Handy tool! Thanks Gary. I was struggling visualising the actions of those instructions too.
Shave off the implicit
AUGS
:There is no AUGS there,
#%%1032
Is a regular 9 bit immediateSorry, I can't read.
That is more readable though. MOVBYTS always has to be read carefully to know what gets moved where.
Another readable form:
```
```
EDIT: Grr, formatting is messed. It won't clean up.