Shop Learn
PASM2's movbyts is amazing! Needs documentation. — Parallax Forums

PASM2's movbyts is amazing! Needs documentation.

movbyts colorbits, #%%2310 ' $RR_GG_BB_WW --> $GG_RR_BB_WW

I found this gem of an instruction in Jon's pixel driver and wow, have I been doing it wrong. There is little documentation on it, but it appears that in the S field, if you specify #%%0123 you could basically swap the lowest byte in a long, for the highest and swap the middle bytes too. Where as, the natural order would be #%%3210 Is that correct?

Comments

  • evanhevanh Posts: 13,121
    edited 2022-02-03 04:48

    Correct.

    There is a large amount of extra machine instructions in the Prop2. Quite the contrast to the Prop1. That said, quite a lot of them are hardware support instructions like WXPIN for the smartpins.

    EDIT: Some more of the new data manipulation instructions would: INCMOD/DECMOD, ENCOD/DECOD, BITx/TESTx and pin twiddling like DRVx/FLTx/DIRx/OUTx/TESTPx, SPLIT/MERGE, BMASK/ZEROX/SIGNX are effective, GETBYTE and co, the ALTx prefixing group for indexing, instructions for multiple call stacks, the cordic maths instructions, and of course MUL/SCA for fast multiples.

    Specialised data instructions I've not used are ADPIX/MULPIXBLNPIX/MIXPIX/SETPIV/SETPIX, SKIP/SKIPF/EXECF, SEUSSF/SEUSSR/RGBSQZ/RGBEXP, CRCBIT/CRCNIB.

    Reference doc is Propeller 2 PASM Instructions from here - https://www.parallax.com/propeller-2/documentation/

  • ke4pjwke4pjw Posts: 648
    edited 2022-02-03 14:49

    movbyts doesn't have an entry, other than in the index in the PASM2 Manual, yet.

  • evanhevanh Posts: 13,121
    edited 2022-02-03 05:03

    It's in that spreadsheet. But like everything there, it's concise. Here's the direct link - https://docs.google.com/spreadsheets/d/1_vJk-Ad569UMwgXTKTdfJkHYHpc1rZwxB-DcIiAZNdk/edit?usp=sharing

    PS: That's what everyone has used so far. The more elaborate docs are still in draft form. Documenting the Prop2 is a lot bigger job than the Prop1 ever was.

  • MOVBYTS is probably one of the most useful instructions. #%%0123 is a full endian swap, #%%1032 is a word swap (can also be done with ROLWORD), #%%2200 dublicates even bytes into odd bytes, etc. And if you use a register S, you can use it to decode 2bpp indexed data to 8bpp.

  • pik33pik33 Posts: 1,673

    To make this complete, there is also splitw,splitb, mergew, mergeb. Very useful for pixel manipulation. For example, if you need to put a character - 8 pixels - line onto the 4 bpp screen you need to convert 00000000_00000000_0000000_abcdefgh to 000a_000b_000c_000d_000e_000f_000g_000h. In every normal microprocessor this is not a trivial task. In the Propeller, mergeb does this in one instruction.

Sign In or Register to comment.