The table below provides the names and definitions of the functions created for the general-purpose computer. The missing byte match functions are covered separately.
Parameters A and B are bytes, W is a 16-bit word, and C, D, and E are Booleans (bytes restricted to 0 and 1).
| Function | Definition |
|---|---|
| CLEAR | A ↦ 0 |
| DEC | A ↦ A − 1 |
| DEC_16 | W ↦ W − 1 |
| IDENTITY | A ↦ A |
| INC | A ↦ A + 1 |
| INC_16 | W ↦ W + 1 |
| LS2 | A ↦ A << 2 |
| LS3 | A ↦ A << 3 |
| LS4 | A ↦ A << 4 |
| RS1 | A ↦ A >>> 1 |
| RS5 | A ↦ A >>> 5 |
| ADD_AB_FB | [ A, B ] ↦ [ A + B, B ] |
| AND_AB_AF | [ A, B ] ↦ [ A, A & B ] |
| AND_AB_FB | [ A, B ] ↦ [ A & B, B ] |
| AND_NOT_AB_FB | [ D, E ] ↦ [ D, D and not E ] |
| COPY_A_B | [ A, B ] ↦ [ A, A ] |
| COPY_B_A | [ A, B ] ↦ [ B, B ] |
| INC_16_C | [ W, C ] ↦ [ C ? W + 1 : W, C ] |
| OR_AB_FB | [ A, B ] ↦ [ A | B, B ] |
| SUB_AB_FB | [ A, B ] ↦ [ A − B, B ] |
| SWAP | [ A, B ] ↦ [ B, A ] |
| XOR_AB_FB | [ A, B ] ↦ [ A ^ B, B ] |
| AND_A_B_C | [ D, E, C ] ↦ [ D, E, D and E ] |
| C_AND_A_NOT_B | [ C, D, E ] ↦ [ D and not E, D, E ] |
| CMP_C | [ A, B, C ] ↦ [ A, B, A = B ] |
| CMP_AND_C | [ A, B, C ] ↦ [ A, B, (A = B) and C ] |
| C_CMP | [ C, A, B ] ↦ [ A = B, A, B ] |
| COPY_A_B_C | [ A, B, C ] ↦ [ A, C ? A : B, C ] |
| COPY_B_A_C | [ A, B, C ] ↦ [ C ? B : A, B, C ] |
| C_COPY_B_A | [ C, A, B ] ↦ [ C, C ? B : A, B ] |
| C_COPY_A_B | [ C, A, B ] ↦ [ C, A, C ? A : B ] |
A byte match functions accept a byte, A, and a Boolean, C. It returns A, unchanged, along with a Boolean indicating if A matches a specific bit pattern. The function names declare the parameter orders:
| Ends with _C: | [ A, C ] ↦ [ A, isMatch(A) ] |
| Starts with C_: | [ C, A ] ↦ [ isMatch(A), A ] |
The following table details the byte match functions. Those with bit patterns containing don’t-care are capable of matching multiple values, as shown in the right column.
| Function | Pattern | Values |
|---|---|---|
| ADD_C | 00010000 | 10 |
| AND_C | 00010001 | 11 |
| BEQ_C | 00100011 | 23 |
| BMI_C | 00100101 | 25 |
| BNE_C | 00100010 | 22 |
| BPL_C | 00100100 | 24 |
| DEC_C | 00010010 | 12 |
| INC_C | 00010011 | 13 |
| JMP_C | 00100000 | 20 |
| JSR_C | 00101000 | 28 |
| LDB_C | 01000001 | 41 |
| LS2_C | 00010100 | 14 |
| LS3_C | 00010101 | 15 |
| LS4_C | 00010110 | 16 |
| OR_C | 00010111 | 17 |
| RS1_C | 00011000 | 18 |
| RS5_C | 00011001 | 19 |
| RTS_C | 01110000 | 70 |
| SEA_C | 01010000 | 50 |
| SEB_C | 01010001 | 51 |
| SMN_C | 00101111 | 2F |
| STA_C | 00110000 | 30 |
| STB_C | 00110001 | 31 |
| SUB_C | 00011010 | 1A |
| XOR_C | 00011011 | 1B |
| TAX_C | 000000** | 00, 01, 02, 03 |
| TBX_C | 000001** | 04, 05, 06, 07 |
| TMX_C | 000010** | 08, 09, 0A, 0B |
| TNX_C | 000011** | 0C, 0D, 0E, 0F |
| TXA_C | 0000**00 | 00, 04, 08, 0C |
| TXB_C | 0000**01 | 01, 05, 09, 0D |
| TXM_C | 0000**10 | 02, 06, 0A, 0E |
| TXN_C | 0000**11 | 03, 07, 0B, 0F |
| LDX_C | 0100000* | 40, 41 |
| STX_C | 0011000* | 30, 31 |
| SEX_C | 0101000* | 50, 51 |
| THREE_C | 0010**** | 20..2F |
| MINUS_C | 1******* | 80..FF |
| C_MINUS | 1******* | 80..FF |
| ZERO_C | 00000000 | 00 |
| C_ZERO | 00000000 | 00 |
As their names suggest, the byte match functions primarily detect machine language opcodes or sets of opcodes. The most generic of them, THREE_C, matches the opcodes for all 3-byte instructions.
MINUS_C and C_MINUS recognize negative numbers, those with bit-7 set per two’s complement.
ZERO_C and C_ZERO are zero detectors.
© 2023 meatfighter.com |