Joined: Tue Sep 03, 2002 12:58 pm Posts: 336
|
Ignoring the digit at the end of instructions like RMB0, the 65C02 has 70 different instruction names. Storing them directly would require 210 bytes. The obvious optimisation is to pack the three letters for an instruction into two bytes, as only five bits are needed for each. That takes it down to 140. Is it possible to do better? Looking at just the first letter of the names, there are 15 possible characters: A, B, C, D, E, I, J, L, N, O, P, R, S, T, and W. The other two letters come in 64 unique pairs. It is possible to group the first letters into four sets that have 16 second/third letter pairs each: C, I, J, L, N, W can be followed by AI, DA, DX, DY, LC, LD, LI, LV, MP, NC, NX, NY, OP, PX, PY, SR D, E, R, S can be followed by BC, EC, ED, EI, EX, EY, MB, OL, OR, TA, TI, TP, TS, TX, TY, TZ A, B, O can be followed by BR, BS, CC, CS, DC, EQ, IT, MI, ND, NE, PL, RA, RK, SL, VC, VS P, T can be followed by AX, AY, HA, HP, HX, HY, LA, LP, LX, LY, RB, SB, SX, XA, XS, YA
So it would seem that an instruction name can be described in only 8 bits - first letter, then second/third pair. But it takes a number of tables to expand this encoding, and the whole ends up larger than the original. Still, it's a neat coincidence, and it would be nice if it could be exploited somehow. (for the record, there are 18 unique second letters with 59 first/third pairs, and 17 third letters with 39 first/second pairs)
|
|