Bit operations of the MegaProcessor.
The opcodes 0xD8..0xDF encode the various bit shift-, rotate-, test- and change operations.
Each of these 8 opcodes take a postbyte to encode the exact operation.
The first byte [b1] of a bit-opeation only determines the destination, as shown in the table below.
0xD8 : R0 for LSL, LSR, ASL, ASR, ROL, ROR, ROXL, and ROXR instructions
0xD9 : R1 " " " " " " "
0xDA : R2 " " " " " " "
0xDB : R3 " " " " " " "
0xDC : R0 for BTST, BCHG, BCLR, and BSET instructions
0xDD : R1 " " " " " "
0xDE : R2 " " " " " "
0xDF : R3 " " " " " "
All of the bit operations can only be applied on registers R0..R3.
The second byte specifies the particular operation, and the second parameter (e.g. number of shifts,
or bit-number to be tested)
In both tables below, decode the first byte of the bit-operation instruction to determine the destination register
first byte [b1] = 0xd8..0xdf
destination register [Rx] : x = b1 & 0x03
To select between the tables for decoding of second byte below
table = ( (b1 >> 3) & 0x01 ) -- 0 means 0xd8..0xdb, 1 means 0xdc..0xdf
Decoding of second byte [b2] for instructions 0xD8..0xDB
2nd byte : fixed part : variable part
0x00..0x0f : LSL Rx, #0 .. #15
0x10..0x1f : LSL Rx, #-16 .. #-1
0x20..0x23 : LSL Rx, R0 .. R3
0x24..0x27 : -- Redundant (4)
0x28..0x2b : LSL.WT Rx, R0 .. R3
0x2c..0x2f : -- Redundant (4)
0x30..0x33 : LSR Rx, R0 .. R3
0x34..0x37 : -- Redundant (4)
0x38..0x3b : LSR.WT Rx, R0 .. R3
0x3c..0x3f : -- Redundant (4)
0x40..0x4f : ASL Rx, #0 .. #15
0x50..0x5f : ASL Rx, #-16 .. #-1
0x60..0x63 : ASL Rx, R0 .. R3
0x64..0x67 : -- Redundant (4)
0x68..0x6b : ASL.WT, R0 .. R3
0x6c..0x6f : -- Redundant (4)
0x70..0x73 : ASR Rx, R0 .. R3
0x74..0x77 : -- Redundant (4)
0x78..0x7b : ASR.WT Rx, R0 .. R3
0x7c..0x7f : -- Redundant (4)
0x80..0x8f : ROL Rx, #0 .. #15
0x90..0x9f : ROL Rx, #-16 .. #-1
0xa0..0xa3 : ROL Rx, R0 .. R3
0xa4..0xa7 : -- Redundant (4)
0xa8..0xab : ROL.WT Rx, R0 .. R3
0xac..0xaf : -- Redundant (4)
0xb0..0xb3 : ROR Rx, R0 .. R3
0xb4..0xb7 : -- Redundant (4)
0xb8..0xbb : ROR.WT Rx, R0 .. R3
0xbc..0xbf : -- Redundant (4)
0xc0..0xcf : ROXL Rx, #0 .. #15
0xd0..0xdf : ROXL Rx, #-16 .. #-1
0xe0..0xe3 : ROXL Rx, R0 .. R3
0xe4..0xe7 : -- Redundant (4)
0xe8..0xeb : ROXL.WT Rx, R0 .. R3
0xec..0xef : -- Redundant (4)
0xf0..0xf3 : ROXR Rx, R0 .. R3
0xf4..0xf7 : -- Redundant (4)
0xf8..0xfb : ROXR.WT Rx, R0 .. R3
0xfc..0xff : -- Redundant (4)
Decoding of second byte [b2] for instructions 0xDC..0xDF
There are 8 different instructions in the category 'test-or-set'.
These are positioned at the bytes with even values for the high-nibble.
2nd byte : fixed part : variable part
0x00..0x0f : BTST Rx, #0 .. #15
0x10..0x1f : -- Redundant
0x20..0x23 : BTST Rx, R0 .. R3
0x24..0x27 : -- Redundant
0x28..0x2c : -- Redundant
0x2d..0x2f : -- Redundant
0x30..0x33 : -- Redundant
0x34..0x37 : -- Redundant
0x38..0x3c : -- Redundant
0x3d..0x3f : -- Redundant
0x40..0x4f : BCHG Rx, #0 .. #15
0x50..0x5f : -- Redundant
0x60..0x63 : BCHG Rx, R0 .. R3
0x64..0x67 : -- Redundant
0x68..0x6c : -- Redundant
0x6d..0x6f : -- Redundant
0x70..0x73 : -- Redundant
0x74..0x77 : -- Redundant
0x78..0x7c : -- Redundant
0x7d..0x7f : -- Redundant
0x80..0x8f : BCLR Rx, #0 .. #15
0x90..0x9f : -- Redundant
0xa0..0xa3 : BCLR Rx, R0 .. R3
0xa4..0xa7 : -- Redundant
0xa8..0xac : -- Redundant
0xad..0xaf : -- Redundant
0xb0..0xb3 : -- Redundant
0xb4..0xb7 : -- Redundant
0xb8..0xbc : -- Redundant
0xbd..0xbf : -- Redundant
0xc0..0xcf : BSET Rx, #0 .. #15
0xd0..0xdf : -- Redundant
0xe0..0xe3 : BSET Rx, R0 .. R3
0xe4..0xe7 : -- Redundant
0xe8..0xec : -- Redundant
0xed..0xef : -- Redundant
0xf0..0xf3 : -- Redundant
0xf4..0xf7 : -- Redundant
0xf8..0xfc : -- Redundant
0xfd..0xff : -- Redundant