Professional Documents
Culture Documents
Z80 CPU(Java)
493041143-4
493041147-6
By
Mr. Worapot Sommool
Mr. Sasawat Paresrisakul
I.D. 493041143-4
I.D. 493041147-6
Z80 CPU(Java)
493041143-4
493041147-6
.......................................
(. )
1. ........................................
(. )
2. ........................................
(. )
17 2553
Abstract
Z80 Simulator is java-base application that allows Z80 educators and developers with
user-interface environment for multi-platforms (Linux, Window, Mac OS) with integrated
simulator, assembler, disassembler, system call and I/O port for Zilog Z80 8 bits
microprocessor.
Abstract
1
1.1
1.2
1.3
1.4
1.4.1
1.4.2
1.4.3
1.4.4 Z80 simulator (java)
1.4.5
1.5
2 CPU Z80
2.1 CPU Z80
2.2 CPU Z80
2.3 Z80
2.3.1 (Main Register)
2.3.2 (Alternative Register)
2.3.3
2.4 CPU Z80
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
1
1
1
2
2
2
2
2
2
2
2
3
3
5
6
6
7
7
9
9
9
9
9
10
2.4.6
2.5 Z80
2.6 Z80 Addressing Modes
2.7 Z80 CPU Z80
2.7.1 INPUT
2.7.2 OUTPUT
2.7.3 MEMORY
2.7.4
3 CPU Z80
3.1
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.3
3.3.1
3.3.2
3.3.3
3.3.4
3.4
3.4.1 SCANK
3.4.2 SCANC
3.4.3 DSEC
3.4.4 INIT_LCD
3.4.5 CLDCMD
3.4.6 GOTO_ADDR
3.4.7 WRLCD
3.4.8 LCDHEX
10
10
11
12
12
12
13
13
14
14
14
14
15
16
17
18
18
20
20
23
24
24
24
25
25
25
26
26
26
26
26
3.4.9 WR_LCD_MSG
3.4.10 CLR_LCD
3.4.11 CUR_ON
3.4.12 CUR_OFF
3.4.13 HBEEP
3.4.14 LBEEP
3.4.15 TITLE
3.5
3.5.1 Keyboard
3.5.2 LED array
3.5.3 7segment
3.5.4 speaker
3.5.1 LCD
4
4.1
4.1.1
4.1.2
4.1.3
4.2
4.2.1 light
4.2.2 test condition
4.2.3 light2
4.2.4 lcd moving
5
5.1
5.2
5.3
5.4
26
26
26
26
27
27
27
27
27
28
28
28
28
29
29
29
29
30
30
30
31
32
33
35
35
35
36
36
37
38
53
3
5
6
12
12
12
12
13
13
13
14
15
16
17
20
21
22
22
22
23
23
24
24
25
25
25
27
27
28
3.20 GUI 7segment
3.21 GUI speaker
3.22 GUI LCD
4.1 Pair Programming
4.2
4.3 light
4.4 light
4.5 test condition
4.6 test condition
4.7 light2
4.8 light2
4.9 lcd moving
.1
.2 menu bar
.3 menu bar
.4 menu bar
.5 toolbar
.6 toolbar
.7 toolbar
.8 File menu bar
.9 File
.10 run mode step
.11 run mode slow
.12 run mode fast
.13 run toolbar
.14 run menu bar
.15 pc
.16 break toolbar
.17 break menu bar
.18 reset
.19 SCANK
28
28
28
29
29
30
31
31
32
32
33
33
38
39
39
40
40
41
41
42
42
43
43
43
44
44
44
45
45
46
46
.20 SCANC
.21 DSEC
.22 dump_memory
.23
.24 edit menu bar
.25 edit_register
.26 edit_ memory
.27 LED array
.28 7 segment
.29 LCD
.30 Speaker
47
48
49
49
50
50
51
51
51
52
52
1.1
2.1
2.2
2.3
2.4
2.5
2.6
4.1
2
4
7
7
7
9
11
34
1.1
Microprocessor
Microprocessor
Embedded Engineer
Microprocessor
Microprocessor CPU Z80 ET-Board
( 2) programming
execution time machine cycle Z80 simulator
Microprocessor Z80 Z80 simulator DOS
Z80simulator
system call
Graphic User Interface
I/O port
platform
Microprocessor Z80
1.2
1. ET-Board
2. ET-Board
3. user interface
4. system call
I/O port
1.3
Z80 simulator Z80 ET Board
Z80 simulator system call Z80 simulator
I/O port
1.4
1.4.1
Z80 CPU
1.4.2
Engine Z80
CPU
1.4.3
Engine
1.4.5
1.1
1.5
Z80 simulator CPU Z80 ET - Board
microprocessor Z80
2
CPU Z80
2.1 CPU Z80
CPU Z80
CPU Z80
memory, lcd, keyboard , rom, clock, speaker, led flag ET -BOARD V4
2.1 CPU CPU
Z80 ET -BOARD V.4 2.1
4
2.1 Z80 ET-Board V. 4 [7]
CPU
CLOCK
EPROM
RAM
Expansion
Memory
Expansion
Socket
DISPLAY
ET-Board V.4
Z80A
4MHZ
32K BYTE EPROM MONITOR PROGRAM
8K BYTE RAM ON BOARD(6264)
32K BYTE RAM/EPROM(2764,27128,27256,6264,62286)(OPTION)
RTC(REAL TIME CLOCK) 6242 (OPTION)
z80 3
1. Fetch IR
2. Decode Z80
Fetch PC
3. Execute Z80
Z80 ALU flag
1 halt Z80
2.3 Z80
(Register)
Z80[4]
208 2 8
18 16 4 3
2.3
7
A AF 16 A Flag
F Flag Register
2.2 Flag register Z80 CPU
7 6 5 4 3 2 1 0
Flag register S Z x H x P/V N C
sign flag
zero flag
P/V
parity/overflow
add/subtract
carry flag
0 7 0
1 7 1
0 0
1 0
0 / -
1 / -
0 overflow
1 overflow
0 1
1 1
0 add
1 subtract
0 / 7 15
1 / 7 15
sign number
overflow (
signed number)
parity
8 16
A
F
B
C
D
E
H
L
A
F
B
C
D
E
H
L
2.3.3 [6]
Program counter (PC) 16
fetch fetch
CPU
CPU
8
(Jump)
9
2.5 16 bit Register Z80 CPU[4]
IX
IY
SP
PC
I R
10
2.4.5
1.
2.
3.
2.4.6
2 HALT , NOP
2.5 Z80
(Mnemonic operation code
opcode) (operand)
LD = LOAD SUB = SUBTRACT
OUT(10H),A
A(Accumulator) output port 10H Z80 3
1. byte
2. byte
3. 10H
Z80 4
1-byte instructions
LD A, B
0111 1000 (78H)
2-byte instructions
Byte 1
LD B, 32H
0000 0110 (06H)
Byte 2
0011 0010 (32H)
3-byte instructions
byte 1
LD BC, 2080H
0000 0001 (01H)
byte 2
1000 0000 (80H)
0010 0000 (20H)
byte 3
4-byte instructions
byte 1
LD IX, 2000H
1101 1101 (DDH)
0010 0001 (21H)
byte 2
byte 3
0000 0000 (00H)
byte 4
0010 0000 (20H)
11
Mode
Immediate operand 8
Immediate operand 16
Extended
Register
operand
Implied
operand
Accumulator (A)
Register
Indirect
Extended
16 Jump
Relative
operand displacement 2s complement
Indexed
Index Register
displacement 1 byte
Bit
mode
3 mode(register, register indirect,
indexed)
Page Zero 8 restart one-byte call
byte 00H
byte
LD B, 97H
LD BC, 8045H
LD B, A
AND B
LD B, (HL)
JP 2080H
JR 14H
INC (IX+10H)
SET 7, B
RST 28H
12
2.7 CPU Z80
CPU Z80 CPU Z80
2.7.1 INPUT
INPUT CPU Z80
2.4
13
2.7.4
Z80 ET-BOARD V4 RS232 connector 2.9, 34 pin 40 pin I/O port
2.10
14
3
CPU Z80
3.1
MICROPROCESSORS AND INTERFACING (178320)
MICROPROCESSORS AND INTERFACING LABORATORY (178321)
microprocessors CPUZ80 ET -BOARD V4 CPUZ80
CPUZ80
3.2
3.2.1
load
memory load
memory register run
register memory 3.1
3.1
15
3.2.2
memory
register , reset
3.2
3.2
16
3.2.3
run
run
memory mode
mode
fast program counter
register
3.3
3.3
17
3.2.4
3.4
3.4
18
3.2.5
1. short A,B,C,D,E,F,H,L,Ap,Bp,Cp,Dp,Ep,Fp,Hp,Lp,I,R,CY;
2. short memory[][] = new short[1][65536];
3. String nemonic[] = new String[65536];
4. short op1=0x0001,op2,op3,op4; 4 byte
5. intIX , IY, SP=0x1000, PC, PC_nemonic, st_pc;
19
6 ex_bt_bs.java Class Instructions
10 jump.java ClassInstructions
11 input_output.java Class Instructions
port port
3.2.6.2 Graphic User Interface
8 class 8
1 user_interface.java Class
2 gui_about.java Class
3 gui_dump_memory.java Class dump memory
memory
4 gui_editmemory.java java Class
5 gui_editreg.java java Class
6 gui_input_syscall.javaClass system call scanc scank
7 gui_inputPC.java Class program counter
20
3.3
3.3.1
3.5
3.5
3.5
1. (mnemonic)
2. memory
3. Z80 ET Board
4. CPU Z80
5.
21
3.3.1.1 (mnemonic)
load
3.6
3.6
3.3.1.2
load load
CPUZ80 ET-BOARD V4 load memory
ASCII
2 byte
3.7
22
3.7
3.3.1.3
CPUZ80
ET-BOARD V4 LED array, LCD, 7 segment speaker 3.8
3.8
3.3.1.4
3.9
3.9
23
3.3.1.5
load, run.
break, mode, load demo, edit register, edit memory, reset register help 3.10
3.10
3.3.2
edit register
3.11
3.11
24
3.3.3
program counter
program counter 3.12
3.12
3.3.4
byte
3.13
3.13
3.4
[5] CPUZ80
system call CPUZ80
ET-BOARD V4 system call
25
3.4.1 SCANK
scan key board
key board 2 3.14
3.14 SCANK
3.4.2 SCANC
key board A
3.15
3.15 SCANC
3.4.3 DSEC
delay B delay 1-255
3.16
3.16 DSEC
26
3.4.4 INIT_LCD
LCD
CPUZ80 ET-BOARD V4
CPUZ80 ET-BOARD V4
3.4.5 CLDCMD
set LCD D 2
cursor
3.4.6 GOTO_ADDR
LCD
D
3.4.7 WRLCD
ASCII LCD cursor
D
3.4.8 LCDHEX
16 LCD cursor
D
3.4.9 WR_LCD_MSG
memory HL
LCD
3.4.10 CLR_LCD
LCD cursor
3.4.11 CUR_ON
cursor LCD
3.4.12 CUR_OFF
cursor LCD
27
3.4.13 HBEEP
3.17
3.17 LBEEP
3.4.14 LBEEP
HBEEP
3.4.15 TITLE
HBEEP
3.5
CPU Z80 ET-BOARD V4
CPU Z80
ET-BOARD V4
3.5.1 key board
key board
system call
key board CPU Z80 ET-BOARD V4 mouse
3.18
28
3.5.2 LED array
8 port 40 3.19
3.19 GUI led array
3.5.3 7segment
port 60
3.20
29
4.1
4.1.1
2 Pair Programming
4.1
4.2
30
4.1.3
1. , (Memory)
2. I/O Port
3. System Call
4. running , step
5. GUI
4.2
(demo)
4.1
4.2.1 light
LED array
bit [5]
4.2.1.1 light
demo File Load_demo
DEMO_0.hex run 4.3
4.3 light
31
4.2.1.2 light
LED array
4.4
4.4 light
4.2.1.3 light
8 bit load group, 16 bit load group, 8 bit
arithmetic and logical group, 16 bit arithmetic and logical group, rotate and shift group, jump
group, call and return group, input and out put group
32
4.2.2.2 test condition
system call scanc
4 LED
array 4.6
4.2.3 light2
memory [5]
4.2.3.1 light2
demo File Load_demo
DEMO_2.hex run 4.7
4.7 light2
33
4.2.3.2 light2
LED array
4.8
4.8 light2
4.2.3.3 light2
8 bit load group, 16 bit load group, 8 bit
arithmetic and logical group, 16 bit arithmetic and logical group, rotate and shift group, jump
group, call and return group, input and out put group
34
4.2.4.2 lcd moving
LCD
COMPUTER--DESIGNBY ETT-TEAM WORK
4.2.4.3 lcd moving
8 bit load group, 16 bit load group, 8 bit
arithmetic and logical group, 16 bit arithmetic and logical group, rotate and shift group, jump
group, call and return group, input and out put group byte
4.1
light
LED array
LCD
LCD
systemcall
LED array
light2
LED array
LED array
lcd moving
LCD
LCD
35
5.1
6
(GUI)
Z80 CPU
Z80 CPU
Windows, Linux, Mac OS
Z80 CPU 700 ET-Board
(Memory)
I/O Port 7 segment, LCD, LED Array Speaker mode 3
(Step) (Slow) (Fast)
ET-Board
Z80 CPU
ET-Board
5.2
1. unsigned
2. (Graphic User Interface)
36
5.3
(Requirement)
5.4
1. IO Port
ET-Board
2. real time
ET-Board
3. System call
4.
ET-Board
37
38
.1
.1
1. (mnemonic)
2. memory
3. Z80 ET Board
4. CPU Z80
5.
** Z80 ET Board
39
Load file
3
1. menu bar File Load
file (.hex) .2
.2 menu bar
file (.hex) file (.hex)
Open Load file Cancel X
.3
.3 menu bar
40
Load file memory
code (.hex) run .4
.4 menu bar
2. toolbar load toolbar load file file
(.hex) .5
.5 toolbar
file (.hex) file (.hex)
Open Load file Cancel X
.6
41
.6 toolbar
Load file memory
code (.hex) run .7
.7 toolbar
3. Flie menu bar File
Load_demo file_demo (.hex)
.8
42
.9 Flie
Run
run
run 3
1. Mode Step
43
Fast Step
Step .10
Fast
Fast
Fast .12
44
run run 2
1. Toolbar .13
.15 pc
45
Break
.16 .17
Reset
reset run load(.hex)
46
.18 reset
.19 SCANK
47
SCANC (03H)
scan keyboard routine
return register A
.20
.20 SCANC
INIT_LCD (0AH)
LCD
CLDCMD (0BH)
set cursor register D
GOTO_ADDR (0DH)
WRLCD (0EH)
ASCII register D LCD
LCDHEX (14H)
HEX register D LCD cursor
WR_LCD_MSG (16H)
LCD memory HL
CLR_LCD (17H)
Clear LCD cursor
CUR_ON (18H)
cursor LCD
48
CUR_OFF (19H)
cursor LCD
DSEC (2FH)
1 255 register B
.21
.21 DSEC
HBEEP (4CH)
BEEP
LBEEP (4DH)
BEEP
TITLE (4EH)
TITLE
Dump memory
dump memory memory
dump_ memory load
dump memory memory load
.22
49
.22 dump_memory
memory dump memory
dump run
dump dump break reset register( memory reset )
halt dump_memory
dump .23
.23
50
Edit
Edit run register memory
edit load run break
edit .24
.25 edit_register
51
edit_memory
.26
I/O Port
I/O Port
LED array
port 40H .27
.28 7 segment
52
LCD
system call .29
.29 LCD
Speaker
system call .30
.30 Speaker
53
1. Z-80 [] 4 2551
[ 10 2552]
http://www2.ltc.ac.th/microprocessor/theory/instruction_index.html
2. Z-80 [] 30 2551 [ 10 2552]
http://www.cpe.ku.ac.th/~yuen/204323/z80/inst_main.html
3. . . :
; 2548
4. 2 Z80 Z80 [] 20 2543 [ 5
2553] http://www.ett.co.th/article/z80/2000-002-learnz80-002.html
5. ETT. USER S MANUAL ET-BOARD V4.0. ;2535
6. CPU Z80 [] 26 2553 [ 5 2553]
http://web.ku.ac.th/schoolnet/snet1/hardware/z80/z80.html
7. ET-BOARD V.4.0 [] 4 2543 [ 5 2553]
http://www.ett.co.th/product/01A02.html