|
|
|
|
Z80 |
8080 |
LD H,VALUE |
LX1 H,VALUE |
LD A,C |
MOV A,C |
DEC B |
DCR B |
|
|
|
|
|
|
|
Another ruling I set myself was to try NOT to use special multi-operation code specific to one processor, like the LDIR, LDDR, CPIR AND CPDR Z80 codes. These are very useful routines that perform multiple operations with the programmer simply entering values into certain specified registers and pressing the �Go� button. Really like a sub-routine already built into the processor. My last rule was to avoid �tidy� and elegant� pieces of coding that use �clever� techniques to achieve the required goal. Unfortunately they generally involve a measure of �Nellie knowledge� and therefore might not be well understood by someone new to the subject; thus all the coding here is SIMPLE to the extreme - BUT will enable the micro project builder to write his or her code that will work! There�ll be time to tidy up the code and make it look more �professional� at a later date. |
|
|
|
|
|
|
Sample of code used to begin initialising the 8530 SCC chip: |
|
|
|
Z80 HEX |
does what? |
6809 HEX |
does what? |
what are we attempting to achieve by this? |
3E |
LOAD A REG |
86h |
LOAD A REG |
The 8530 needs two instructions to allow the processor to talk to |
09 |
WITH 09h |
09h |
WITH 09h |
any of it�s many registers. Here we tell it we want access to Reg 9 |
D3 |
SEND TO |
B7h |
SEND TO |
We send this register �request� to the address of the control regs. |
21 |
I/O 21h |
80h |
ADDRESS |
for the �A� half of the SCC. Note that the Z80 uses a specific I/O |
3E |
LOAD A REG |
01h |
8001h |
address, in this case 21h, whereas the 6809 thinks of it as memory. |
C0 |
WITH C0H |
86h |
LOAD A REG |
This is the second part of the instruction where we now send the |
D3 |
SEND TO |
C0h |
WITH C0H |
value we want to send to Register 9. This instruction is a Reset. |
21 |
I/O 21h |
B7h |
SEND TO |
Note that the instruction is sent to the same address as before. The |
|
|
80h |
ADDRESS |
internal workings of the SCC will have directed the value where |
|
|
01h |
8001h |
we wish it to go. |
|
|
|
|
|
Whilst I�m afraid that it would be of little help to show the display load routine from the EEprom Programmer program as it incorporates the OUTI instruction which is unique to the Z80, so for this example I will show that used in the 8085 project - which will of course work equally well on the Z80 or the 8080. In keeping with my liking for retaining similarities in my designs, the addressing for the displays in both the Programmer and the 8085 Site Project are identical. Note that the �HL� pair is simply two 8 bit registers combined to form one single 16 bit one. Most processors have at least one that can perform this operation. In the case of the 6809, there are two indexed registers (the X and The Y) which may be used in a similar manner. Although users of the 6502 only have two single byte (8 bit) index registers, these have full increment, decrement and compare facilities, and may be used to transfer messages etc. if the lowest part, or the �Zero page� area of the memory is used. Essentially, it�s a case of getting to know and using to the full, the instructions that come with the micro you are planning on using. |
|
|
|
|
|
|
|
|
|
|
|
First and foremost, before this Display SUBROUTINE is run, the physical ADDRESS of the first byte of the 4 digit word to be outputted to the display has to be loaded into the HL register pair. The HL pair will then point to a 16 bit address in ROM or RAM, and place the contents into the ACCUMULATOR. In the case of these processors, namely the 8080, 8085 and the Z80, the op-code is a 21h with two further digits to tell it what immediate values to load into registers H and L. i.e: |
|
|
|
21h |
LOAD HL PAIR WITH |
|
68h |
68h (address low) |
Note that this series of micro, |
00h |
00h (address high) |
puts the LSW (the 68) FIRST |
|
|
|
If you are feeling really keen :) you can check the example above with the 8085 site project program listing at 0039/003A/003Bh |
|
|
|
IMPORTANT! Note that this program subroutine with it�s four digits is a border line case where it is questionable whether it would have been better to tidy up the code and use another register or memory location to keep track of the passes, thus making it only necessary to write the �Load/Send/Increment� bit only once.Obviously in the case of eight or more consecutive digits one would try not to write out the same piece of coding eight times over! |
|
|
|
|
|
|
|
|
Subroutine to display 4 x digits in one pass |
|
|
|
7Eh |
LOAD Accumulator with where HL is pointing (0068h here) |
D3h |
SEND TO I/O ADDRESS (display far LH digit) |
13h |
13h |
23h |
INCREMENT HL (from this example�s 0068h-0069h) |
7Eh |
LOAD Accumulator with where HL is pointing (0069h here) |
D3h |
SEND TO I/O ADDRESS |
12h |
12h |
23h |
INCREMENT HL (from this example�s 0069h-006Ah) |
7Eh |
LOAD Accumulator with where HL is pointing (006Ah here) |
D3h |
SEND TO I/O ADDRESS |
11h |
11h |
23h |
INCREMENT HL (from this example�s 006Ah-006Bh) |
7Eh |
LOAD Accumulator with where HL is pointing (006Bh here) |
D3h |
SEND TO I/O ADDRESS (display far RH digit) |
10h |
10h |
C9h |
RETURN FROM SUBROUTINE |
|
|
|
|
|