Shop Learn
I try to understand... — Parallax Forums

I try to understand...

SuracSurac Posts: 153
edited 2021-04-04 21:14 in Propeller 2

Reading the Instruction set of the P2 i have found something i can't find any documentation about

EEEE 0100000 CZI DDDDDDDDD SSSSSSSSS TESTB D,S/# WC/WZ
EEEE 0100001 CZI DDDDDDDDD SSSSSSSSS TESTBN D,S/# WC/WZ
EEEE 0100010 CZI DDDDDDDDD SSSSSSSSS TESTB D,S/# ANDC/ANDZ
EEEE 0100011 CZI DDDDDDDDD SSSSSSSSS TESTBN D,S/# ANDC/ANDZ
EEEE 0100100 CZI DDDDDDDDD SSSSSSSSS TESTB D,S/# ORC/ORZ
EEEE 0100101 CZI DDDDDDDDD SSSSSSSSS TESTBN D,S/# ORC/ORZ
EEEE 0100110 CZI DDDDDDDDD SSSSSSSSS TESTB D,S/# XORC/XORZ
EEEE 0100111 CZI DDDDDDDDD SSSSSSSSS TESTBN D,S/# XORC/XORZ

So, if i write TESTB or TESTBN, how does the compiler determine which to use?

EEEE 1101011 CZL DDDDDDDDD 001000000 TESTP D/# WC/WZ
EEEE 1101011 CZL DDDDDDDDD 001000001 TESTPN D/# WC/WZ
EEEE 1101011 CZL DDDDDDDDD 001000010 TESTP D/# ANDC/ANDZ
EEEE 1101011 CZL DDDDDDDDD 001000011 TESTPN D/# ANDC/ANDZ
EEEE 1101011 CZL DDDDDDDDD 001000100 TESTP D/# ORC/ORZ
EEEE 1101011 CZL DDDDDDDDD 001000101 TESTPN D/# ORC/ORZ
EEEE 1101011 CZL DDDDDDDDD 001000110 TESTP D/# XORC/XORZ
EEEE 1101011 CZL DDDDDDDDD 001000111 TESTPN D/# XORC/XORZ
  • shouldn't WC/WZ be written as {WC/WZ}?
  • How does the compiler determine how to encode the instruction?

Do i have to write something special behind the instruction to tell if i want AND OR, XOR?

Does it work like wc wz wcz behind the instruction?

Comments

  • evanhevanh Posts: 10,846
    edited 2021-04-04 21:27

    @Surac said:
    Do i have to write something special behind the instruction to tell if i want AND OR, XOR?

    Does it work like wc wz wcz behind the instruction?

    Yes, for those instructions, the WC/ANDC/ORC/XORC encodings are all the same "C" bit (#20) and WZ/ANDZ/ORZ/XORZ are all the same "Z" bit (#19).

  • evanhevanh Posts: 10,846
    edited 2021-04-04 21:53

    The reason why there is no {} braces is because it is mandatory to use exactly one option. Most instructions it is optional to use any.

  • TonyB_TonyB_ Posts: 1,678
    edited 2021-04-04 23:49

    TESTBx and BITx share the same opcodes, except for C & Z bits. Similarly for TESTPx and DIRx.

    TESTBx  D,S/#   WC/ANDC/ORC/XORC    'CZ=10
    TESTBx  D,S/#   WZ/ANDZ/ORZ/XORZ    'CZ=01
    BITx    D,S/#                       'CZ=00
    BITx    D,S/#   WCZ                 'CZ=11
    
  • ozpropdevozpropdev Posts: 2,762
    edited 2021-04-05 06:51

    Here's a complete list of the TESTP/n encodings.

    EEEE 0100000 00I DDDDDDDDD SSSSSSSSS        BITL    D,S/#
    EEEE 0100000 01I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       WZ
    EEEE 0100000 10I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       WC
    EEEE 0100000 11I DDDDDDDDD SSSSSSSSS        BITL    D,S/#       WCZ
    
    EEEE 0100001 00I DDDDDDDDD SSSSSSSSS        BITH    D,S/#
    EEEE 0100001 01I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       WZ
    EEEE 0100001 10I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       WC
    EEEE 0100001 11I DDDDDDDDD SSSSSSSSS        BITH    D,S/#       WCZ
    
    EEEE 0100010 00I DDDDDDDDD SSSSSSSSS        BITC    D,S/#
    EEEE 0100010 01I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       ANDZ
    EEEE 0100010 10I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       ANDC
    EEEE 0100010 11I DDDDDDDDD SSSSSSSSS        BITC    D,S/#       WCZ
    
    EEEE 0100011 00I DDDDDDDDD SSSSSSSSS        BITNC   D,S/#
    EEEE 0100011 01I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       ANDZ
    EEEE 0100011 10I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       ANDC
    EEEE 0100011 11I DDDDDDDDD SSSSSSSSS        BITNC   D,S/#       WCZ
    
    EEEE 0100100 00I DDDDDDDDD SSSSSSSSS        BITZ    D,S/#
    EEEE 0100100 01I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       ORZ
    EEEE 0100100 10I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       ORC
    EEEE 0100100 11I DDDDDDDDD SSSSSSSSS        BITZ    D,S/#       WCZ
    
    EEEE 0100101 00I DDDDDDDDD SSSSSSSSS        BITNZ   D,S/#
    EEEE 0100101 01I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       ORZ
    EEEE 0100101 10I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       ORC
    EEEE 0100101 11I DDDDDDDDD SSSSSSSSS        BITNZ   D,S/#       WCZ
    
    EEEE 0100110 00I DDDDDDDDD SSSSSSSSS        BITRND  D,S/#
    EEEE 0100110 01I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       XORZ
    EEEE 0100110 10I DDDDDDDDD SSSSSSSSS        TESTB   D,S/#       XORC
    EEEE 0100110 11I DDDDDDDDD SSSSSSSSS        BITRND  D,S/#       WCZ
    
    EEEE 0100111 00I DDDDDDDDD SSSSSSSSS        BITNOT  D,S/#
    EEEE 0100111 01I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       XORZ
    EEEE 0100111 10I DDDDDDDDD SSSSSSSSS        TESTBN  D,S/#       XORC
    EEEE 0100111 11I DDDDDDDDD SSSSSSSSS        BITNOT  D,S/#       WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000000        DIRL    D/#
    EEEE 1101011 01L DDDDDDDDD 001000000        TESTP   D/#         WZ
    EEEE 1101011 10L DDDDDDDDD 001000000        TESTP   D/#         WC
    EEEE 1101011 11L DDDDDDDDD 001000000        DIRL    D/#         WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000001        DIRH    D/#
    EEEE 1101011 01L DDDDDDDDD 001000001        TESTPN  D/#         WZ
    EEEE 1101011 10L DDDDDDDDD 001000001        TESTPN  D/#         WC
    EEEE 1101011 11L DDDDDDDDD 001000001        DIRH    D/#         WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000010        DIRC    D/#
    EEEE 1101011 01L DDDDDDDDD 001000010        TESTP   D/#         ANDZ
    EEEE 1101011 10L DDDDDDDDD 001000010        TESTP   D/#         ANDC
    EEEE 1101011 11L DDDDDDDDD 001000010        DIRC    D/#         WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000011        DIRNC   D/#         
    EEEE 1101011 01L DDDDDDDDD 001000011        TESTPN  D/#         ANDZ
    EEEE 1101011 10L DDDDDDDDD 001000011        TESTPN  D/#         ANDC
    EEEE 1101011 11L DDDDDDDDD 001000011        DIRNC   D/#         WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000100        DIRZ    D/#
    EEEE 1101011 01L DDDDDDDDD 001000100        TESTP   D/#         ORZ
    EEEE 1101011 10L DDDDDDDDD 001000100        TESTP   D/#         ORC
    EEEE 1101011 11L DDDDDDDDD 001000100        DIRZ    D/#         WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000101        DIRNZ   D/#
    EEEE 1101011 01L DDDDDDDDD 001000101        TESTPN  D/#         ORZ
    EEEE 1101011 10L DDDDDDDDD 001000101        TESTPN  D/#         ORC
    EEEE 1101011 11L DDDDDDDDD 001000101        DIRNZ   D/#         WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000110        DIRRND  D/#
    EEEE 1101011 01L DDDDDDDDD 001000110        TESTP   D/#         XORZ
    EEEE 1101011 10L DDDDDDDDD 001000110        TESTP   D/#         XORC
    EEEE 1101011 11L DDDDDDDDD 001000110        DIRRND  D/#         WCZ
    
    EEEE 1101011 00L DDDDDDDDD 001000111        DIRNOT  D/#
    EEEE 1101011 01L DDDDDDDDD 001000111        TESTPN  D/#         XORZ
    EEEE 1101011 10L DDDDDDDDD 001000111        TESTPN  D/#         XORC
    EEEE 1101011 11L DDDDDDDDD 001000111        DIRNOT  D/#         WCZ
    
    

    Edit: Corrected DIRNC typos

  • SuracSurac Posts: 153
    edited 2021-04-05 05:31

    Ahh,

    Thank you for enlighten me :smiley:

    EEEE 1101011 00L DDDDDDDDD 001000011 DIRNC D/# {WCZ}

    hmm i think there should not be a {WCZ}

    EEEE 1101011 11L DDDDDDDDD 001000011 DIRNC D/# {WCZ}

    and here it should say WCZ not {WCZ}

    right?

  • evanhevanh Posts: 10,846

    Correct. Oz missed a couple.

  • @Surac said:
    Ahh,

    Thank you for enlighten me :smiley:

    EEEE 1101011 00L DDDDDDDDD 001000011 DIRNC D/# {WCZ}

    hmm i think there should not be a {WCZ}

    EEEE 1101011 11L DDDDDDDDD 001000011 DIRNC D/# {WCZ}

    and here it should say WCZ not {WCZ}

    right?

    @evanh said:
    Correct. Oz missed a couple.

    Oops!
    I corrected the error, thanks guys. :smile:

Sign In or Register to comment.