02 Mts-Z80a-Eb
02 Mts-Z80a-Eb
Hardware Configuration
1. Feature
(a) MTS-Z80A, a training kit using a 8-bit CPU Z80 of Zilog, has a built-in various peripherals
and do not use optional circuits.
(b) This tool can show data by using PC after down loading or inputting Data with the Keypad
(c) It supports step functions rind disassembling. The program inputted in machine codes by
the keypad can be run line-by-line or step-by-step.
(d) This hardware can be conducted by the Demo program stored in the Monitor Program.
(e) When you make a program, you can use input function from a keyboard of your. PC and
displaying to PC Program stored in the Monitor Program.
(f) This Kit is easy-to-use on account of built-in Power Supply. It also has free-voltage system.
2. Memory Map
(a) You can easily, understand the Memory Map of this Kit by referencing detailed sheets and
Demo program.
(b) The address 0000H - FFFFH is allocated to ROM, 8000H - FFFFH to RAM.
(c) You can refer to the table bellow which has detailed address map.
(d) USER Memory has the same address as ROM area which is for ROM writing.
Then if the ROM is 2764 or 27128, insert ROM into USER MEMORY and move the short bat
down ROM and turn on the kit. Then ROM of USER MEMORY with be driven, but if ROM is
27256, delete MONITOR ROM and immediately insert ROM and turn on the switch.
3. I/O Map
(a) I/O port address From A3 to A7 is connected to the recorder 74LS154 IC, and From A0 to
A2 is directly connected to reserved ICs. However the unconnected pin in A0 - A2 can (a)
I/O port address From A3 to A7 is be '1' or'0'. The default value is '0'.
(b) In the case of additioning I/O to System Bus, A7 should be set to '1'
1
Connected to Connected to
Physical
74LS154 corresponding IC Remark
Address
A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 0 X 0 0 00H A Port
0 0 0 0 0 X 0 1 01H B Port
EXT
0 0 0 0 0 X 1 0 02H C Port
0 0 0 0 0 X 1 1 03H CW
0 0 0 0 1 X X 0 08H I.R
LCD
0 0 0 0 1 X X 1 09H D.R
KEY 0 0 0 1 0 X X X 10H Key Input
KEY CLR 0 0 0 1 1 X X X 18H Key Buffer Clear
0 0 1 0 0 X 0 0 20H A Port
0 0 1 0 0 X 0 1 21H B Port
ROM WR
0 0 1 0 0 X 1 0 22H C Port
0 0 1 0 0 X 1 1 23H CW
0 0 1 0 1 X 0 0 28H A Port
0 0 1 0 1 X 0 1 29H B Port
DOT
0 0 1 0 1 X 1 0 2AH C Port
0 0 1 0 1 X 1 1 2BH CW
DAC 0 0 1 1 0 X X X 30H DAC0808
0 0 1 1 1 0 0 0 38H Channel 0
0 0 1 1 1 0 0 1 39H Channel 1
0 0 1 1 1 0 1 0 3AH Channel 2
0 0 1 1 1 0 1 1 3BH Channel 3
ADC
0 0 1 1 1 1 0 0 3CH Channel 4
0 0 1 1 1 1 0 1 3DH Channel 5
0 0 1 1 1 1 1 0 3EH Channel 6
0 0 1 1 1 1 1 1 3FH Channel 7
0 1 0 0 0 X X 0 40H Command
8251
0 1 0 0 0 x x 1 41H Data
0 1 0 0 1 X 0 0 48H Count 0
0 1 0 0 1 X 0 1 49H Count 1
CTC
0 1 0 0 1 X 1 0 4AH Count 2
0 1 0 0 1 X 1 1 4BH Command
LED 0 1 0 1 0 X X X 50H 8 Bit LED
SWITCH 0 1 0 1 1 X X X 58H 8 Bit Switch
FND 0 1 1 0 0 X X X 60H FND
STEP 0 1 1 0 1 X X X 68H Stepping Motor
SPK 0 1 1 1 0 X X X 70H Speaker
ROM CONT 0 1 1 1 1 X X X 78H ROM WR Control
2
Chapter 2. HOW TO USE TRAINING KIT
1. Selection of Keypad/Serial
For using MTS-Z80A, you should decide whether you use Keypad directly
or PC connected through RS-232C Serial.
2. Function of Keypad
C D E F
STEP
SZH PNC SZH' PNC
8 9 A B
INS
IX IY SP I
4 5 6 7
ADDR GO
AF' BC' DE' HL'
0 1 2 3
RESET INC
AF BC DE HL
3
: Validate and modify registers of MTS-Z80A for a single step.
REG
A non-used register is unimportant.
3. Method by Keypad
(a) Basic Use
When you turn on the kit, One message below will display
MTS-Z80A
K&H MFG.
As above mentioned, after the Kit is turned on or a Key is pushed with holding the
RESET Key, the current mode will turn into the Serial mode. Then you cannot use the
Keypad.
A few seconds after not pushing the key, the mode will turn into the Keypad Mode and
the LCD will display as follows. After reset the address will be set to the address '8000H'
which is the starting address of RAM.
Addr. Data
8000 FF
4
(b) Data Confirmation
Without inserting data you cannot know what data of the address is in it.
Addr. Data : A few seconds after reset the data of the address
RESET
8000 FF_ '8000H' will display.
Addr. Data : The address increases by 1 the data of the address will
INC
8001 FF_ display.
Addr. Data : The address increases by 1 the data of the address will
INC
8002 FF_ display.
Addr. Data
RESET
8000 FF_
5
(d) Validating and Modifying Registers
This section is only validating and modifying registers for a single step.
Unused register has no meaning. You don't still need to know the name and function
of a register. Let's change data of AF register to'1234H'.
Addr. Data
RESET
8000 12_
PC:8000 SP:FF00
REG
F:FF:SZHVNC
0 REGISTER MODIFY : You should change all the bits(16 bits) of the
AF AF:FFFF_ register.
1 REGISTER MODIFY
BC AF:FFF1_
2 REGISTER MODIFY
DE AF:FF12_
3 REGISTER MODIFY
HL AF:F123_
4 REGISTER MODIFY
AF’ AF:1234_
6
(e) Modifying and Running an Address
You should input 4-digits of 16-bit to modify an address.
First, let's run the example given in the Monitor ROM.
The starting address of the program for flikering LED.
Addr. Data
RESET : After reset, the address will be '8000H'
8000 FF_
Addr. Data : The cursor shifts the address part by pressing the
ADDR
8000_ FF ADDR key
0 Addr. Data
AF 0050_ C3
1 Addr. Data
BC 0501_ 20
0 Addr. Data
AF 5010_ 21
7
(f) INS, DEL Function
INS and DEL are the functions INSERT and DELETE respectively,
which functions can help correcting typing errors. For example, when the address is not
correct by pushing the INC key twice or more, you can delete the data by pushing the
DEL key. Moreover,
when you want to insert data of an specific address you can do it by pushing the INS
key.
Let's start from 8000H and test INC, DEL functions.
Addr. Data
RESET : After reset, the address will be '8000H'
8000 FF_
0 Addr. Data
AF 8000 F0_
0 Addr. Data
AF 8000 00_
Addr. Data
INC
8001 FF_
1 Addr. Data
BC 8001 F1_
1 Addr. Data
BC 8001 11_
Addr. Data
INC
8002 FF_
Addr. Data : By pushing the INC key once again, you omit the data
INC
8003 FF_ of 8002H.
2 Addr. Data
DE 8003 F2_
2 Addr. Data
DE 8003 22_
8
Addr. Data
INC
8004 FF_
4 Addr. Data
AF’ 8004 F4_
4 Addr. Data
AF’ 8004 44_
Addr. Data
INC’
8005 FF_
4 Addr. Data
AF’ 8004 44_
5 Addr. Data
BC’ 8005 F5_
5 Addr. Data
BC’ 8005 55_
Addr. Data
RESET : After reset, the address will be '8000H'
8000 00_
Addr. Data
INC
8001 11_
Addr. Data
INC
8002 FF_
Addr. Data
DEL : Delete the data of the address 8002H
8002 22_
Addr. Data
INC
8003 44_
9
3 Addr. Data
HL 8003 03_
3 Addr. Data
HL 8003 33_
Addr. Data
INC
8004 44_
Addr. Data
INC
8005 55_
Addr. Data
RESET : Check one again if it is well- corrected.
8000 00_
Addr. Data
INC
8001 11_
Addr. Data
INC
8002 22_
Addr. Data
INC
8003 33_
Addr. Data
INC
8004 44_
Addr. Data
INC
8005 55_
10
Chapter 3. CPU Architecture
1. Z80 CPU
(a) Description of function of Each Pin
11
Functions for each pin as followings.
Name of a Pin Action Description
A15 - A0 Addressing Addressing memory or I/O
Receiving or transmitting data
D7 - D0 Input and output of Data
to/from Memory or I/O
/MREQ Connecting CPU to Memory is selected when 'L' sign
(MEMORY REQUEST) data bus of Memory appears
/IORQ Connecting CPU to I/O is selected when 'L' sign
(I/O REQUEST) data bus of I/O appears
/RD CPU decodes the Data Memory or I/O is selected
(READ) from Memory, or I/O by MREQ or IORQ signal
/WR CPU outputs data from Memory or I/O is selected
(WRITE) Memory or I/O by MREQ or IORQ signal
For 'L' sign,
CPU will make the Bus high
Impedance when the currently
/BUSRQ Request the Bus Open currently running machine cycle
(BUS REQUEST) For use finish.
Namely, it is in disconnection.
Then the access to control is
Given to the External.
When CPU accepts BUSRQ signal
/BUSAK
Check if the Bus is and makes it high impedance.
(BUS
Open Then CPU outputs 'L' sign to
ACKNOWLEDGE)
Notify that the Bus is open.
By 'L' sign,
/INT(INTERRUPT) Request interrupt
CPU is requested to interrupt.
When the signal High goes to
Low, CPU is requested for NMI.
/NMI(NON MASKABLE
Request NMI Using EI or DI, INT interrupt signal
INTERRUPT)
can prevent interrupt, but NMI is a
uninterruptable signal.
Reflash signal for the
/RFSH Reflash
Dynamic RAM
In order to synchronize the speed
/WAIT Wait of slower Memory and I/O, CPU
signal is delayed.
/HALT Halt Notify that CPU is Halt
The speed of CPU depends on
this signal. the lowest value of 'H'
CLK Clock level is 0.6V.
Therefore, 330 Ohm is pulled-up
To apply.
When 3 clocks are applied 'L'
sign, CPU will be reset and
/RESET Reset
PC(program counter)
Goes to '0000H'.
12
(b) Clock Generating Circuit
Clock is generated at 2.4575MHz using crystal. It is provided
CPU with 330 Ohm pull-up resistance.
It is also used for Serial communications by division.
13
(e) Registers Configuration of Z80-CPU
2) Instruction Execution
According to the data of IR, a Program will be executed, then the control signals
corresponding to each instruction are outputed. In that way, arithmetic operation and
transmission instructions are executed.
14
1 byte command OP code Ex) CPL
OP code1 OP code2 CPDR, INDR
2 byte command
OP code1 Operand CP 98H
OP code1 OP code2 Displayment AND (IX+d)
3 byte command
OP code1 Operand Operand LD HL,1234H
OP code1 OP code2 Operand Operand LD IX,(nn)
4 byte command
OP code Operand Displayment Operand BIT 1,(IX+d)
15
Chapter 4. Data Transmission Instruction
16
(b) Extend Addressing
LD ss,(nn) : This addressing is the method that moves between pair register(or
16-bit register) and 2 bytes data to a destination.
eq) Let's make the instruction which stare 1234H in BC
LD BC,(1234H)
※ Then, the data of ‘1234H’ are transmitted to C register and the data' of 1234H+1
(1235H) are transmitted to B register.
11011101 DD
LD r,(IX+d) r←(IX+d) * * * * * * 01rrr110 3 5 19
<- d ->
17
3. Other Methods of Addressing(except transmission instructions)
(a) Modified Page Zero addressing
RST n : In this addressing, a specific RST n designates the address n.
eq) if there in RST 10H, it will jump to 0010H
4. Test I
In order to store the follow value, let's make the program by using a 8-bit data
Transmission instruction and execute from the training kit.
A=00H, B=12H, C=34H, D=34H
18
Test 1-3. Assign the address. Allocate addresses from 8000H because the user
programing area is from 8000H to FEEEH. Then insert the starting address of
each line.
Address Machine Code Mnemonic Description
8000 3E 00 LD A,00H ; transmits 00H to A
8002 06 12 LD B,12H ; transmits 12H to B
8004 0E 34 LD C,34H ; transmits 34H to C
8006 51 LD D,C ; transmits (or copy) the data of C to D
8007 CF RST 08H ; return to the Monitor
Test 1-4. Let's insert the program into the training kit.
3 E Addr. Data
HL SZ·H’ 8000 3E_
0 0 Addr. Data
INC
AF AF 8001 00_
0 6 Addr. Data
INC
AF DE’ 8002 06_
1 2 Addr. Data
INC
BC DE 8003 12_
0 E Addr. Data
INC
AF SZ·H’ 8004 0E_
3 4 Addr. Data
INC
HL AF’ 8005 34_
5 1 Addr. Data
INC
BC’ BC 8006 51_
C F Addr. Data
INC
SZ·H ·PNC’ 8007 CF_
19
Test 1-5. Let's insert the program into the training kit
8 0 0 0 Addr. Data
ADDR
IX AF AF AF 8000 3E_
※ You can use RESET key instead of ADDR 8000H
PC:8000 3E 00
STEP : Nothing executes yet
LD A,00H
AF:00FF BC:FFFF
INC : checking the next register
DE:FFFF HL:FFFF
PC:8004 0E 34
STEP : LD B,12H has been executed
LD C,34H
AF:00FF BC:12FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:8004 0E 34
STEP : display the current status
LD C,34H
PC:8006 51
STEP : LD C,34H has been executed
LD D,C
20
: showing the current program counter PC:8006 SP:FF00
REG
stack pointer and flag register F:FF:SZHVNC
AF:00FF BC:1234
INC : checking the next register
DE:FFFF HL:FFFF
PC:8006 51
STEP : display the current status
LD D,C
PC:8007 CF
STEP : LD D,C has been executed
RST 08H
AF:00FF BC:1234
INC : checking the next register
DE:34FF HL:FFFF
5. Test 2
In order to store the follow value, let's make the program by using a 16-bit data
transmission
instruction and execute from the training kit.
BC=1234H, DE=5678H, HL=5678
21
※ MSBs and LSBs of 16-bit register or its data should be exchanged.
Test 2-3. Let's insert the program into the training kit.
0 1 Addr. Data
AF BC 8001 01_
3 4 Addr. Data
INC
HL AF’ 8001 34_
1 2 Addr. Data
INC
BC DE 8002 12_
1 1 Addr. Data
INC
BC BC 8003 11_
7 8 Addr. Data
INC
HL’ IX 8004 78_
5 6 Addr. Data
INC
BC’ DE’ 8005 56_
6 2 Addr. Data
INC
DE’ DE 8006 62_
6 B Addr. Data
INC
DE’ I 8007 6B_
C F Addr. Data
INC
SZ·H ·PNC’ 8008 CF_
22
Test 2-4. Let's see the state of the registers while executing the program using the single
step function.
PC:8000 01 34 12
STEP : Nothing executes yet
LD BC,1234H
AF:FFFF BC:1234
INC : checking the next register
DE:FFFF HL:FFFF
PC:8006 62
STEP : LD DE,5678H has been executed
LD H,D
AF:FFFF BC:1234
INC : checking the next register
DE:5678 HL:FFFF
PC:8006 62
STEP : display the current status
LD H,D
PC:8007 6B
STEP : LD H,D has been executed
LD L,E
PC:8007 6B
STEP : display the current status
LD L,E
PC:8008 CF
STEP : LD L,E has been executed
RST 08H
AF:FFFF BC:1234
INC : checking the next register
DE:5678 HL:5678
6. Test 3
Let's analysis the following program and predict the value of BC register. Then insert the
program into the training kit and execute in order to compare the result to the predicted
value. 'INC HL' and 'INC A' are the instructions which increment the designated address
by 1.
Test 3-1. Let's analysis the following program. Setting a stack pointer is important, but let's
skip this procedure in this example. a stack pointer should be the address plus 1, so in
MTS-Z80A it is correct to set the stack pointer to FF00H. (the last address is FFFFH, but
Monitor program uses the address area from FF00H Ultimately the last user address
should be FEFFH. Then Adding 1 becomes FF00H)
24
Test 3-2. Let's insert the program to the training kit and execute the program step-by-step
using the single step function. While at that, see the change of registers and data.(Input
method of the program is the same as mentioned in the previous sections)
PC:8000 31 00 90
STEP : Nothing executes yet
LD SP,9000H
PC:8003 21 20 80
STEP : LD SP,9000H has been executed
LD HL,8020H
PC:8003 21 20 80
STEP : display the current status
LD HL,8020H
PC:8006 3E 98
STEP : LD HL,8020H has been executed
LD A,98H
AF:FFFF BC:FFFF
INC : checking the next register
DE:FFFF HL:8020
PC:8006 3E 98
STEP : display the current status
LD A,98H
PC:8008 77
STEP : LD A,98H has been executed
LD (HL),A
25
AF:98FF BC:FFFF
INC : checking the next register
DE:FFFF HL:8020
PC:8008 77
STEP : display the current status
LD (HL),A
PC:8009 23
STEP : LD (HL),A has been executed
INC HL
8 0 2 0 Addr. Data
ADDR
IX AF DE AF 8020 98_
※ In the case of checking the data of Memory while executing single step, you should set
again the last address of checking the data before. Then execute single step.
8 0 0 9 Addr. Data
ADDR
IX AF AF IY 8009 23_
PC:8009 23
STEP : display the current status
INC HL
PC:800A 3C
STEP : INC HL has been executed
INC A
AF:98FF BC:FFFF
INC : checking the next register
DE:FFFF HL:8021
PC:800A 3C
STEP : display the current status
INC A
PC:800B 77
STEP : INC A has been executed
LD (HL),A
26
AF:9989 BC:FFFF
INC : checking the next register
DE:FFFF HL:8021
PC:800B 77
STEP : display the current status
LD (HL),A
PC:800C ED 4B 20 80
STEP : LD (HL),A has been executed
LD BC,(8020H)
8 0 2 1 Addr. Data
ADDR
IX AF DE BC 8021 99_
8 0 0 C Addr. Data
ADDR
IX AF AF SZ·H 800C ED_
PC:800C ED 4B 20 80
STEP : display the current status
LD BC.(8020H)
PC:8010 CF
STEP : LD BC,(8020H) has been executed
RST 08H
AF:9989 BC:9998
INC : checking the next register
DE:FFFF HL:8021
※ After executing the single step, you checked that BC register
has 9998H. Is that the same as the predicted value?
27
Chapter 5. Logic and Arithmetic Instructions
1. Flag Register
You should understand registers very well in order to efficiently use the arithmetic
instructions. The following details flag registers.
BIT
7 6 5 4 3 2 1 0
NO.
Sign S Z H P/V N C
Carry Flag
Negative Flag
Zero Flag
Sign Flag
※ has no mean
28
(c) P/V(Parity/overflow) Flag
This flag has the following functions.
① Parity Flag : Logical operations affect this flag with the parity of the result while
arithmetic operations affect this flag with the overflow of the result. If P/V holds parity,
P/V =1 if the result of the operation is even. P/V = 0 if the result is odd. If the P/V holds
overflow, P/V = 1 if the result of the operation produced an overflow.
② Overflow Flag : If the P/V holds overflow, P/V = 1 if the result of the operation produced
an overflow(the limit is -128~1127, for 16-bit operation -32768 ~ +32767)
③ Block Transfer instruction : checks if the register(B or BC) for using block transfer or
search instruction is 0 or not.
④ Checking the status of Interrupt Enable Flag : By using "LD A,I" or "LD A,R", You can
check the status of the flag because the content of the interrupt enable flip-flop(IFF2) is
copied into the P/V flag.
29
2. 8-bit Arithmetic instructions
30
3. 16-bit Arithmetic instructions
(a) Increment, Decrement instruction (INC, DEC)
store the data in registers or the memory by incrementing and decrementing. Importantly, in
16-bit INC, DEC Carry Flag doesn't change, so you should consider it.
31
(c) Rotate, Shift instruction (RL, RLC, RLA, RLCA etc)
① RL, RR instruction : In RL instruction, the register or the data of the Memory shifts 1 bit
left and the MSB goes into the Carry Flag. Then the Carry flag which is generated
preceding the instruction moves into the LSB. In RR instruction, the register or the data
of the Memory shifts 1 bit right and the LSB goes into the Carry Flag. Then the Carry
flag which is generated preceding the instruction moves into the LSB.
Cy MSB LSB
RL
MSB LSB Cy
RR
② RLC, RRC instruction : In RLC instruction, the register or the data of the Memory shifts
1 bit left and the MSB goes into the LSB with the Carry Flag. In RRC instruction, the
register or the data of the Memory shift 1 bit right and the LSB goes into the MSB with
the Carry Flag.
Cy MSB LSB
RLC
MSB LSB Cy
RRC
③ RLA, RRA : RLA and RRA respectively is the same as RL r and RR r instruction when
r register is A register, but the length is shorter, the execution speed is faster. The
change of the flag register is a little bit different.
④ RLCA, RRCA : RLCA and RRCA respectively is the same as RLC r and RRC r
instruction when r register is A register but the length is shorter, the execution speed is
32
⑥ SLA, SRA, SRL : These instructions are hard to understand, so very careful attention
is required to make a program. In SLA instruction the register or the data of the
Memory shifts 1 bit left and the MSB goes into the Carry Flag. 0 goes into the MSB. In
SRA instruction, the register or the data of the Memory shifts 1 bit right and the MSB
before shift is copied into the MSB after shift. LSB goes into the Carry Flag.
Cy MSB LSB
SLA
MSB LSB Cy
SRA
MSB LSB Cy
SRL
⑦ RLD, RRD : In RLD instruction, the data that A and HL register circles 4-bit left. 4 bit of
the MSB of A register doesn't change. RRD instruction, like RLD circles right.
RLD
RRD
33
5. Test 1
Analyses the following program and record the change of the flag register and A register.
Let's input the program into the training kit and execute it.(a).
Test 1-1. Analysis the following program and make the table of the of the prediction
value.
Prediction Result
Register Flag Register Flag
Address Mnemonic
A S Z H V N C A S Z H V N C
8000 LD SP,9000H 00 1 1 1 1 1 1 00 1 1 1 1 1 1
8003 AND A
8004 LD B,09H
8006 LD A,0FFH
8008 INC A
8009 ADC A,B
800A XOR A
800B ADD A,B
800C ADD A,88H
800E SCF
800F SBC 33H
8011 SUB 25H
34
Test 1-2. Input the program into the training kit. Then execute the program step-by-step
by using single step function an observe the change of the registers.
PC:8000 SP:FF00
REG : check the register
F:FF:SZHVNC
0 REGISTER MODIFY!
: modify the AF resister
AF AF : FFFF_
0 0 F F REGISTER MODIFY!
AF AF ·PNC’ ·PNC’ AF : 00FF_
PC:8000 SP:FF00
REG : check the register
F:FF:SZHVNC
1 REGISTER MODIFY!
: modify the BC resister
BC BC : FFFF_
0 0 F F REGISTER MODIFY!
AF AF ·PNC’ ·PNC’ BC : 00FF_
PC:8003 A7
STEP : LD SP,9000H has been executed
AND A
PC:8004 06 09
STEP : AND A has been executed
LD B,09H
35
AF:0054 BC:00FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:8004 06 09
STEP : display the current status
LD B,09H
PC:8006 3E FF
STEP : LD B,09H has been executed
LD A,FFH
AF:0054 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:8006 3E FF
STEP : display the current status
LD A,FFH
PC:8008 3C
STEP : LD A,FFH has been executed
INC A
AF:FF54 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:8008 3C
STEP : display the current status
INC A
PC:8009 88
STEP : INC A has been executed
ADC A,B
36
AF:0050 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:8009 88
STEP : display the current status
ADC A,B
PC:800A AF
STEP : ADC A,B has been executed
XOR A
AF:0908 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:800A AF
STEP : display the current status
XOR A
PC:800B 80
STEP : XOR A has been executed
ADD A,B
AF:0044 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:800B 80
STEP : display the current status
ADD A,B
PC:800C C6 88
STEP : ADD A,B has been executed
ADD A,88H
AF:0908 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
37
PC:800C C6 88
STEP : display the current status
ADD A,88H
PC:800E 37
STEP : ADD A,88H has been executed
SCF
AF:9190 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:800E 37
STEP : display the current status
SCF
PC:800F DE 33
STEP : SCF has been executed
SBC A,33H
AF:9181 BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
PC:800F DE 33
STEP : display the current status
SBC A,33H
PC:8011 D6 25
STEP : SBC A,33H has been executed
SUB 25H
AF:5D1E BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
38
PC:8011 D6 25
STEP : display the current status
SUB 25H
PC:8013 CF
STEP : SUB 25H has been executed
RST 08H
AF:382A BC:09FF
INC : checking the next register
DE:FFFF HL:FFFF
39
Chapter 6. Jump Instructions
1. Program Counter
Z80-CPU has the Program counter register. This register has the address of the next
instruction. After system reset, it returns to 0000H. Whenever CPU fetches the
instruction from the memory address to which PC points, PC is incremented. When jump
or call instructions are executed or the interrupt signal is received, the new address is
loaded to PC.
4. Test 1
Test 1-1. Analyses the following program to know what the program does.
Test 1-2. Insert the program into the Kit and execute the program by pushing GO key.
Then see what the result is. Inserting 'RST 08H' at the last address of the program
and Pushing Go key has the same result as setting the breakpoint at the address
which has RST 08H. Namely all the registers are already stored right after RST 08H
executes, so you can check by pushing the REG key. If the RESET key is pushed,
the stack pointer changes to FF00H without changing other registers. By using Go
function execute the program at once, but for training, single step function is used.
When you execute the program step-by-step, you can see the mnemonic DJNZ
8008H at 800BH. The exact notation is DJNZ FBH, but it was changed to help the
user disassemble the program from the Monitor program using single step function.
41
RESE Addr. Data
T 8000 31_
Addr. Data
GO
800D CF_
8 1 0 0 Addr. Data
ADDR
IX BC AF AF 8100 00_
Addr. Data
INC
8101 01_
Addr. Data
INC
8102 02_
Addr. Data
INC
8103 03_
- - - - - - - - - - - - - - - omitted - - - - - - - - - - - - - - - - - - - - - - - - - - -
Addr. Data
INC
81FD FD_
Addr. Data
INC
81FE FE_
Addr. Data
INC
81FF FF_
42
5. Test 2
Test 2-1. Analyses the following program to know what the program does.
Then compare that with Test 1
43
Test 1-2. Insert the program into the Kit and execute the program by pushing GO key.
Then see what the result is.
Addr. Data
GO
8010 CF_
8 1 0 0 Addr. Data
ADDR
IX BC AF AF 8100 00_
Addr. Data
INC
8101 01_
Addr. Data
INC
8102 02_
Addr. Data
INC
8103 03_
- - - - - - - - - - - - - - - omitted - - - - - - - - - - - - - - - - - - - - - - - - - - -
Addr. Data
INC
8161 97_
Addr. Data
INC
8162 98_
Addr. Data
INC
8163 99_
44
Chapter 7. Stack and Subroutine
1. Stack Pointer
(a) Stack
Stack is the place that the data of registers is stored in the temporary memory or the
return address of subroutine call is stored. In the stack, the data that are first stored in
are first poked out.
2. Subroutine
Subroutine is the block of instructions which the programmer names after.
The subroutine jumps to the routine by the call instruction, and by the return instruction(RET)
returns to the main Program. When jumping to the routine the call instruction points to, CPU
stores the return address in the stack and jumps.
If the programmer do the same program above, CPU jumps to the address's 8100H with
the execution of RET.
45
(b) Conditional Call1 and Return(CALL, RET)
When the condition is in accord, the conditional CALL instruction calls the subroutine,
otherwise the next instruction is continued. RET also returns if the condition is not in
accord, otherwise the next instruction is continued. The conditions for conditional CALL
and RET as follows.
cc(Condition code) related flag
NZ(Non Zero)
Zero Flag
Z(Zero)
NC(Non Carry)
Carry Flag
C(Carry)
PO(Parity Odd)
Parity Flag
PE(Parity Even)
P(Plus)
Sign Flag
M(Minus)
3. Test 1
Test 1-1. Analyse the following program to know what the program does. Then predict
the values of A, BC, DE, HL in the end of the program.
46
Test 1-2. Insert the program into the Kit and execute the program by pushing GO key.
Then see what the result is.
Addr. Data
GO
8019 CF_
AF:2442 BC:0000
INC : checking the next register
DE:8100 HL:8124
8 1 0 0 Addr. Data
ADDR
IX BC AF AF 8100 00_
Addr. Data
INC
8101 01_
Addr. Data
INC
8102 02_
Addr. Data
INC
8103 03_
- - - - - - - - - - - - - - - omitted - - - - - - - - - - - - - - - - - - - - - - - - - - -
Addr. Data
INC
8122 22_
Addr. Data
INC
8123 23_
Addr. Data
INC
8124 FF_
47
Chapter 8. Other Instructions
1. HALT instruction
When the HALT instruction executes, CPU repeats NOP instruction in order to keep the
Dynamic RAM reflash until CPU accepts the interrupt or the reset signal of the Hardware.
3. RST instruction(Restart)
This instruction consists of 1 byte op-code and executes CALL instruction. From the
following table, 3 bit combination corresponding to ttt can make 8 addresses( the
combination: 00H, 08H, 10H, 18H, 20H, 28H, 30H, 38H)
Eq.) RST 08H performs the same action as CALL 0008H, but unlike CALL instruction,
it is a 1 byte instruction
4.Input/output Instruction(IN,OUT)
MTS-Z80A consists of lots of external device such as LCD, PPI, CTC, which is called I/O
device. These I/O device writes and reads the data to/from the external.
IN A,(n) : write the data from the externals to A register. n is the 8-bit address of I/O
device.
IN r,(C) : write t C register points to.
OUT (n),A : output the 8-bit data of the pointed I/O register to A register r(any of B, C, D,
E, H, L,4) from the I/O device theater.
OUT C,r : output the data to a r register to the I/O device that C register points to.
48
5. Block Input/Output Instruction(INI, IDHR, IND etc)
① INI : receive the data from the I/O device that C register points to, store the data at
the address HL register points to. HL register increments and B register decrements.
Then Z = 1 if B register is zero, otherwise Z = 0.
② IND : the same as INI, but HL register decrements.
③ INIR : repeat INI instruction until B register is zero.
① INDR : repeat IND instruction until B register is zero.
⑥ OUTI : output the data of the address pointed by HL register to the I/O device that C
register points to. HL register increments and B register decrements. Then Z = 1 if B
register is zero, otherwise Z = 0.
⑥ OUTD : the same as OUTI, but HL register decrements.
⑦ OTIR : repeat OUTI instruction until B register is zero.
⑧ OTDR : repeat OUTD instruction until B register is zero.
① LDI : transfer the data of the Memory pointed by HL register to the Memory at the address
HL register points to. HL and DE register increment, and BC register decrements. Then Z =
1 if B register is zero, otherwise Z = 0.
② LDIR : repeat LDI instruction until BC register is zero.
③ LDD : the same as LDI, but HL and DE register decrement.
④ LDDR : repeat LDD instruction until BC register is zero.
49
Chapter 9. Interrupt
1. Z80 Interrupt
Z80-CPU has non-maskable interrupts(NMI) and maskable interrupts(INT Non-
maskable interrupt is prior to all the other interrupts and it is used for protecting the
system from power cut or black-out.
3. Maskable Interrupt
Z80-CPU has 3 types of maskable interrupts(INT). These maskable interrupts allows the
programer to use El(Enable Interrupt) and Dl(disable Interrupt) instructions in order to
acknowledge or forbid. The control to acknowledge or forbid is done by two interrupt
enable flip-flops IFF1 and IFF2. If Z80-CPU is reset or DI instruction executes, the two
flip-flops are reset. If EI instruction execute, the two flip-flops are set. Once the two
flip-flops are reset. the interrupts is acknowledged. Nevertheless, the reason that there
are two filly-flops is the presence of NMI. If CPU receives NMI, IFF1 is reset. IFF2
doesn't change and indicates IFF1 before NMI requests. NMI is forbidden because IFF1
is reset. When NMI routine has finished, RETN instruction needs to execute. Then by this
instruction the status of IFF2 is copied into IFF1. Namely it returns to the routine just
before NMI interrupt occurs. After that it restores the PC in the stack and returns to the
previous routine. When the maskable interrupt routine halts, RETI instruction executes.
4. Mode 0 Interrupt
Z80-CPU is set to Interrupt Mode 0 when it is reset or IM0 instruction executes. Mode 0
interrupt is the mode that pheriparals transmits instructions through Bus. There is 1 byte
RST(Restart) and 3 byte CALL instruction of the types of instruction. RST is used most.
5. Mode 1 Interrupt
When IM1 instruction executes, the Mode is set to the interrupt Mode 1. If the interrupt
apply, CPU stores PC into the stack and jumps to 0038H. MTS-Z80A reads the address
from the Memory at FF04H and FF05H. For the start, the Monitor Programs is supposed
to jump to the starting address, namely it acts as RESET key is phased.
50
6. Mode 2 Interrupt
When IM2 instruction executes, the Mode is set to the interrupt Mode 2. The Mode 2
interrupt is called the vector interrupt. I register of Z80 registers is only used for Mode 2
interrupt. When the interrupt occurs, I register becomes the MSB of the vector. This
mode is only designed for Z80 family IC(8420, 8430 etc).
51
Chapter 10. Assembler
1. Z80 Assembler
Until now you has practised by hand assembling on the keypad. From now on, let's
practise using Editor program on the personal computer. At first, write the source
program and assemble it and compile it to HEX format. Then by using the serial monitor,
load the program into the training kit.
52
2. Writing the Source Program
(a) Write the source program by using the editor program.
To edit the source code, simply edit it under any text editor, such as Notepad or Microsoft
Word. BE SURE that the file is saved with the extension of [ASM]. Creates a new file. Here
file name is EXAM.ASM.
After finishing input of the program, to save the file. Like that, after input in the source file, you
can assemble the program by using the Z80 Assembler.
The following step is to convert the assemble code [EXAM.ASM] to machine code
[EXAM.HEX].It is supported in Windows XP/7 32bits OS. Refer to Appendix 1 if your OS is
Windows 7 64 bits.
53
Step 1: Create a new folder on C:\ , and rename it “MTS80A”.
Step 2: Put your assembly code [*.asm] and assembler (X80.exe and LINK80.exe)
in this folder.
Step 3: Double click [X80.EXE] and type the source program(EXAM) in Input Filename.
Step 4: Press [Enter] twice. The object file [EXAM.OBJ] will be shown in the same folder.
54
Step 5: Double click [LINK80.EXE] and type the .obj file(EXAM.obj) and then click Enter 5
times to finish the link process.
Step 6: The hexadecimal file [EXAM.HEX] will be shown in the same folder. To download the
program into Z80 chip.
55
Chapter 11. How to Use the Serial Monitor
>From now on, execute the program by transmitting the data to MTS-Z80A through RS -232c
communication.
1. Communication Program
Use the “Hyper Terminal” communication program. It is supported in Windows XP OS.
Refer to Appendix 2 if your OS is Windows 7.
If it is connected to COM 2 of PC, change to COM2 and save the settings. Then check if the
short bar Is plugged on the upper tilde of BUAD RATE which is on the MTS-Z80A board.
After preparing, push RESET key on the MTS-Z80A and push Hexa Key. Then it shows as
follows.
Serial Monitor
K&H MFG.
MTS-Z80A > H↵
###### HELP ######
1. Load from PC
L : Load program from PC through serial cable.
56
2. Memory Dump
D[start] , [end] : Dump the contents of memory to the display
Ex) D8000
3. Trace, Step execution of program
T or T[Count]
S or S[Count] : Trace the execution of the specified number
of instruction.
Ex) T05 or S10
4. Program Execution
G : runs the program.
Start Address is Reg.PC
5. Program Execution
G[Break Point] : runs the program.
and terminates at Break Point.
You must be careful to choose Break Point.
Start Address is Reg.PC
Ex) G8080
6. Move
M start, end, destination : Move a block of data from a source
location in memory to a destination location.
Ex) M8000, 800F, 9000
7 Fill
F Start, End, Data : Fill a block in memory with the data.
Ex) F9000, 90FF, 98
8. Edit
E[Start] : Examine or modify the contents of memory
You can use <SPACE>, <.> for skipping.
Ex) E8080
57
9. Register Check or Modify
10. Disassemble
U or U[Count] : Disassemble the contents of memory
Defaults = 20 Lines
I2. Clear
CLS : Clear the Monitor of PC.
* If you want to know more, contact Your Manual.
MTS-Z80A >
① LOAD
The instruction that transmits *.HEX file generated by assembling from PC to the training
kit.
MTS-Z80A > L↵
Then Press ? in order to allow the PC to transmit the data. Then send file' menu will
appear. On that menu select 'send' and input the file name. You can see the procedure of
transmitting to PC by the sign *. When you downloads the file, the data of the Memory after the
data loading fills with FFH. Then the Program Counter turns to 8000H.
**
PC SZ-H-VNC A BC DE HL IX IY SP I
8000:310090 11111111 FF FFFF FFFF FFFF FFFF FFFF FFFF FF
LD SP,9000H 11111111 FF FFFF FFFF FFFF
MTS-Z80A >
The data on PC has been transmitted to the MTS-Z80A training kit
58
② Go and GOTO
The transmitted Program can be executed by the GO, GOTO, STEP, TRACE. GO
instruction executes first the Program at the Program counter, GOTO instruction starts the
program at the current address and stops the execution at the address the user defines. Then
the address the user defines is called break points.
MTS-Z80A > G↵
Program Counter = 8000H
MTS-Z80A >
If execute GO instruction, the current address appears on the Monitor and executes the
program. Let's execute GO instruction The important thing is, the break points should be at the
starting address. Because the program counter has changed, change PC to 8000H and
execute GOTO instruction.
then stop the program at 8011H
PC SZ-H-VNC A BC DE HL IX IY SP I
8011:CD1A80 00000000 05 0006 FFFF 8105 FFFF FFFF 8FFF FF
CALL 801AH 11111111 FF FFFF FFFF FFFF
MTS-Z80A >
stop the Program, and display the value of each register at the time it stops.
59
one step. Unlike TRACE, STEP runs all the steps and the next step of the CALL instruction. It
helps trace the time delayed subroutine such as TIMER.
MTS-Z80A > T↵ : After that, TRACE function executes by only pressing ENTER
PC SZ-H-VNC A BC DE HL IX IY SP I
8003:4F 11111111 FF FFFF FFFF FFFF FFFF FFFF 9000 FF
XOR A 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
8006:0E06 01000100 00 FFFF FFFF FFFF FFFF FFFF 9000 FF
LD C,06H 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
8006:210081 01000100 00 FF06 FFFF FFFF FFFF FFFF 9000 FF
LD HL,8100H 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
8009:E5 01000100 00 FF06 FFFF 8100 FFFF FFFF 9000 FF
PUSH HL 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
800A:0605 01000100 00 FF06 FFFF 8100 FFFF FFFF 8FFE FF
LD B,05H 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
800C:CD1A80 01000100 00 0506 FFFF 8100 FFFF FFFF 8FFE FF
CALL 801AH 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
801A:77 01000100 00 0506 FFFF 8100 FFFF FFFF 8FFC FF
LD (HL), A 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
801B:23 01000100 00 0506 FFFF 8100 FFFF FFFF 8FFC FF
INC HL 11111111 FF FFFF FFFF FFFF
60
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
801C:3C 01000100 00 0506 FFFF 8101 FFFF FFFF 8FFC FF
INC A 11111111 FF FFFF FFFF FFFF
MTS-Z80A > ↵
PC SZ-H-VNC A BC DE HL IX IY SP I
801D:C9 00000000 01 0506 FFFF 8101 FFFF FFFF 8FFC FF
INC A 11111111 FF FFFF FFFF FFFF
MTS-Z80A > : For DJNZ 800CH, DJNZ FBH is originally the right expression.
However in order easily to trace it is disassembled.
PC SZ-H-VNC A BC DE HL IX IY SP I
800F:10FB 00000000 01 0506 FFFF 8101 FFFF FFFF 8FFE FF
DJNZ 800CH 11111111 FF FFFF FFFF FFFF
MTS-Z80A > S↵ : After that, STEP function executes by only pressing ENTER
: In TRACE instruction, the fact that CALL instruction also executes
one step
: Let's execute STEP function and see the difference.
PC SZ-H-VNC A BC DE HL IX IY SP I
800C:CDIA80 00000000 01 0406 FFFF 8101 FFFF FFFF 8FFE FF
CALL 801AH 11111111 FF FFFF FFFF FFFF
MTS-Z80A > (
PC SZ-H-VNC A BC DE HL IX IY SP I
800F:10FB 00000000 02 0406 FFFF 8102 FFFF FFFF 8FFE FF
INC A 11111111 FF FFFF FFFF FFFF
MTS-Z80A > (
PC SZ-H-VNC A BC DE HL IX IY SP I
800C:CDIA80 00000000 02 0306 FFFF 8102 FFFF FFFF 8FFE FF
CALL 801AH 11111111 FF FFFF FFFF FFFF
MTS-Z80A > (
PC SZ-H-VNC A BC DE HL IX IY SP I
800F:10FB 00000000 03 0306 FFFF 8103 FFFF FFFF 8FFE FF
DJNZ 800CH 11111111 FF FFFF FFFF FFFF
61
MTS-Z80A > (
PC SZ-H-VNC A BC DE HL IX IY SP I
800C: CDIA80 00000000 03 0206 FFFF 8103 FFFF FFFF 8FFE FF
CALL 801AH 11111111 FF FFFF FFFF FFFF
MTS-Z80A >
Then for the name of the register, you just need the first character except IX, IY, I.
MTS-Z80A > R(
PC SZ-H-VNC A BC DE HL IX IY SP I
8000: 310090 11111111 FF FFFF FFFF FFFF FFFF FFFF FF00
FF
LD SP,9000H 11111111 FF FFFF FFFF FFFF
62
MTS-Z80A> D(
8000:31 00 90 AF 0E 06 21 00 - 81 E5 06 05 CD 1A 80 10 1.....!.........
8010: FB CD IA 80 0D C2 0A 80 – D1 CF 77 23 3C C9 FF FF ..........W#<...
8020: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8030: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8040: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8050: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8060: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8070: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8080: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8090: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80A0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80B0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80C0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80D0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80E0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80F0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
MTS-Z80A> (
8010: FB CD 1A 80 0D C2 0A 80 - Dl CF 77 23 3C C9 FF FF ..........W#<...
8020: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8030: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8040: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8050: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8060: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8070: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8080: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8090: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF................
80A0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80B0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80C0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80D0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80E0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
80E0: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8100: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
63
MOVE outputs the data of the Memory(ROM, RAM) to the other, area(RAM). The instruction
format is 'M Start Address, End Address, Restart Address', but any address of them can be
omitted. Let's copy the data of 8000H-801FH to the address from 8030H to 804F and dump
from 8000H to 805FH to check
MTS-Z80A> M8000,801F,8030↵
MTS-Z80A> D8000,805F↵
8000: 31 00 90 AF 0E 06 21 00 - 81 E5 06 05 CD IA 80 10 1.....!.........
8010: FB CD 14 80 0D C2 0A 80 – D1 CF 77 23 3C C9 FF FF ......... W#<...
8020: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
8030: 31 00 90 AF 0E 06 21 00 - 81 E5 06 05 CD 1A 80 10 1.....!.........
8040: FB CD 1A 80 0D C2 0A 80 – D1 CF 77 23 3C C9 FF FF ......... W#<...
8050: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF................
MTS-Z80A>
FILL function fills the Memory(ROM or RAM) with the data you want. The instruction format 'F
Start Address, End Address, Data' Let's fill 8000H - 801FH with 44H and dump it to check.
MTS-Z80A> F8000,801F,44↵
MTS-Z80A> D8000,802F↵
8000: 44 44 44 44 44 44 44 44 - 44 44 44 44 44 44 44 44 DDDDDDDDDDDDDDDD
8010: 44 44 44 44 44 44 44 44 - 44 44 44 44 44 44 44 44 DDDDDDDDDDDDDDDD
8020: FF FF FF FF FF FF FF FF - FF FF FF FF FF FF FF FF ................
MTS-Z80A>
⑥ EDIT
EDIT is used for modifying the data of the Memory(RAM). To modifying the data, Insert'.'. To
go to one address backward, insert When just press ENTER, the address increments without
and change of data. The instruction format is 'E Start Address'. If the address is omitted the
default is 8000H.
MTS-Z80A> E↵
8000: 44 -> 11↵
8001: 44 -> 22↵
8002: 44 -> 33↵
8003: 44 -> 55↵
8004: 44 -> \↵ : the address increments
8003: 55 -> 44↵
8004: 44 -> 55↵
8005: 44 -> .↵ : finish modifying the data
64
MTS-Z80A>
⑦ Disassembler
Disassembler shows the mnemonics of the machine codes that transmitted to PC or inputted
from the keypad. We are used to using STEP and TRACE, so you knows convenience. The
other way, MTS-Z80A has the function that converts the machine codes of the Memory(ROM,
RAM) on the PC into the mnemonics. If the instruction format 'U line' or the number of lines are
omitted, it shows the mnemonics of 20 lines.
MTS- Z80A> U↵
8000: 310090 LD SP,9000H
8003: AF XOR A
8004: 0E06 LD C,06H
8006: 210081 LD HL,8100H
8009: E5 PUSH HL
800A: 0605 LD B,05H
800C: CD1A80 CALL 801AH
800F: 10FB DJNZ 800CH
8011: CD1A80 CALL 801AH
8014: 0D DEC C
8015: C20A80 JP NZ,800AH
8018: Dl POP DE
8019: CF RST 08H
801A: 77 LD (HL), A
801B: 23 INC HL
801C: 3C INC A
801D: C9 RET
801E: FF RST 38H
801F: FF RST 38H
8020: FF RST 38H
65
Chapter 12. Externally Conneted Circuits
① 74LS244
A TTL IC, 74LS244 When the control signal 1G and 2G is 'High', output Y is high
impedance(electrically there is no connection, namely no high and not low). When 1G and 2G
are 'Low', the output Y is the same as A. When it's connected to the external, it is used for the
input ports lot as well as the selector of micro-processors. For the pin configuration the IC,
refer to the sheets.
② 74LS373
74LS373 has the latch function, so for the external connection it is used a lot for the
output ports as well as the address latch of micro-processors. When the output control(OC) of
74LS373 is 'H', the output becomes the high impedance. This output is prior to Enable(G).
When the Enable becomes 'H', the data will be lost. When the Enable is 'L', the data are hold.
0000 END
66
2. LED Output Ⅱ according to the switch input (74LS244, 74LS373)
(a) Source file name : 80SW1.ASM
(b) Hexa file name : 80SW1.HEX
(c) Address : 5150H
(d) Action : If more than one of 8-bit switches are pressed, all the 8-bit
LEDs flicker, otherwise all the 8-blt LEDs are lights -out.
0000 END
67
3. LED Flickering 1 (74LS373)
(a) Source file name : 80LIGHT1.ASM
(b) Hexa file name : 80LIGHT1.HEX
(c) Address : 5160H
(d) Action : 8-bit LEDs flicker( the Left 4 bits and Right 4bits flicker
alternatively)
0000 END
0000 END
8003 3EFC START: LD A,0FCH ;set the lighting pattern (only the
;left 2 lights are on)
8004 D350 J1: OUT (LED),A ;output the data
8007 07 RLCA
8008 CB7F BIT 7,A ;if the MSB is zero
800A CA1380 JP Z,J2 ;jump to J2
800D CD2180 CALL TIMER
8010 C30580 JP J1
8013 D350 J2: OUT (LED),A
8015 0F RRCA
8016 CB47 BIT 0,A ;if the LSB is zero
8018 CA0580 JP Z,J1 ;jump to J1
8013 CD2180 CALL TIMER
801E C31380 JP J2
69
8021 1640 TIMER: LD D,40H
8023 1EFF TIME1: LD E,0FFH
8025 1D TIME2: DEC E
8026 C22580 JP NZ,TIME2
8029 15 DEC D
802A C22380 JP NZ,TIME1
802D C9 RET
0000 END
0000 END
71
7. FND Control (74LS373)
a) Source file name : 80FND.ASM
b) Hexa file name : 80FND,HEX
c) Address : 5020H
d) Action : outputs hexadecimal in sequence on the FND
72
;each segments are lit in the LOW state.
8046 ; Dgfedcba
8046 C0 TABLE: DB 11000000B ;0
8047 F9 DB 11111001B ;1
8048 A4 DB 10100100B ;2
8049 B0 DB 10110000B ;3
804A 99 DB 10011001B ;4
804B 92 DB 10010010B ;5
804C 82 DB 10000010B ;6
804D D8 DB 11011000B ;7
804E 80 DB 10000000B ;8
804F 90 DB 10010000B ;9
8050 88 DB 10001000B ;A
8051 83 DB 10000011B ;B
8052 C6 DB 11000110b ;C
8053 A1 DB 10100001B ;D
8054 86 DB 10000110B ;E
8055 8E DB 10001110B ;F
0000 END
804C ; Dgfedcba
804C C0 TABLE: DB 11000000B ;0
804D F9 DB 11111001B ;1
804E A4 DB 10100100B ;2
804F B0 DB 10110000B ;3
8050 99 DB 10011001B ;4
8051 92 DB 10010010B ;5
8052 82 DB 10000010B ;6
8053 D8 DB 11011000B ;7
0000 END
74
Chapter 13. 8255
① What is 8255?
Most microprocessors use particular components to easily perform connection to the
external. The Intel 8255(PPI. Programmable Peripheral Interface) is a general purpose I/O
component designed for use with various type of microprocessors. 8255 has 24 I/O pins which
are classified A, B and C ports in sets of 8 bits. A and B ports can be individually programmed
in sets of 8 bit to be input and output. C port consists of the 4 bits MSB and 4-bits LSB and is
used in sets of 4 to be input output. Its main feature is that of a general purpose programmable
device with three ports with 8-bit input/output.
75
D7 D6 D5 D4 D3 D2 D1 D0
GROUP B
Port C 0 Output
(Lower) 1 Input
0 Output
PORT B
1 Input
Mode 0 Mode 0
Selection 1 Mode 1
GROUB A
Port C 0 Output
(Upper) 1 Input
0 Output
Port A
1 Input
00 Mode 0
Mode
01 Mode 1
Selection
1x Mode 2
D7 D3 D2 D1 D0
O Reset
Bit Set/Reset
1 Set
D1 0 1 0 1 0 1 0 1
D2 0 0 1 1 0 0 1 1
D3 0 0 0 0 1 1 1 1
76
③ How to light a DOT MATRIX LED
The LEDs as display are required to have more than 256Dots(16 × 16 Dot per a
character to express Korean or Chinese. If only onto character controlled by the static method,
it Is virtually impossible to configure control the hardware.
Dot Matrix LED is the LED component which is connected to the joining point of a row and
column line. In general, a Dot Matrix LED is lit in the Dynamic lighting method. The dynamic
method is a little bit complicated but it is the very convenient way to control lots of LEDs.
77
2) Practising FONT Construction on the character generator
Using the following table, construct characters and pictures. Then use that programming
practice.
78
⑤ Program
0028 APORTD EQU 28H
0029 BPORTD EQU APORTD+ 1
002A CPORTD EQU BPORTD+1
002B CNTD EQU CPORTD+1
79
8049 062D J5: LD B,45 ;set the number of the output
804B 0E28 J6: LD D,APORTD ;set the output port(GREEN)
804D CD5D80 CALL DISP ;display the character
8050 0E29 LD C,BPORTD ;set the output port(RED)
8052 CD5D80 CALL DISP ;display the character
8055 10F4 DJNZ J6 ;jump to J6 if 45 outputs has not
;been done
8057 CD8380 CALL DELAY ;delay the time (all the LEDs are
;off)
805A C33180 JP J1 ;jump to J1
0000 END
81
802D 3E80 LD A,80H
802F D32B OUT (CNTD) ,A
8031 21FFFF MAlN: LD HL,0FFFFH ;clear the data area for display
8034 FD210082 LD IY,LET1 ;clear the area for GREEN
8038 CDB480 CALL CLEAR
803B FD2l1082 LD IY,LET3 ;clear the area for RED
803F CDB480 CALL CLEAR
8042 DD210B81 LD IY,DATA2 ;set the starting address of the
;data
8046 FD210882 LD IY,LET2 ;the data area for GREEN
804A CDBF80 CALL MOVE ;data transfer routine
804D DD210381 LD IX,DATA1 ;set the starting address
8051 FD211082 LD IY,LET3 ;transmit the data for RED
8055 CDBF80 CALL MOVE ;data transfer routine
84
810B 007E7E7E DATA2: DB 00H, 7EH, 7EH, 7EH
810F 7E7E7E00 DB 7EH, 7EH, 7EH, 00H
0000 END
85
Chapter 14. 8253
1. SOUND - TEST 1
(a) Source file name : 80CTC.ASM
(b) Hexa file name : 80CTC.HEX
(c) Address : 5120H
(d) Action : Play the sound generated by the division of the clock at
2.4576MHz which is input to COUNT0 of the IC 8253
④ Counter/Timer Mode
1) Mode 0 Count Complete interrupt
ⓐ Start counting after loading the count value
ⓑ If the counter becomes zero. the OUT pin becomes 'H'. Then if is an interrupt, the
interrupt is requested.
ⓒ Maintain the OUT pin until selecting a Mode and setting the count value.
86
2) Mode 1 : Programmable One Shot
ⓐ Use a GATE pin as trigger function
ⓑ If the GATE pin(Trigger) becomes 'H', the counter starts action
ⓒ OUT pin becomes 'L'. If the counter is zero, it becomes 'H'
ⓓ This mode is so retriggerble that if a trigger signal is inputted to Gate pin, the count
value is reloaded.
87
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RL1 RL0 M2 M1 M0 BCD
Binary BCD Counter
1 BCD
0 Binary
Mode Selection
Mode
M2 M1 M0 Mode
No.
Interrupt enable if the
0 0 0 0
counter is ‘0’
0 0 1 Programmable One Shot 1
0 1 0 Rate Generator 2
Square Wave Rate
0 1 1 3
Generator
1 0 0 Software Triggered Strobe 4
1 0 1 Hardware Triggered Strobe 5
Counter Control
RL1 RL0 Function
0 0 Counter Latch
0 1 Read/Load only LSB
1 0 Read/Load only MSB
1 1 Read/Load LSB/MSB
Counter Selection
RL1 RL0 Counter
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
1 1 Counter 3
◆ Mode Byte of the 8253
◆ To generate the sound, output the frequency that the sound has Divide frequency
(24576000Hz) applied to CTC(8253) by the reference frequency.
◆ For example, the division rate of degree is 9394 because 2457600÷261.6 = 9394.495413.
The decimal 9394 is converted into the hexadecimal 24B2H.
88
The musical scale Do Re Mi Fa Sol Ra Si
Reference
261.6 293.7 329.6 349.2 392.0 440.0 493.2
Frequency(Hz)
period(ms) 3.82 3.40 3.03 2.86 2.55 2.27 2.03
Division ratio(decimal) 9394 8386 7456 7038 6269 5585 4983
Division
20B0 20B0 1D20 1B7E 1B7E 187D 1377
Ratio(hexadecimal)
⑤ Program
0048 COUNT0 EQU 48H
0049 COUNT1 EQU 49H
004A COUNT2 EQU 4AH
004B CSR EQU 4BH
0000 DO EQU 0
0002 RE EQU 2
0004 MI EQU 4
0006 FA EQU 6
0008 SOL EQU 8
000A RA EQU 0AH
000C SY EQU 0CH
000E DO1 EQU 0EH
0010 NO EQU 10H
89
8031 3E0A LD A,10 ;the LSB of the division ratio
8033 D348 OUT (COUNT0).A ;output to the 8253
8035 AF XOR A ;the MSB of the division ratio
8036 D348 OUT (COUNT0),A ;output to the 8253
8038 CD7D80 CALL TIMER ;delay the time
;the first byte of the song data is
stored in order of musical scale,
tempo.
803B FD219B80 PLAY: LD IY,DATA2 ;the starting address of the song
;data
803F 1600 MAIN: LD D,0 ;clear D to operate
8041 DD218980 LD IX,DATA1 ;division ratio table
8045 FD7E00 LD A,(IY) ;transmit the scale data to A
8048 FEFF CP A,0FFH ;is that the end of the song?
804A CA3B80 JP Z,PLAY ;jump to PLAY if it is.
8061 CD7D80 J1: CALL TIMER ;delay the time of standard tempo
8064 3D DEC A ;decrement the tempo data
8065 C26180 JP NZ,J1 ;Jump to J1 if not zero
8068 3E0A LD A,10 ;stop generating the sound
806A D348 OUT (COUNT0),A
806C AF XOR A ;delay for very short time( to stop
the continuous sound)
806F 210001 LD HL,100H
8072 2B J2: DEC HL
8073 7C LD A,H
90
8074 B5 OR L
8075 C27280 JP NZ,J2
8078 FD23 INC IY
807A C33F80 JP MAIN
91
0060 STRINGL EQU 0060H
0058 LINE2 EQU 0058H
806A 78 LD A,B
806B 87 ADD A,A ;double the data because the
;each division ratio consists of 2
;bytes
806C 5F LD E,A
806D DDl9 ADD IX,DE
806F DDTE00 LD A,(IX)
8072 D348 OUT (COUNT0),A
8074 DD23 ADD IX,DE
8076 DD7E00 LD A,(IX)
8079 D348 OUT (COUNT0),A ;timer for removing chattering
807B 110030 LD DE,3000H ;don't recognize although the
;switch is pushed faster than the
;timer, namely in the minimum
;time of generating the sound
807E 1B J3: DEC DE
807F 7A LD A,D
8080 B3 OR E
8081 C27E80 JP NZ,J3
8084 C33D80 JP MAIN
0000 END
94
8017 CD5800 CALL LINE2
801A CD6000 CALL STRINGL
801D 20444950 DB ' DIP1 = NO.2 ON$'
95
8073 FE4D CP 'M'
8075 CAA980 JP Z,SI
8078 FE6D CP 'm'
807A CAA980 JP Z,SI
96
80CD 1B J1: DEC DE
80CE 7A LD A,D
80CF B3 OR E
80D0 C2CD80 JP NZ,J1
80D3 D1 POP DE
80D4 F1 POP AF
80D5 C9 RET
0000 END
97
Chapter 15. DAC0808
① What is DAC0808?
DAC 0808 is 8-bit one channel current output D/A converter. The current signal form DAC
0808 should be converted into the voltage signal by using an OP amp. An OP amp, called ‘a
operational amplifier’ was used for the basic components of analog computers. An OP amp is
the DC amplifier with high gain and its characteristics of the input/output is applied to the
simple operational circuit like addition/subtraction or an oscillator The output current of
DAC0808 is the multiple of the digital input value and the reference current. The relation
between the current lout and the reference current 1ref is as follows.
This current signal is converted into the voltage signal through an OP amp. The output
voltage is from 0 to 10V. The minimum conversion voltage 10/256V because the input value is
in 256 level(from 0 to 255). This signal can be checked from TP1. From the program for
generating pulse wade, you can observe the shape of the wave by connecting TP1 to an
oscilloscope. TP2 is for grounding.
② Program
0030 DAC EQU 30H
0038 AD0 EQU 38H
0050 LED EQU 50H
98
8000 CD4800 START: CALL LCDCLR
8003 CD6000 CALL STRINGL
8006 20442F41 DB ' D/A Converter!$'
8016 CD5800 CALL LINE2
8019 CD6000 CALL STRINGL
801C 2050756C DB ' Pulse Wave !!$'
0000 END
99
8016 CD5800 CALL LINE2
8019 CD6000 CALL STRINGL
801C 20205261 DB ' Ramp Wave !!$'
802B AF MAIN: XOR A
802C D330 REPT: OUT (DAC),A
802E 3C INC A
802F C32C80 JP REPT
0000 END
100
803A C23680 JP NZ,REPT1
803D C32E80 JP REPT
0000 END
4. Generating Pulse Wave 4 (DAC0808)
(a) Source file name : 80DA4.ASM
(b) Hexa file name : 80DA4.HEX
(c) Address : 50A0H
(d) Action : Output sine wave in the constant period by making sine wave
data normalize by 10 " through D/A CONVERTERS. Let's
observe the wave of TP1 on the oscilloscope. TP2 is for
grounding.
0000 END
5. Control the Speed of a DC Motor (ADC0890, DAC0808)
(a) Source file name : 80ADDA.ASM
(b) Hexa file name : 80ADDA.HEX
(C) Address : 50E0H
(d) Action : read the volume signal through A/D converter and output the
data through D/A converter to control the speed of a DC
motor. Observe the speed by changing the volume after
execute the program.
② Program
805F D338 MAIN: OUT (AD0),A ;give the start signal of A/D
;converter through OUT command
;A has no more meaning
8061 060A LD B,10 ;the conversion time of A/D
;Converter
8063 10FE DJNZ $
8065 DB38 IN A,(AD0) ;read the value of A/D conversion
8067 D330 OUT (DAC),A ;output to D/A Converter. drive
;the motor
8069 2F CPL ;inverse the signal
806A D350 OUT (LED),A ;output to the 8-bit LED
806C CD7280 CALL TIMER
806F C35F80 JP MAIN
0000 END
103
6. Measurement of the rotation numbers of a DC motor
(a) Source file name : 80COUPL.ASM
(b) Hexa file name : 80COUPL.HEX
(c) Address : 50F0H
(d) Action : read the volume signal through the A/D converter and output
it to the D/A converter. Then control the speed of a DC motor
and read the port interrupt. Whenever it counts 16 (16 per 1
rotation), add 1 to the data. Then output it to the LCD. If the
DC motor doesn't rotate after the program starts executing,
turn the volume up to the maximum and execute it again. In
spite of the lower limit in the program, there can be a motor
which doesn't work properly. After executing the program,
observe the change of rotation numbers while changing the
volume. The counter consists of 8-digit decimal counters.
106
0080 LOUTA EQU 0080H
0090 LCD_OUT EQU 0090H
806F 23 INC HL
8070 C36180 JP J1
8077 CB1D RR L
8079 10FA DJNZ INTR1
108
808B 78 LD A,B
808C CD8000 CALL LOUTA
808F F1 POP AF
8090 C664 ADD A,100
0000 END
109
Chapter 16. ADC 0809
0000 END
111
803C C32E80 JP MAIN
0000 END
112
8037 D350 OUT (LED),A
8039 CD3E80 CALL TIMER
803C C32E80 JP MAIN
803F 210050 TIMER: LD HL,5000H
8042 2B TIME: DEC HL
8043 7C LD A,H
8044 B5 OR L
8045 C24280 JP NZ,TIME
8048 C9 RET
0000 END
113
802C 0604 LD B,4
802E CDB080 DELAY: CALL TIMER
8031 10FB DJNZ DELAY
8033 CD5800 MAIN: CALL LINE2
8036 CD6000 CALL STRINGL
8039 20205245 DB 'RECORDING...$'
804A DD210081 LD IX,8100H ;the starting address of the data
;stored
804E 210070 LD HL,7000H ;the number of the output
114
8092 DD210081 LD IX,8100H ;the starting address of the data
8096 210070 LD HL,7000H ;the number of the data
0000 END
115
Chapter 17. Stepping Motor
② Driving Method
1) 1 phase exciting method : the way to drive the motor by exciting every one pair. This
method requires low power and the torque is small.
116
INPUT CCW π θ CW
A
/A
/B
2) 2 phase exciting method : the way to drive the motor by exciting two phases
simultaneously. This method requires high power but the torque is also large.
INPUT CCW π θ CW
A
/A
/B
3) 1-2 phase exciting method: the way to alternate 1 phase exciting and 2phases exciting.
Because the angle of STEP become 1/2, it is possible to control precisely and it rotates
smoothly. However it is not suitable for the high speed.
INPUT CCW π θ CW
A
/A
/B
117
③ Program
0050 LED EQU 50H
0058 SWITCH EQU 58H
0068 STEP EQU 68H
0048 LCDCLR EQU 0048H
0060 STRINGL EQU 0060H
0058 LINE2 EQU 0058H
8034 F5 PUSH AF
8035 DB58 IN A,(SWITCH) ;check the status of he switch
8037 D350 OUT (LED),A ;output to the LED
8039 E603 AND 00000011B ;clear just leaving the MSB 2 bit
803B FE03 CP 00000011B ;is there any key pushed?
803D C24580 JP NZ,J1 ;jump to J1 if so
8040 F1 POP AF
8041 07 RLCA
8042 C32F80 JP MAIN
118
8055 F5 TIMER: PUSH AF
8056 210090 LD HL,9000H
8059 2B TIME: DEC HL
805A 7C LD A,H
805B B5 OR L
805C C25980 JP NZ,TIME
805F F1 POP AF
8060 C9 RET
0000 END
119
Chapter 18. LCD Control
◈ In HD44780, it can be interfacing to 4 bit or 8 bit CPU. For 4-bit CPU, only from D4 to D7
can be used.
120
RAM, CG RAM and the data which is read from DD RAM, CG RAM.
2) BF(Busy Flag)
BF notifies if LCD Module can receive the next instruction or not. When RS = 0, R/W = 1,
it outputs the data to D7
BF = 1: it means the internally running and it cannot receive the next instruction.
BF = 0: it can receive the next instruction.
Accordingly, when the next instruction executes, you should check the status of BF.
Without checking the status of BF, if the instruction executes, the instruction should execute
after waiting for the running time. With the standard of the clock at 250KHz in the module, the
running time of CLEAR and HOME is 1.64ms and the rest is 40us
121
In the data of CG RAM, '1' means display selected and '0' means not selected. the
character code from 0 to 2 corresponds to the address bit(from 3 to 5)of CG RAM. The
address bit(from 0 to 2)of CG RAM displays the column location of the character pattern. the
8th column of the character pattern is the location of the cursor and it can be used with making
the pattern. When the pattern of CG RAM is read, from 4 to 7 bit of the code select '0'. bit 3 is
invalid because from 0 to 2 bit decides which pattern can be read. Namely, '00H' and '08H'
selects the same character. In order to display Korean, display 1 character in the space for 4
characters because it is impossible to use 5 x 7 dot See the example.
122
③ Concepts of Instructions
Code Description
Instruction
RS R/W D7 D6 D5 D4 D3 D2 D1 D0
Clear all the display and set the
Display Clear 0 0 0 0 0 0 0 0 0 1 address 0 of DD RAM in the
address counter
Set the address 0 of DD RAM in
Cursor Home 0 0 0 0 0 0 0 0 1 ▶ the address counter. The contents
of DD RAM will not be changed.
Decide the moving direction of the
Entry mode
0 0 0 0 0 0 0 1 1/D S cursor and the shift when it reads
Set
and writes the data.
Display Set Display on/off(D), Cursor
On/OFF 0 0 0 0 0 0 1 D C B on/off(C), the Bland of the cursor
Control location character.
Without changing the contents of
Cursor/ S/ R/
0 0 0 0 0 0 ▶ ▶ DD RAM, display the moving of the
Display shift C L
cursor and the shift.
Code Description
Instruction
RS R/W D7 D6 D5 D4 D3 D2 D1 D0
Set the length of the interface
Function Set 0 0 0 0 1 DL N F ▶ ▶ data(DL), the number of display
lines, and the character font(F).
Set the address of CG RAM. The
CG RAM
0 0 0 1 Acg data transmitted after that is the
Address Set
data of CG RAM
Set the address of DD RAM. The
DD RAM
0 0 1 Add data transmitted after that is the
Address Set
data of CG RAM
Busy Flag/
Address 0 1 BF AC Decode the contents of BF and AC
decoding
CG RAM,
Write the data to CG RAM and DD
DD RAM 1 0 Write Data
RAM
Data Input
CG RAM,
DD RAM Decode the data from CG RAM
1 1 Read Data
Data and DD RAM
Decoding
123
▶ : invalid bit
I/D = 1 : increment 0 : decrement
S = 1 : accompanying with display shift 0 : doesn't shift
S/C = 1 : shift of display 0 : shift of the cursor
R/L = 1 : shift right 0 : shift left
DL = 1 : 8 BIT 0 : 4 BIT
N = 1 : 2 lines 0 : 1 line
F = 1 : 4 x 10 dot 0 : 5 x 7 dot
BF = 1 : internally running 0 : instruction
After clearing the previous display, the cursor goes back to HOME(0th column). The
ASCII code '20H' of space are filled in all the address of DD RAM, and the address 0 of the DD
RAM in AC is set. If the display shifts, it goes back to the original location. After the instruction
executes the entry mode turns into the increment mode.
2) Cursor HOME
RS R/W D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 0 1 ▶
▶ : invalid bit
The cursor goes back to HOME(0th column). The address 0 of the DD RAM in AC is set.
The cursor goes back to HOME. If the display shifts, it goes back to the original location. The
content of DD RAM will not be changed.
124
3) Entry Mode Set
RS R/W D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 1 I/D S
It set s Display On/Off, Cursor On/Off, and flickering of the character which is in the
location of the cursor. Cursor On/Off and flickering is the line which the address of DD RAM
points to.
When D = 1, Display is set ON.
When D = 0, Display is set OFF.
In the case that from D = 0 Display is OFF, display like D = 1 because the displayed data
remains in DD RAM.
125
5) Cursor/Display Shift
RS R/W D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 S/C R/L ▶ ▶
▶: invalid bit
Without changing the contents of DD RAM. It displays the moving of the cursor and
shifts Display.
S/C R/L Action
0 0 Shift lift the location of the cursor(decrement AC by 1)
0 1 Shift right the location of the cursor(increment AC by 1)
1 0 Shift left the entire display. The cursor moves according to the display.
1 1 Shift left the entire display. The cursor moves according to the display.
6) Function Set
RS R/W D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 DL N F ▶ ▶
126
⑤ Program
0048 LCDCLR EQU 0048H
0060 STRINGL EQU 0060H
0058 LINE2 EQU 0058H
0090 LCD_OUT EQU 0090H
0098 SCAN EQU 0098H
802C 000F0000 FONT_LOW: DB 00H, 0FH, 00H, 00H, 00H, 00H, 00H, 00H
8034 001C0404 DB 00H, 1CH, 04H, 04H, 04H, 04H, 04H, 00H
803C 000F0808 DB 00H, 0FH, 08H, 08H, 08H, 08H, 0FH, 00H
8044 001C0404 DB 00H, 1CH, 04H, 04H, 04H, 04H, 1CH, 00H,'$'
00 END
127
Chapter 19. Testing Melody
◆ the musical scale and tempo data : After executing the following program, input the data of
other songs by referring to the following data.
128
0050 LED EQU 50H
0058 SWITCH EQU 58H
0070 SPK EQU 70H
129
8076 21ADB1 LD HL,DATA1 ;the starting address of the data
8079 CD4F81 CALL PLAY ;play the sound
807C 21C581 LD HL, DATA2
807E CD4F81 CALL PLAY
8088 21A582 LD HL,DATA3
808B CD4F81 CALL PLAY
808E 21A582 LD HL,DATA4
8091 CD4F81 CALL PLAY
8094 216783 LD HL,DATA5
8097 CD4F81 CALL PLAY
809A 213584 LD HL,DATA6
809D CD4F81 CALL PLAY
80A0 213584 LD HL,DATA6
80A3 CD4F81 CALL PLAY
80A6 213584 LD HL,DATA6
80A9 CDAF81 CALL PLAY
80AC 213584 LD HL,DATA6
80AF CD4F81 CALL PLAY
130
80EE CD5800 CALL LINE2
80F1 CD6000 CALL STRINGL
80F4 20444950 DB 'DIP1 = NO.1 ON$'
8104 210014 LD HL,LENGTH2
8107 220090 LD (FLAG),HL
131
8154 47 LD B,A ;store the scale data into B
8155 3C INC A ;increment the scale data
8156 CA9081 JP Z,8 ;jump to J8 if the scale data is
'FFH'(FFH is the code of no-
;sound. If increment FFH by 1, it
;becomes '0')
8159 E5 PUSH HL
815A CD6281 CALL J2 ;generate one sound
815D E1 POP HL
132
8187 0D DEC C
8188 C8 RET Z
133
8225 2D032A03 DB 2DH,03H,2AH,03H,80H,03H,1CH,06H
822D 20032403 DB 20H,03H,24H,03H,26H,03H,80H,03H
8235 2A012601 DB 2AH,01H,26H,01H,2AH,01H,2AH,03H
823D 2A032603 DB 2AH,03H,26H,03H,39H,03H,0C0H,03H
8245 44033303 DB 44H,03H,33H,03H,39H,03H,44H,03H
824D 40039803 DB 40H,03H,98H,03H,39H,03H,44H,03H
8255 40033303 DB 40H,03H,33H,03H,39H,03H,0C0H,03H
825D 40033303 DB 40H,03H,33H,03H,39H,03H,44H,03H
8265 40039803 DB 40H,03H,98H,03H,33H,03H,30H,03H
826D 2A032603 DB 2AH,03H,26H,03H,24H,03H,80H,03H
8275 1C062003 DB 1CH,06H,20H,03H,24H,03H,26H,03H
827D AC032A02 DB 0ACH,03H,2AH,01H,2DH,03H,0AH,01H
8285 26012A01 DB 26H,01H,2AH,01H,2DH,03H,2AH,01H
820D 80031C06 DB 80H,03H,1CH,06H,20H,03H,24H,03H
8295 26038003 DB 26H,03H,80H,03H,26H,03H,2AH,03H
134
8365 0000 DB 00H,00H
135
8483 3C120000 DB 2CH,12H,0,0
136
8583 AE022D10 DB 1EH,02H,2DH,10H
0000 END
138
8072 327781 LD (HOUR),A
8075 357681 LD (MINUTE),A
8078 327581 LD (SECOND),A
807B CD1E81 CALL DISPLAY ;output to the LCD
139
80D2 20FB JR NZ,TIME
80D4 C9 RET
140
810E 217781 LD HL,HOUR
8111 7E LD A,(HL)
8112 C601 ADD A,1
8114 27 DAA
8115 77 LD (HL),A
8116 FE24 CP 24H
8118 C21D81 JP NZ,COUNT_END
811B 3600 LD (HL),0
811D C9 COUNT_END: RET
141
815C 1A LD A,(DE) ;transmit the data to A
815D E60F AND A,0FH ;store the data
815F C630 ADD A,30H ;make the ASCII code by adding
;30H
8161 77 LD (HL),A ;store the data
8162 C9 RET
8163 CDF080 INTR: CALL COUNT ;add 1 second to the hour data
8166 CD1E81 CALL DISPLAY ;output to the LCD
8169 CDCC80 CALL TIMER ;time delay(because the interrupt
;signal is applied every 1Hz, the
;interrupt is acknowledged 0.5
;seconds later)
816C FB EI ;acknowledge the interrupt
816D ED4D RETI
814F AF NMI: XOR A ;clear the second data
8170 327581 LD (SECOND),A
8173 ED45 RETN
0000 END
142
Chapter 21. ROM Writer
1. Usage
(a) Blank Check : This is the function that checks if ROM is empty or not before writing ROM.
To drive ROM Writer, type on the keyboard as follows.
MTS-Z80A > W↵
What do you want?
1. WRITE
2. READ
3.BLANK CHECK
4.COMPARE
Select the number or Press <ESC> to cancel 3
:Select BLANK CHECK by typing 3 as input
(b) ROM Read : Store the result of reading ROM into RAM. Store them from 8000H and the
end of the data is obtained by adding the last address of ROM to 8000H. 27256 is read two
times because RAM is bigger than to read. If in the last part(7E00H-7FFFH) the data is
unnecessary, you can perform READ, WRITE AND COMPARE at one time from 27256 by
inserting '5' on the prompt of 'ROM TYPE' and selecting 27256(0000H-7E00H).
143
MTS-Z80A > W↵
What do you want?
1. WRITE
2. READ
3. BLANK CHECK
4. COMPARE
Select the number or Press <ESC> to cancel 2
:Select ROM READ by typing 2 as input
(c) Compare : Compare the data of ROM and the data stored in RAM.
MTS-Z80A > W↵
What do you want?
1. WRITE
2. READ
3. BLANK CHECK
4. COMPARE
Select the number or Press <ESC> to cancel 4
:Select COMPARE by typing 4 as input
144
(d) Write : Write the data stored in RAM to ROM. The address of RAM is the same as that of
ROM.
MTS-Z80A > W↵
What do you want?
1. WRITE
2. READ
3. BLANK CHECK
4. COMPARE
Select the number or Press <ESC> to cancel 1
: Select WRITE by typing 1 as input
145
A:/>HEXOBJ
ATOM Hex to Converter V2.0
(c)Copyright 1986 By ATOM Electronic Co., Ltd.
A:/>BIN2HEX
Converter from BIN to INTEL HEX file V1.0 made by Sigma Intelligence
This program is the Public ware. Anyone can use this HAK LIM Micro Instrument
A:/>
The file has been generated as above. We skip the method of transmission and ROM
WRITE because it's already explained. After WRITE, the target board is required. In order to
use MTS-Z80A as a target board, unscrew the bolts and remove the plastic board. Then for
2764 or 27128 ROM, insert ROM into the place of USER ROM and move right the short bar of
the lower part of ROM and apply the power. The important caution is that you shouldn't use
any System call while writing a program.
146
Chapter 22. System Call
SYSTEM CALL is the group of the useful subroutines of the Monitor program to give users
Keep those system calls in mind for the best use in making programs.
For the first time, it is recommended that you should use the system calls. When you are
accustomed to using that, try to control them in your own program. It is the best way to
understand the processor in depth. To do so, each routine is well-summarized for you, so try to
use the below table. In ROM, single steps step. Like INRS of SCAN, input type system calls
are required to store the input data to A register, so AF register cannot be protected. For other
system call. however, all the register can be protected completely.
147
1. RST 08H (Program End)
We skip explaining about that because you need to understand the Monitor program
entirely.
148
;10(from 0 to 9))
ADD A,7 ;Not a number. add 7 to it. (when A register has '0AH',
;the ASCII code of 'A' is 41H.
;it results 7 from the calculation '41H-30H-0AH = 7'
NAS1: ADD A,'0' ;add 30H. (the character in the quotation mark is
;assembled in ASCII code by the assembler, and the
;ASCII code of '0' is 30H)
RET ;return to the main routine
149
by the stack.
ALLCLR: PUSH AF
LD A,1 ;put 1 into A register.(See the LCD control to know what
;'1' means)
CALL BUSY ;check if the LCD can accept an instruction or not
OUT (08H),A ;output the control code
POP AF
RET
BUSY: PUSH AF
BUSY1: IN A,(08H) ;read BUSY FLAG. (using only 7-bit)
BIT 7,A ;check BUSY FLAG
JR NZ,BUSY1 ;jump to BUSY1 if the LCD is acting internally (can write
;an instruction if BUSY FLAG is '0')
POP AF
RET
150
8.CALL 0050H (LINE1)
This call sends the cursor to HOME(the first column of the previous line).
LINE1: PUSH AF
LD A,2 ;put 2 into A register
CALL BUSY ;check if the LCD can accept an instruction or not
OUT (08H),A ;output the control code
POP AF
RET
LINE2: PUSH AF
LD A,0C0H ;put 0C0H into A register
CALL BUSY ;check if the LCD can accept an instruction or not
OUT (08H),A ;output the control code
POP AF
RET
STRINGL: EX (SP),HL
PUSH AF
STRINGL1: LD A,(HL)
CP '$'
JR Z,STRINGL2
CALL OUTL
INC HL
JR STRINGL1
STRINGL2: POP AF
INC HL
EX (SP),HL
RET
151
11.CALL 0070H (LOUTHL)
This call converts a HL register value to the ASCII code and outputs it. See OUTHL
LOUTHL: PUSH AF
LD A,H
CALL LOUTA
LD A,L
CALL LOUTA
POP AF
RET
LOUT_HL: PUSH AF
LD A,(HL) ;transmit the data of the address to which HL register
;points, to A register.
JP LOUTA1 ;jump to LOUTA1(See LOUTA)
LOUTA: PUSH AF
LOUTA1: PUSH AF
AND 0F0H
RRA
RRA
RRA
RRA
CALL BI2AS
CALL OUTL
POP AF
AND 0FH
CALL BI2AS
CALL OUTL
POP AF
RET
152
14. CALL 0088H (OUTL)
This call outputs an A register value to the LCD.
OUTL: CALL BUSY ;check if the LCD can accept an instruction or not
OUT (09H),A ;output the data(write the character data onto the LCD)
RET
LCD_OUT: CALL BUSY ;check if the LCD can accept an instruction or not
OUT (08H),A ;output the data(write the character data onto the LCD)
RET
Code
Instruction Description
RS R/W D7 D6 D5 D4 D3 D2 D1 D0
DD RAM DD RAM sets the address. After setting,
0 0 1 Address
Address Set the data is the data of DD RAM
153
16. CALL 0098H (SCAN)
This call gets 1 data from the Keypad input of MTS-Z80A. Then the data which are stored
in A register is the internal code of the Keypad.
154
Chapter 23. Instruction Set
※ According to the instruction table, rrr, bbb etc are the same as follows. When you do the
hand assembling, you can convert them into the machine code by consulting the table. Take
the example.
Ex) Let's convert LD B, D into the machine code. r1 is B register, so it is '000' in machine code.
r2 is D register, so it is '010'. Converting them into the machine codes, it becomes '01000010B',
and it is also '42H' in hexadecimal. Namely, the machine code of 'LD B,D' is '42H'.
157
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte Cycle
11011101 DD
← d →
11011101 FD
← d →
11001110 CE
ADC A,n A←A+n+Cy ↕ ↕ ↕ V 0 ↕ 2 2 7
← n →
11101101 ED
ADC HL,ss HL←HL+ss+Cy ↕ ↕ X V 0 ↕ 2 4 15
01ss1010
11011101 DD
← d →
11111101 FD
← d →
11000110 C6
ADD A,n A←A+n ↕ ↕ ↕ V 0 ↕ 2 2 7
← n →
11011101 DD
ADD IX,ss IX←IX+ss * * X * 0 ↕ 2 4 15
00ss1001
11111101 FD
ADD IY,ss IY←IY+ss * * X * 0 ↕ 2 4 15
00ss1001
11011101 DD
← n →
11111101 FD
← n →
158
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
11100110 E6
AND n A←A∧r ↕ ↕ ↕ P 0 0 2 2 7
← n →
11001011 CB 2 3 12
BIT b,(HL) X ↕ 1 X 0 *
Z←(HL)b 01bbb110 1 1 4
11011101 DD
11001011 CB
BIT b,(IX+d) X ↕ 1 X 0 * 4 5 20
Z←(IX+d)b ← d →
01bbb110
11011101 FD
11001011 CB
BIT b,(IY+d) X ↕ 1 X 0 * 4 5 20
Z←(IY+d)b ← d →
01bbb110
11001011 CB
BIT B,r X ↕ 1 X 0 * 2 2 8
Z←rb 01bbbrrr
11ccc100
3 3 10
CALL cc,nn * * * * * * ← n2 →
cc is true 5 17
← n1 →
(SP-1)←PCH 11001101 CD
CALL nn (SP-2)←PCL * * * * * * ← n2 → 3 5 17
PC←nn ← n1 →
CCF * * X * 0 ↕ 00111111 3F 1 1 4
Cy←Cy
11011101 DD
← d →
11111101 FD
← d →
CP r A-r ↕ ↕ ↕ V 1 ↕ 10111rrr 1 1 4
11111110 FE
CP n A-n ↕ ↕ ↕ V 1 ↕ 2 2 7
← n →
159
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte Cycle
11101101 ED
CPD ↕ ♤ ↕ ♠ 1 * 2 4 16
10101001 A9
11101101 ED 2 5 21
CPDR ↕ ♤ ↕ ♠ 1 *
10111000 B8 BC=0 4 16
11101101 ED
CPI ↕ ♤ ↕ ♠ 1 * 2 4 16
10100001 A1
11101101 ED 2 5 21
CPIR ↕ ♤ ↕ ♠ 1 *
10110001 B1 BC=0 4 16
CPL * * 1 * 1 * 00101111 2F 1 1 4
A←A
DAA ↕ ↕ ↕ P * ↕ 00100111 27 1 1 4
DEC (HL) (HL)←(HL)-1 ↕ ↕ ↕ V 1 ↕ 00110101 35 1 3 11
11011101 DD
DEC (IX+d) (IX+d)←(IX+d)-1 ↕ ↕ ↕ V 1 ↕ 00110101 35 3 6 23
← d →
11111101 FD
DEC (IY+d) (IY+d)←(IY+d)-1 ↕ ↕ ↕ V 1 ↕ 00110101 35 3 6 23
← d →
DEC r r←r'-1 ↕ ↕ ↕ V 1 * 00rrr101 1 1 4
DEC ss ss←ss-1 * * * * * * 00ss1011 1 1 6
11011101 DD
DEC IX IX←IX-1 * * * * * * 2 2 10
00101011 2B
11111101 FD
DEC IY IY←IY-1 * * * * * * 2 2 10
00101011 2B
DI IFF1, IFF2←0 * * * * * * 11110011 F3 1 1 4
00010000 10 2 3 13
DJNZ * * * * * *
← e-2 → B=0 2 8
EI IFF1, IFF2←1 * * * * * * 11111011 FB 1 1 4
L↔(SP)
EX (SP),HL * * * * * * 11100011 E3 1 5 19
H↔(SP+1)
IXL↔(SP) 11011101 DD
EX (SP),IX * * * * * * 2 6 23
IXH↔(SP+1) 11100011 E3
IYL↔(SP) 11111101 FD
EX (SP),IY * * * * * * 2 6 23
IYH↔(SP+1) 11100011 E3
EX AF,AF' AF↔AF' * * * * * * 00001000 08 1 1 4
EX DE,HL DE↔HL * * * * * * 11101011 EB 1 1 4
BC↔BC'
EXX DE↔DE' * * * * * * 11011001 D9 1 1 4
HL↔HL'
160
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte Cycle
11101101 ED
IM 0 INT MODE 0 * * * * * * 2 2 8
01000110 46
11101101 ED
IM 1 INT MODE 1 * * * * * * 2 2 8
01011110 56
11101101 ED
IM 2 INT MODE 2 * * * * * * 2 2 8
01011110 5E
11011011 DB
IN A,(n) A←(n) * * * * * * 2 3 11
← n →
11101101 ED
IN r,(c) r←(c) ↕ ↕ 0 * 0 * 2 3 12
01rrr000
11011101 DD
← d →
11111101 FD
← d →
11011101 DD
INC IX IX←IX+1 * * * * * * 2 2 10
00100011 23
11111101 FD
INC IY IY←IY+1 * * * * * * 2 2 10
00100011 23
(HL)←(C)
11101101 ED
IND B←B-1, X ↕ X X 1 * 2 4 16
10101010 AA
HL←HL-1
IND 11101101 ED 2 5 21
INDR X 1 X X 1 *
Repeat until B=0 10111010 BA B=0 4 16
(HL)←(C)
11101101 ED
INI B←B-1 X ↕ X X 1 * 2 4 16
10100010 A2
HL←HL+1
INI 11101101 ED 2 5 21
INIR X 1 X X 1 *
Repeat until B=0 10110010 B2 B=0 4 16
161
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
11000011 C3
JP nn pc←nln2 * * * * * * ← n2 → 3 3 10
← n1 →
11011101 DD
JP (IX) PC←IX * * * * * * 2 2 8
11101001 E9
11111101 FD
JP (IY) PC←IY * * * * * * 2 2 8
11101001 E9
11ccc010
If condition cc is true
JP cc,nn * * * * * * ← n2 → 3 3 10
PC←nln2
← n1 →
00011000 18
JR e PC←PC+e * * * * * * 2 3 12
← e-2 →
00110110 36
LD (HL),n (HL)←n * * * * * * 2 3 10
← n →
11011101 DD
← d →
11011101 DD
00110110 36
LD (IX+d),n (IX+d)←n * * * * * * 4 5 19
← d →
← n →
11011101 FD
← d →
11111101 FD
00110110 36
LD (IY+d),n (IY+d)←n * * * * * * 4 5 19
← d →
← n →
00110010 32
LD (nn),A (nln2)←A * * * * * * ← n2 → 3 4 13
← n1 →
162
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
11101101 ED
01ss0011
LD (nn),ss (n1n2)←ss * * * * * * 4 6 20
← n2 →
← n1 →
00100010 22
LD (nn),HL (n1n2)←HL * * * * * * ← n2 → 3 5 16
← n1 →
11011101 DD
00100010 22
LD (nn),IX (n1n2)←IX * * * * * * 4 6 20
← n2 →
← n1 →
11111101 FD
00100010 22
LD (nn),IY (n1n2)←IY * * * * * * 4 6 20
← n2 →
← n1 →
11011101 DD
← d →
11111101 FD
← d →
00111010 3A
LD A,(nn) A←(n1n2) * * * * * * ← n2 → 3 4 13
← n1 →
LD rl,r2 r1←r2 * * * * * * 01 r1 r2 1 1 4
00rrr110
LD r,n r←n * * * * * * 2 2 7
← n →
11101101 ED
01ss1011
LD ss,(nn) ss←(n1n2) * * * * * * 4 6 20
← n2 →
← n1 →
00ss0001
LD ss,nn ss←n1n2 * * * * * * ← n2 → 3 3 10
← n1 →
163
Mnem Flag OP code The number Machine
Action State
onic S Z H P/V N C 76543210 HEX of byte cycle
00101010 2A
LD HL,(nn) HL←n1n2 * * * * * * ← n2 → 3 5 16
← n1 →
11011101 DD
00101010 2A
LD IX,(nn) IX←(n1n2) * * * * * * 4 6 20
← n2 →
← n1 →
11011101 DD
00100001 21
LD IX,nn IX←n1n2 * * * * * * 4 4 14
← n2 →
← n1 →
11111101 FD
00101010 2A
LD IY,(nn) IY←(n1n2) * * * * * * 4 6 20
← n2 →
← n1 →
11111101 FD
00100001 21
LD IY,nn IY←n1n2 * * * * * * 4 4 14
← n2 →
← n1 →
11011101 DD
LD SP,IX SP←IX * * * * * * 2 2 10
11111001 F9
11111101 FD
LD SP,IY SP←IY * * * * * * 2 2 10
11110010 F9
11101101 ED
LD A,I A←I ↕ ↕ 0 IFF 0 * 2 2 9
01010111 57
11101101 ED
LD A,R A←R ↕ ↕ 0 IFF 0 * 2 2 9
01011111 5F
11101101 ED
LD I,A I←A * * * * * * 2 2 9
01000111 47
11101101 ED
LD R,A R←A * * * * * * 2 2 9
01001111 4F
164
Flag OP code The number Machine
nemonic Action State
S Z H P/V N C 76543210 HEX Of byte cycle
* * 0 ♠ 0 * 11101101 ED
LDD 2 4 16
10101000 A8
* * 0 0 0 * 11101101 ED 2 5 21
LDDR
10111000 B8 BC=0 4 16
* * 0 ♠ 0 * 11101101 ED
LDI 2 4 16
10100000 A0
* * 0 0 0 * 11101101 ED 2 5 21
LDIR
10110000 B0 BC=0 4 16
A←0-A ↕ ↕ ↕ V 1 ↕ 11101101 ED
NEG 2 2 8
01000100 44
11011101 DD
←d→
11111101 FD
←d→
OR r A←A∨r ↕ ↕ 0 P 0 0 10110rrr 1 1 4
11110110 F6
OR n A←A∨n ↕ ↕ 0 P 0 0 2 2 7
← n →
11101101 ED 2 5 21
OTDR X 1 X X 1 *
10111011 BB B=0 4 16
11101101 ED 2 5 21
OTIR X 1 X X 1 *
10110011 B3 B=0 4 16
11101101 ED
OUT (C),r (C)←r * * * * * * 2 3 12
01rrr001
11010011 D3
OUT (n),A (n)←A * * * * * * 2 3 11
← n →
11101101 ED
OUTD X ↕ X X 1 * 2 4 16
10101011 AB
11101101 ED
OUTI X ↕ X X 1 * 2 4 16
10110011 A3
SSL←(SP),
SP←SP+2
165
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
IXL←(SP)
11011101 DD
POP IX IXH←(SP+1) * * * * * * 2 4 14
11100001 E1
SP←SP+2
IYL←(SP)
11111101 FD
POP IY IYH←(SP+1) * * * * * * 2 4 14
11100001 E1
SP←SP+2
(SP-1)←SSH
SP←SP-2
(SP-1)←IXH
11011101 DD
PUSH IX (SP-2)←IXL * * * * * * 2 4 15
11100101 E5
SP←SP-2
(SP-1)←IYH
11111101 FD
PUSH IY (SP-2)←IYL * * * * * * 2 4 15
11100101 E5
SP←SP-2
11001011 CB
RES b,(HL) (HL)b←0 * * * * * * 2 4 15
10bbb110
11011101 DD
11001011 CB
RES b,(IX+d) (IX+d)b←0 * * * * * * 4 6 23
←d→
10bbb110
11111101 FD
11001011 CB
RES b,(IY+d) (IY+d)b←0 * * * * * * 4 6 23
←d→
10bbb110
11001011 CB
RES b,r Rb←0 * * * * * * 2 2 8
10bbbrrr
PCL←(SP) C9
SP←SP+2
3 11
RET cc * * * * * * 11ccc000 1
1 5
RETURN FROM
11101101 ED
RETN NMI * * * * * * 2 4 14
01000101 45
IFF1←IFF2
166
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
11001011 CB
RL (HL) ↕ ↕ 0 P 0 ↕ 2 4 16
00010110 16
11011101 DD
11001011 CB
RL (IX+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00010110 16
11111101 FD
11001011 DB
RL (IY+D) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00010110
11001011 CB
RL r ↕ ↕ 0 P 0 ↕ 2 2 8
00010rrr
RLA * * 0 * 0 ↕ 00010111 17 1 1 4
11001011 CB
RLC (HL) ↕ ↕ 0 P 0 ↕ 2 4 15
00000110 06
11011101 DD
11001011 CB
RLC (IX+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00000110 06
11101101 FD
11001011 CB
RLC (IY+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00000110 06
11001011 CB
RLC r ↕ ↕ 0 P 0 ↕
00000rrr
RLCA * * 0 * 0 ↕ 00000111 07 1 1 4
11101101 ED
RLD ↕ ↕ 0 P 0 * 2 5 18
01101111 6F
11001011 CB
RR (HL) ↕ ↕ 0 P 0 ↕ 2 4 15
00011110 1E
11011101 DD
11001011 CB
RR (IX+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00011110 1E
11111011 FD
11001011 CB
RR (IY+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00011110 1E
167
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
11001011 CB
RR r ↕ ↕ 0 P 0 ↕ 2 2 8
00011rrr
RRA * * 0 * 0 ↕ 00011111 1F 1 1 4
11001011 CB
RRC (HL) ↕ ↕ 0 P 0 ↕ 2 4 15
00001110 0E
11011101 DD
11001011 CB
RRC (IX+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00001110 0E
11111101 FD
11001011 CB
RRC (IY+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00001110 0E
11001011 CB
RRC r ↕ ↕ 0 P 0 ↕ 2 2 8
00001rrr
RRCA * * 0 * 0 ↕ 00001111 0F 1 1 4
11101101 ED
RRD ↕ ↕ 0 P 0 ↕ 2 5 18
01100111 67
RESTART TO
RST n * * * * * * 11ttt111 1 3 11
LOCATION n
11011110 DE
SBC A,n A←A-n-Cy ↕ ↕ ↕ V 1 ↕ 2 2 7
← n →
11011101 DD
← d →
11111101 FD
← d →
11101101 ED
SBC HL,ss HL←HL-ss-Cy ↕ ↕ ↕ V 1 ↕ 2 4 15
01ss0010
11001011 CB
SET b,(HL) (HL)b←1 * * * * * * 2 4 15
11bbb110
168
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
11011101 DD
11001011 CB
SET b,(IX+d) (IX+d)b←1 * * * * * * 4 6 23
← d →
11bbb110
11111101 FD
11001011 CB
SET b,(IY+d) (IY+d)b←1 * * * * * * 4 6 23
← d →
11bbb110
11001011 CB
SET b,r Rb←1 * * * * * * 2 2 8
11bbbrrr
11001011 CB
SLA (HL) ↕ ↕ 0 P 0 ↕ 2 4 15
00100110 26
11011101 DD
11001011 CB
SLA (IX+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00100110 26
11111101 FD
11001011 CB
SLA (IY+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00100110 26
11001011 CB
SLA r ↕ ↕ 0 P 0 ↕ 2 2 8
00100rrr
11001011 CB
SRA (HL) ↕ ↕ 0 P 0 ↕ 2 4 15
00101110 1E
11011101 DD
11001011 CB
SRA (IX+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00101110 2E
11111101 FD
11001011
SRA (IY+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00101110 2E
11001011 CB
SRA r ↕ ↕ 0 P 0 ↕ 2 2 8
00101rrr
11001011 CB
SRL (HL) ↕ ↕ 0 P 0 ↕ 2 4 15
00111110 3E
169
Flag OP code The number Machine
Mnemonic Action State
S Z H P/V N C 76543210 HEX of byte cycle
11011101 DD
11001011 CB
SRL (IX+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00111110 3E
11111101 FD
11001011 CB
SRL (IY+d) ↕ ↕ 0 P 0 ↕ 4 6 23
← d →
00111110 3E
11001011 CB
SRL r ↕ ↕ 0 P 0 ↕ 2 2 8
00111rrr
11011101 DD
← d →
11111101 FD
← d →
11010110 D6
SUB n A←A-n ↕ ↕ ↕ V 1 ↕ 2 2 7
← n →
11011101 DD
← n →
11111101 FD
← n →
11101110 EE
XOR n A←A⊕n ↕ ↕ 0 P 0 ↕ 2 2 7
← n →
170
Appendix 1: Operation Guide for Windows 7 64 Bits
Installing MTS-Z80A on Windows 7 64bits is quite a simple affair. If you follow the steps
exactly as described in this tutorial you will have MTS-Z80A up and running without any
problems.
DOSBox Installation
DOSBox is a DOS-emulator that uses the SDL-library which makes DOSBox very easy to port
to different platforms such as Windows 7 OS.
Step 2: Select components to install. Then click Next> to continue the installation.
171
Step 3: Enter the directory where the DOSBox will be placed. The default is C:\Program Files
(x86)\DOSBox-0.74. Then click Install to continue the installation.
Step 4: As the installation is complete, click Close and then the “DOSBox 0.74” shortcut is
generated on Desktop automatically.
Step 2: Put your assembly code [*.asm] and assembler (X80.exe and LINK80.exe) in this
folder.
172
Step 3: Open DOSBox 0.74 from Desktop.
Step 5: The “MTS80A” folder is mounted on DOS environment under Windows 7 64 bits OS.
You are able to assemble your source program now.
173
Step 6: Write dos commend
D:\>X80 (Enter)
Type the source program(EXAM) in Input Filename.
Step 7: Press [Enter] twice. The object file [EXAM.OBJ] will be shown in the same folder.
174
Step 8: Write dos commend
D:\>Link80 (Enter)
Type the .obj file(EXAM.obj) and then click Enter 5 times to finish the link process.
Step 9: The hexadecimal file [EXAM.HEX] will be shown in the same folder. To download the
program into Z80 chip.
175
Appendix 2: HyperTerminal Operation Guide for Windows 7
1. First of all you need to get access to a Windows XP machine and copy three files
“hypertrm.dll", 'hypertrm.exe" and "hypertrm.chm" from that system to your target Windows
7 machine.
2. On the Windows 7 machine make a new folder under C:\Program Files\HyperTerminal for
32-bit or make a new folder under C:\Program Files (x86)\HyperTerminal for 64-bit.
3. From a Windows XP machine and copy the following 3 files to the folder that was just
created on the Windows 7 machine:
C:\Program Files\Windows NT\hypertrm.exe
C:\WINDOWS\system32\hypertrm.dll
C:\WINDOWS\Help\hypertrm.chm
4. Make sure you keep the files "hypertrm.dll", "hypertrm.exe" and "hypertrm.chm" in the
same folder. Now you can launch the HyperTerminal client on the Windows 7 machine by
double clicking the hypertrm.exe file. And there you have a fully working HyperTerminal
client.
176
[ Circuit Diagram of MTS-Z80A ]
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195