Instruction Operation P2 v10a
Cluso99
Posts: 18,069
in Propeller 2
Here is a place to record how instructions work and if they have been tested, etc
(just to keep it in one place without other discussions being interleaved)
Chips' P2 Documentation v10a
https://drive.google.com/open?id=1WVk_NHejFVTZzYv33SL1xPU5lHQXCiVwYS7DXK3Um2Y
Google P2 Instructions (some out of date)
https://docs.google.com/document/d/1O27nO2tMjBTvUNblFFRtEp5DHvcvsSGXcPvH9FaJ9u8/pub
Here is the Instruction Summary...
(just to keep it in one place without other discussions being interleaved)
Chips' P2 Documentation v10a
https://drive.google.com/open?id=1WVk_NHejFVTZzYv33SL1xPU5lHQXCiVwYS7DXK3Um2Y
Google P2 Instructions (some out of date)
https://docs.google.com/document/d/1O27nO2tMjBTvUNblFFRtEp5DHvcvsSGXcPvH9FaJ9u8/pub
Here is the Instruction Summary...
Propeller P16X64A Instructions v10a-1c 17Jun2016 ---------------------------------------------------------------------------------------------------------------------------------------- Cond Opcode CZ I Dest Source Instr00 01 10 11 Operand(s) Flags ---------------------------------------------------------------------------------------------------------------------------------------- CCCC 00000ff CZ I DDDDDDDDD SSSSSSSSS ROR ROL SHR SHL D,S/# CZ CZ CZ CZ CCCC 00001ff CZ I DDDDDDDDD SSSSSSSSS RCR RCL SAR SAL D,S/# CZ CZ CZ CZ CCCC 00010ff CZ I DDDDDDDDD SSSSSSSSS ADD ADDX ADDS ADDSX D,S/# CZ CZ CZ CZ CCCC 00011ff CZ I DDDDDDDDD SSSSSSSSS SUB SUBX SUBS SUBSX D,S/# CZ CZ CZ CZ CCCC 00100ff CZ I DDDDDDDDD SSSSSSSSS CMP CMPX CMPS CMPSX D,S/# CZ CZ CZ CZ CCCC 00101ff CZ I DDDDDDDDD SSSSSSSSS CMPR CMPM SUBR CMPSUB D,S/# CZ CZ CZ CZ CCCC 00110ff CZ I DDDDDDDDD SSSSSSSSS MIN MAX MINS MAXS D,S/# CZ CZ CZ CZ CCCC 00111ff CZ I DDDDDDDDD SSSSSSSSS SUMC SUMNC SUMZ SUMNZ D,S/# CZ CZ CZ CZ CCCC 01000ff CZ I DDDDDDDDD SSSSSSSSS ISOB NOTB CLRB SETB D,S/# CZ CZ CZ CZ CCCC 01001ff CZ I DDDDDDDDD SSSSSSSSS SETBC SETBNC SETBZ SETBNZ D,S/# CZ CZ CZ CZ CCCC 01010ff CZ I DDDDDDDDD SSSSSSSSS ANDN AND OR XOR D,S/# CZ CZ CZ CZ CCCC 01011ff CZ I DDDDDDDDD SSSSSSSSS MUXC MUXNC MUXZ MUXNZ D,S/# CZ CZ CZ CZ CCCC 01100ff CZ I DDDDDDDDD SSSSSSSSS MOV NOT ABS NEG D,S/# CZ CZ CZ CZ CCCC 01101ff CZ I DDDDDDDDD SSSSSSSSS NEGC NEGNC NEGZ NEGNZ D,S/# CZ CZ CZ CZ CCCC 0111000 ff I DDDDDDDDD SSSSSSSSS ALTI ALTR ALTD ALTS D,S/# -- -- -- -- CCCC 0111001 CZ I DDDDDDDDD SSSSSSSSS DECOD D,S/# CZ CCCC 011101f CZ I DDDDDDDDD SSSSSSSSS TOPONE BOTONE D,S/# CZ CZ CCCC 011110f CZ I DDDDDDDDD SSSSSSSSS INCMOD DECMOD D,S/# CZ CZ CCCC 011111f fZ I DDDDDDDDD SSSSSSSSS MUL MULS SCLU SCL D,S/# -Z -Z -Z -Z ---------------------------------------------------------------------------------------------------------------------------------------- CCCC 1000ffn nn I DDDDDDDDD SSSSSSSSS SETNIB GETNIB ROLNIB ******* D,S/#,#n -- -- -- -- CCCC 100011f nn I DDDDDDDDD SSSSSSSSS SETBYTE GETBYTE D,S/#,#n -- -- CCCC 1001000 nn I DDDDDDDDD SSSSSSSSS ROLBYTE D,S/#,#n -- CCCC 1001001 fn I DDDDDDDDD SSSSSSSSS SETWORD GETWORD D,S/#,#n -- -- CCCC 1001010 0n I DDDDDDDDD SSSSSSSSS ROLWORD D,S/#,#n -- CCCC 1001010 1f I DDDDDDDDD SSSSSSSSS SETBYTS MOVBYTS D,S/# -- -- CCCC 1001011 ff I DDDDDDDDD SSSSSSSSS SPLITB MERGEB SPLITW MERGEW D,S/# -- -- -- -- CCCC 1001100 ff I DDDDDDDDD SSSSSSSSS SEUSSF SEUSSR RGBSQZ RGBEXP D,S/# -- -- -- -- CCCC 1001101 ff I DDDDDDDDD SSSSSSSSS REV SETI SETD SETS D,S/# -- -- -- -- CCCC 1001110 ff I DDDDDDDDD SSSSSSSSS DJZ DJNZ DJS DJNS D,S/#rel9 -- -- -- -- CCCC 1001111 ff I DDDDDDDDD SSSSSSSSS TJZ TJNZ TJS TJNS D,S/#rel9 -- -- -- -- CCCC 10100ff CZ I DDDDDDDDD SSSSSSSSS TESTN TEST ANYB TESTB D,S/# CZ CZ CZ CZ CCCC 1010100 ff I DDDDDDDDD SSSSSSSSS ADDCT1 ADDCT2 ADDCT3 WMLONG D,S/#;D,S/#;D,S/#;D,S/#/PTRx -- -- -- -- CCCC 1010101 CZ I DDDDDDDDD SSSSSSSSS CALLD D,S/#rel9 CZ CCCC 101011f CZ I DDDDDDDDD SSSSSSSSS RDPIN RDLUT D,S/# CZ CZ CCCC 10110ff CZ I DDDDDDDDD SSSSSSSSS RDBYTE RDWORD RDLONG ******* D,S/#/PTRx CZ CZ CZ CZ CCCC 1011011 ff I DDDDDDDDD SSSSSSSSS ADDPIX MULPIX BLNPIX MIXPIX D,S/# -- -- -- -- CCCC 101110f fL I DDDDDDDDD SSSSSSSSS <empty> <empty> JP JNP D/#,S/#;D/#,S/#;D/#,S/#rel9;D/#,S/#rel9 -- -- -- -- CCCC 101111f fL I DDDDDDDDD SSSSSSSSS SETPAE SETPAN SETPBE SETPBN D/#,S/# -- -- -- -- CCCC 110000f fL I DDDDDDDDD SSSSSSSSS WRPIN WXPIN WYPIN WRLUT D/#,S/# -- -- -- -- CCCC 110001f fL I DDDDDDDDD SSSSSSSSS WRBYTE WRWORD WRLONG RDFAST D/#,S/#/PTRx;D/#,S/#/PTRx;D/#,S/#/PTRx;D/#,S/# -- -- -- -- CCCC 1100100 fL I DDDDDDDDD SSSSSSSSS WRFAST FBLOCK D/#,S/# -- -- CCCC 1100101 fL I DDDDDDDDD SSSSSSSSS XINIT XZERO D/#,S/# -- -- CCCC 1100110 fL I DDDDDDDDD SSSSSSSSS XCONT REP D/#,S/# -- -- CCCC 1100111 CL I DDDDDDDDD SSSSSSSSS COGINIT D/#,S/# C- CCCC 110100f fL I DDDDDDDDD SSSSSSSSS QMUL QDIV QFRAC QSQRT D/#,S/# -- -- -- -- CCCC 1101010 fL I DDDDDDDDD SSSSSSSSS QROTATE QVECTOR D/#,S/# -- -- ---------------------------------------------------------------------------------------------------------------------------------------- CCCC 1101011 CZ L DDDDDDDDD 0000000ff CLKSET COGID <empty> COGSTOP D/# CZ CZ CZ -- CCCC 1101011 CZ 0 DDDDDDDDD 0000001ff LOCKNEW LOCKRET LOCKCLR LOCKSET D;D/#;D/#;D/# CZ -- C- C- CCCC 1101011 CZ L DDDDDDDDD 0000010ff <empty> <empty> <empty> <empty> D/# CZ CZ CZ CZ CCCC 1101011 CZ L DDDDDDDDD 0000011ff <empty> <empty> QLOG QEXP D/# CZ CZ -- -- CCCC 1101011 CZ 0 DDDDDDDDD 0000100ff RFBYTE RFWORD RFLONG WFBYTE D;D;D;D/# CZ CZ CZ -- CCCC 1101011 00 L DDDDDDDDD 0000101ff WFWORD WFLONG SETQ SETQ2 D/# -- -- -- -- CCCC 1101011 CZ 0 DDDDDDDDD 0000110ff GETQX GETQY GETCT GETRND D CZ CZ -- CZ CCCC 1101011 00 L DDDDDDDDD 0000111ff SETDACS SETXFRQ GETXCOS GETXSIN D/#;D/#;D;D -- -- -- -- CCCC 1101011 00 L DDDDDDDDD 0001000ff SETEDG SETRDL SETWRL SETHLK D/# -- -- -- -- ---------------------------------------------------------------------------------------------------------------------------------------- CCCC 1101011 C0 0 0000000ff 000100100 POLLINT POLLCT1 POLLCT2 POLLCT3 C- C- C- C- CCCC 1101011 C0 0 0000001ff 000100100 POLLEDG POLLPAT POLLRDL POLLWRL C- C- C- C- CCCC 1101011 C0 0 0000010ff 000100100 POLLXMT POLLXFI POLLXRO POLLXRL C- C- C- C- CCCC 1101011 C0 0 0000011ff 000100100 POLLFBW POLLHLK POLLATN POLLQMT C- C- C- C- CCCC 1101011 C0 0 0000100ff 000100100 WAITINT WAITCT1 WAITCT2 WAITCT3 C- C- C- C- CCCC 1101011 C0 0 0000101ff 000100100 WAITEDG WAITPAT WAITRDL WAITWRL C- C- C- C- CCCC 1101011 C0 0 0000110ff 000100100 WAITXMT WAITXFI WAITXRO WAITXRL C- C- C- C- CCCC 1101011 C0 0 0000111ff 000100100 WAITFBW WAITHLK WAITATN <empty> C- C- C- CZ CCCC 1101011 00 0 0001000ff 000100100 ALLOWI STALLI <empty> <empty> -- -- CZ CZ CCCC 1101011 CZ 0 0001001ff 000100100 <empty> <empty> <empty> <empty> CZ CZ CZ CZ ---------------------------------------------------------------------------------------------------------------------------------------- CCCC 1101011 00 L DDDDDDDDD 0001001ff ******* SETINT1 SETINT2 SETINT3 -;D/#;D/#;D/# -- -- -- -- CCCC 1101011 00 L DDDDDDDDD 0001010ff WAITX SETCZ PUSH POP D/#;D/#;D/#;D -- CZ -- CZ CCCC 1101011 CZ 0 DDDDDDDDD 0001011ff JMP CALL CALLA CALLB D CZ CZ CZ CZ CCCC 1101011 00 L DDDDDDDDD 0001100ff JMPREL RET RETA RETB D/#;-;-;- -- CZ CZ CZ CCCC 1101011 00 0 DDDDDDDDD 0001101ff GETPTR GETINT SETBRK SETLUT D;D;D/#;D/# -- -- -- -- CCCC 1101011 00 L DDDDDDDDD 0001110ff SETCY SETCI SETCQ SETCFRQ D/# -- -- -- -- CCCC 1101011 00 L DDDDDDDDD 0001111ff SETCMOD SETPIX SETPIV COGATN D/# -- -- -- -- ---------------------------------------------------------------------------------------------------------------------------------------- CCCC 11011ff Rn n nnnnnnnnn nnnnnnnnn JMP CALL CALLA CALLB #abs/#rel -- -- -- -- CCCC 1110fww Rn n nnnnnnnnn nnnnnnnnn CALLD LOC reg,#abs/#rel -- -- CCCC 1111fnn nn n nnnnnnnnn nnnnnnnnn AUGS AUGD #23bits -- -- ---------------------------------------------------------------------------------------------------------------------------------------- COG REGISTERS ------------------------------------------------- _IJMP3 = $1F0 '' COG Interrupt Jump 3 _IRET3 = $1F1 '' COG Interrupt Return 3 _IJMP2 = $1F2 '' COG Interrupt Jump 2 _IRET2 = $1F3 '' COG Interrupt Return 2 _IJMP1 = $1F4 '' COG Interrupt Jump 1 _IRET1 = $1F5 '' COG Interrupt Return 1 _ADDRA = $1F6 '' COG ADDR A _ADDRB = $1F7 '' COG ADDR B _PTRA = $1F8 '' COG PTR A _PTRB = $1F9 '' COG PTR B _DIRA = $1FA '' COG DIR A _DIRB = $1FB '' COG DIR B _OUTA = $1FC '' COG OUT A _OUTB = $1FD '' COG OUT B _INA = $1FE '' COG IN A / Debug JMP _INB = $1FF '' COG IN B / Debug RET -------------------------------------------------
Comments
CCCC 1101011 CZ L DDDDDDDDD 000101001 SETCZ D/# {WC,WZ}
Sets the C & Z flags according to D[1:0] and WC, WZ
If WC is specified then C=D[1] (0=C cleared, 1=C set)
If WZ is specified then Z=D[0] (0=Z cleared, 1=Z set) (yes, 1 sets Zero flag)
If neither WC nor WZ is specified, then C & Z flags are not set/changed
If both WC and WZ are specified, then both C & Z flags are set/changed
I have verified the above with v10a.
Note to Chip
Might it be possible/easy to have SETCZ when neither WC nor WZ is specified, that D[1:0] is set/written with the contents of C & Z flags (ie the reverse of SETCZ D WC,WZ) ? It could be called SAVECZ.
FYI This can be achieved by using 2 SETBx instructions.
Enjoy!
Mike
Here's some of my notes on these instructions to refresh our memory on them. These enabled saving and restoring zc flags.
A 16 level flag stack basically.
It seems to have only partial opcode construction details
eg with fasmg, https://flatassembler.net/download.php
and using a Chip docs example, I find/guess this is the required form of WAITX
- looks ok for the 32b case ?
Your bytes are all correct.
Your macro will also have to deal with non immediate variants too.
I can see only a L bit in WAITX, which I assumed was Long immediate, or does that mean L=0 is RegAdr, and all immediates are 32b prefixed ? ( L == #32)
In that case, the macro gives this
L = 0 Register
L = 1 Immediate
If immediate >$1ff then prefixed with AUGS instruction