Nascom Newsletter |
Volume 2 · Number 5 · November 1982 |
Page 3 of 37 |
---|
Looking at the bit patterns for the Z80 instruction set (they are nicely tabulated in your Nascom manual … towards the back), you will notice that many groups of instructions use the middle three bite to represent a register, condition, arithmetic operation, or a number from 0 to 7 (for the bitwise operations)[r, c, a & n respectively].
Bits | r | c | n | a |
---|---|---|---|---|
000 | B | NZ | 0 | ADD A |
001 | C | Z | 1 | ADC |
010 | D | NC | 2 | SUB |
011 | E | C | 3 | SBC A |
100 | H | PO | 4 | AND |
101 | L | PE | 5 | XOR |
110 | INDIS | P | 6 | OR |
111 | A | M | 7 | CP |
INDIS represents an index register HL, IX or IY (and the displacement if necessary). A similar system operates with register pairs.
Bits | ss | ad |
---|---|---|
00 | BC | BC |
01 | DE | DE |
10 | IND | IND |
11 | SP | AF |
Where IND represents one of the index registers (HL, IX, IY) but with no displacements. Make sure that you understand this, because basically disassembley is analysis of bit patterns. I did not, and wrote a disassembler so complex even I could not make head nor tail of it!! These tables will have to go into tables in the computer as they are crucial. You will have to define a character to represent INDIS and IND as we don’t yet know which of the index registers to output!! Remember these as if they were arrays, eg. r(0) – r(7) etc.
The disassembler is going to need one vital piece of information before it starts. Elementary – where to start from. This can easily be done using the Nas-Sys routine ARGS. Load this disassembly address into BC’ (the alternate registers are identified by ’). This piece of your program is the first encountered on a run and is not used again. From now on the disassembley address is always in BC’. It must be the first byte of an instruction or else there will be havoc!! Next thing to do is to set STRDIS to an empty string.
Now there are two more variables – held also in the alternate registers (use D’ and E’) – to be initialised. Call one INDEX, the print routine will require this. The other call TYPE and this holds information as to whether the instruction began with £CB, £ED or neither. Set both these to zero. Take a deep breath and begin!!!
Page 3 of 37 |
---|