This commit is contained in:
Andreas Mieke 2018-04-03 21:45:17 +02:00
parent 003f6dc2f3
commit 496209fb46
36 changed files with 1272 additions and 351 deletions

File diff suppressed because it is too large Load diff

BIN
Reischl/img/z80-ce-wahr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 KiB

After

Width:  |  Height:  |  Size: 312 KiB

BIN
Reischl/img/z80-daisy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

BIN
Reischl/img/z80-netz.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 122 KiB

BIN
Reischl/img/z80-reset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 317 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 128 KiB

BIN
Reischl/img/z80-zeit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

View file

@ -0,0 +1,109 @@
1 ;******************************************************************************
2 ;* Z80 Assembler program *
3 ;* Josef Reisinger *
4 ;* josef.reisinger@htl-hl.ac.at *
5 ;* 26/04/2015 *
6 ;******************************************************************************
7
8 ; ---------------------------- PIO 82C55 I/O ---------------------------------
9 0080 PIO_A: EQU $80 ; (INPUT)
10 0081 PIO_B: EQU $81 ; (OUTPUT) OUT TO LEDS
11 0082 PIO_C: EQU $82 ; (INPUT) IN from DIP SWITCHES
12 0083 PIO_CON: EQU $83 ; CONTROL BYTE PIO 82C55
13
14 ; --------------------------- CTC Z80 Timer Counter --------------------------
15 0000 CTC0 EQU $00 ; Channel 0
16 0001 CTC1 EQU $01 ; Channel 1
17 0002 CTC2 EQU $02 ; Channel 2
18 0003 CTC3 EQU $03 ; Channel 3
19
20 ; -------------------------- SIO (USART) ----------------------------------------
21 0040 SIO_A_D: EQU $40 ; Channel A Data Register
22 0041 SIO_B_D: EQU $41 ; Channel B Data Register
23 0042 SIO_A_C: EQU $42 ; Channel A Control Register
24 0043 SIO_B_C: EQU $43 ; Channel B Control Register
25
26
27 ;-------------------------- CONSTANTS ----------------------------------------
28 FFFF RAMTOP: EQU $FFFF ; 32Kb RAM 8000H-FFFFH
29 8000 COUNTER: EQU $8000 ; RAM Counter
30
31
32 ;******************************************************************************
33 ;* RESET HANDLER *
34 ;* Function: Initialize system and start Main Program *
35 ;******************************************************************************
36 0000 ORG $0000
37 0000 F3 DI ; Disable interrupt
38 0001 31 FF FF LD SP,RAMTOP ; Set stack pointer
39 0004 C3 00 01 JP MAIN ; jump to Main program
40
41
42 ;*******************************************************************
43 ;* MAIN PROGRAM *
44 ;*******************************************************************
45 0100 ORG $0100
46 0100 21 00 80 MAIN: LD HL,COUNTER ; Reset RAM Counter
47 0103 3E 00 LD A,$00
48 0105 77 LD (HL),A
49
50 ; ------------------ Initialize PIO ----------------
51 0106 3E 99 LD A,$99 ; Initialize 8255: PA0-PA7=IN (DIP SWITCHES), PB0-PB7=OUT (LEDS),
52 0108 D3 83 OUT (PIO_CON),A ; PC0-PC7=IN, Mode 0 Selection
53
54 ;------------------ Configure CTC -----------------------
55 010A 3E A5 LD A,$A5 ; Configure CTC Channel 0: Interrupt, Timer Mode, Prescaler = 256,
56 010C D3 00 OUT (CTC0),A ; trigger on positive edge, next word = time constant, Channel continuous result operation
57 010E 3E FF LD A,$FF ; Write Time constant 255*256*552ns= 36,03ms
58 0110 D3 00 OUT (CTC0),A
59 0112 3E A8 LD A,$A8 ; Loading Interrupt Vector register
60 0114 D3 00 OUT (CTC0),A ; trigger on positive edge, next word = time constant, Channel continuous result operation
61
62 ;---------------------- Configure Interrupt -----------------
63 0116 3E 01 LD A,$01 ; Loading Interrupt Register
64 0118 ED 47 LD I,A
65 011A ED 5E IM 2 ; Interrupt Mode 2
66 011C FB EI ; Enable Interrupt
67
68 ;--------------------- Main Program --------------------------
69 011D C3 1D 01 AGAIN: JP AGAIN ; Endless
70
71
72
73 ;******************************************************************************
74 ;* INTERRUPT SERVICE ROUTINE *
75 ;* CTC Channel 0 *
76 ;******************************************************************************
77 01A8 ORG $01A8
78 01A8 AA 01 DEFW _INT_CTC
79 01AA F5 _INT_CTC: PUSH AF
80 01AB E5 PUSH HL
81 01AC 21 00 80 LD HL,COUNTER
82 01AF 7E LD A,(HL) ; Read Counter
83 01B0 3C INC A ; Increment Counter
84 01B1 FE 07 CP $07 ; 252,21ms reached?
85 01B3 C2 BD 01 JP NZ,_END_INT
86 01B6 3E 00 LD A,$00 ; Reset Counter
87 01B8 DB 81 IN A,(PIO_B) ; Toggle LED's with 2Hz
88 01BA 2F CPL
89 01BB D3 81 OUT (PIO_B),A ;
90 01BD 77 _END_INT: LD (HL),A ; Store Counter
91 01BE E1 POP HL
92 01BF F1 POP AF
93 01C0 FB EI ; Entry Point of Interrupt Service Routine
94 01C1 ED 4D RETI
95
96
97
98
99
100
Symbol table:
AGAIN 011D COUNTER 8000 CTC0 0000 CTC1 0001
CTC2 0002 CTC3 0003 MAIN 0100 PIO_A 0080
PIO_B 0081 PIO_C 0082 PIO_CON 0083 RAMTOP FFFF
SIO_A_C 0042 SIO_A_D 0040 SIO_B_C 0043 SIO_B_D 0041
_END_INT 01BD _INT_CTC 01AA
18 symbols.

View file

@ -0,0 +1,51 @@
1 ;******************************************************************************
2 ;* Z80 Assembler program *
3 ;* Josef Reisinger *
4 ;* josef.reisinger@htl-hl.ac.at *
5 ;* 26/04/2015 *
6 ;******************************************************************************
7
8 ; ---------------------------- PIO 82C55 I/O ---------------------------------
9 0080 PIO_A: EQU $80 ; (INPUT)
10 0081 PIO_B: EQU $81 ; (OUTPUT) OUT TO LEDS
11 0082 PIO_C: EQU $82 ; (INPUT) IN from DIP SWITCHES
12 0083 PIO_CON: EQU $83 ; CONTROL BYTE PIO 82C55
13
14 ; --------------------------- CTC Z80 Timer Counter --------------------------
15 0000 CTC0 EQU $00 ; Channel 0
16 0001 CTC1 EQU $01 ; Channel 1
17 0002 CTC2 EQU $02 ; Channel 2
18 0003 CTC3 EQU $03 ; Channel 3
19
20 ; -------------------------- SIO (USART) ----------------------------------------
21 0040 SIO_A_D: EQU $40 ; Channel A Data Register
22 0041 SIO_B_D: EQU $41 ; Channel B Data Register
23 0042 SIO_A_C: EQU $42 ; Channel A Control Register
24 0043 SIO_B_C: EQU $43 ; Channel B Control Register
25
26
27 ;-------------------------- CONSTANTS ----------------------------------------
28 FFFF RAMTOP: EQU $FFFF ; 32Kb RAM 8000H-FFFFH
29
30 ;******************************************************************************
31 ;* START AFTER RESET, *
32 ;* Function....: ready system and restart *
33 ;******************************************************************************
34 0000 ORG $0000
35 0000 F3 DI ; Disable interrupt
36 0001 31 FF FF LD SP,RAMTOP ; Set stack pointer to top off ram
37 0004 3E 15 LD A,$15 ; Configure CTC Channel 0:No Interrupt, Timer Mode, No Prescaler,
38 0006 D3 00 OUT (CTC0),A ; trigger on positive edge, next word = time constant, Channel continuous result operation
39 0008 3E BA LD A,186 ; Write Time constant 186*560ns= 104µs
40 000A D3 00 OUT (CTC0),A
41 000C DB 00 AGAIN: IN A,(CTC0) ; Read actual status of CTC Channel 0
42 000E C3 0C 00 JP AGAIN ; Endlos
43
Symbol table:
AGAIN 000C CTC0 0000 CTC1 0001 CTC2 0002
CTC3 0003 PIO_A 0080 PIO_B 0081 PIO_C 0082
PIO_CON 0083 RAMTOP FFFF SIO_A_C 0042 SIO_A_D 0040
SIO_B_C 0043 SIO_B_D 0041
14 symbols.

42
Reischl/lst/CTC_Counter.s Normal file
View file

@ -0,0 +1,42 @@
;******************************************************************************
;* Z80 Assembler program *
;* Josef Reisinger *
;* josef.reisinger@htl-hl.ac.at *
;* 26/04/2015 *
;******************************************************************************
; ---------------------------- PIO 82C55 I/O ---------------------------------
PIO_A: EQU $80 ; (INPUT)
PIO_B: EQU $81 ; (OUTPUT) OUT TO LEDS
PIO_C: EQU $82 ; (INPUT) IN from DIP SWITCHES
PIO_CON: EQU $83 ; CONTROL BYTE PIO 82C55
; --------------------------- CTC Z80 Timer Counter --------------------------
CTC0 EQU $00 ; Channel 0
CTC1 EQU $01 ; Channel 1
CTC2 EQU $02 ; Channel 2
CTC3 EQU $03 ; Channel 3
; -------------------------- SIO (USART) ----------------------------------------
SIO_A_D: EQU $40 ; Channel A Data Register
SIO_B_D: EQU $41 ; Channel B Data Register
SIO_A_C: EQU $42 ; Channel A Control Register
SIO_B_C: EQU $43 ; Channel B Control Register
;-------------------------- CONSTANTS ----------------------------------------
RAMTOP: EQU $FFFF ; 32Kb RAM 8000H-FFFFH
;******************************************************************************
;* START AFTER RESET, *
;* Function....: ready system and restart *
;******************************************************************************
ORG $0000
DI ; Disable interrupt
LD SP,RAMTOP ; Set stack pointer to top off ram
LD A,$15 ; Configure CTC Channel 0:No Interrupt, Timer Mode, No Prescaler,
OUT (CTC0),A ; trigger on positive edge, next word = time constant, Channel continuous result operation
LD A,186 ; Write Time constant 186*560ns= 104µs
OUT (CTC0),A
AGAIN: IN A,(CTC0) ; Read actual status of CTC Channel 0
JP AGAIN ; Endlos

View file

@ -0,0 +1,80 @@
1 ;******************************************************************************
2 ;* Z80 Assembler program *
3 ;* Josef Reisinger *
4 ;* josef.reisinger@htl-hl.ac.at *
5 ;* 10/07/2017 *
6 ;******************************************************************************
7
8 ; ---------------------------- PIO 82C55 I/O ---------------------------------
9 0080 PIO_A: EQU $80 ; (INPUT)
10 0081 PIO_B: EQU $81 ; (OUTPUT) OUT TO LEDS
11 0082 PIO_C: EQU $82 ; (INPUT) IN from DIP SWITCHES
12 0083 PIO_CON: EQU $83 ; CONTROL BYTE PIO 82C55
13
14 ; --------------------------- CTC Z80 Timer Counter --------------------------
15 0000 CTC0 EQU $00 ; Channel 0
16 0001 CTC1 EQU $01 ; Channel 1
17 0002 CTC2 EQU $02 ; Channel 2
18 0003 CTC3 EQU $03 ; Channel 3
19
20 ; -------------------------- SIO (USART) ----------------------------------------
21 0040 SIO_A_D: EQU $40 ; Channel A Data Register
22 0041 SIO_B_D: EQU $41 ; Channel B Data Register
23 0042 SIO_A_C: EQU $42 ; Channel A Control Register
24 0043 SIO_B_C: EQU $43 ; Channel B Control Register
25
26
27 ;-------------------------- CONSTANTS ----------------------------------------
28 FFFF RAMTOP: EQU $FFFF ; 32Kb RAM 8000H-FFFFH
29 8000 COUNTER: EQU $8000 ; RAM Counter
30
31 ;******************************************************************************
32 ;* RESET HANDLER *
33 ;* Function: Initalize system and start Main Programm *
34 ;******************************************************************************
35 0000 ORG $0000
36 0000 F3 DI ; Disable interrupt
37 0001 31 FF FF LD SP,RAMTOP ; Set stack pointer
38 0004 C3 00 01 JP MAIN ; jump to Main program
39
40
41 ;*******************************************************************
42 ;* MAIN PROGRAM *
43 ;*******************************************************************
44 0100 ORG $100
45 0100 3E 99 MAIN: LD A,$99 ; Initialize 8255: PA0-PA7=IN (DIP SWITCHES), PB0-PB7=OUT (LEDS),
46 0102 D3 83 OUT (PIO_CON),A ; PC0-PC7=IN, Mode 0 Selection
47 0104 3E 01 LD A,$01 ; Initialize RAM Counter
48 0106 21 00 80 LD HL,COUNTER ; Load RAM Counter Address
49 0109 77 LD (HL),A ; Store Counter in RAM cell
50 010A 7E AGAIN: LD A,(HL) ; Load RAM Counter
51 010B D3 81 OUT (PIO_B),A ; Output RAM Counter to LEDs (PB0-PB7)
52 010D 34 INC (HL) : Increment RAM Counter
53 010E CD 14 01 CALL _WAIT
54 0111 C3 0A 01 JP AGAIN ; Endless
55
56
57
58 ;*******************************************************************
59 ;* Warteschleife 0,5s *
60 ;*******************************************************************
61 0114 16 FF _WAIT: LD D,$FF ;
62 0116 1E FF _OUTER: LD E,$FF ;
63 0118 1D _INNER: DEC E
64 0119 C2 18 01 JP NZ,_INNER
65 011C 15 DEC D
66 011D C2 16 01 JP NZ,_OUTER
67 0120 C9 RET
68
69
70
71
72
Symbol table:
AGAIN 010A COUNTER 8000 CTC0 0000 CTC1 0001
CTC2 0002 CTC3 0003 MAIN 0100 PIO_A 0080
PIO_B 0081 PIO_C 0082 PIO_CON 0083 RAMTOP FFFF
SIO_A_C 0042 SIO_A_D 0040 SIO_B_C 0043 SIO_B_D 0041
_INNER 0118 _OUTER 0116 _WAIT 0114
19 symbols.

View file

@ -0,0 +1,291 @@
1 ;******************************************************************************
2 ;* Z80 Assembler program *
3 ;* Josef Reisinger *
4 ;* josef.reisinger@htl-hl.ac.at *
5 ;* 10/07/2017 *
6 ;******************************************************************************
7
8
9 ; ---------------------------- PIO 82C55 I/O ---------------------------------
10 0080 PIO_A: EQU $80 ; (INPUT)
11 0081 PIO_B: EQU $81 ; (OUTPUT) OUT TO LEDS
12 0082 PIO_C: EQU $82 ; (INPUT) IN from DIP SWITCHES
13 0083 PIO_CON: EQU $83 ; CONTROL BYTE PIO 82C55
14
15
16 ; --------------------------- CTC Z80 Timer Counter --------------------------
17 0000 CTC0 EQU $00 ; Channel 0
18 0001 CTC1 EQU $01 ; Channel 1
19 0002 CTC2 EQU $02 ; Channel 2
20 0003 CTC3 EQU $03 ; Channel 3
21
22 ; -------------------------- SIO (USART) ----------------------------------------
23 0040 SIO_A_D: EQU $40 ; Channel A Data Register
24 0041 SIO_B_D: EQU $41 ; Channel B Data Register
25 0042 SIO_A_C: EQU $42 ; Channel A Control Register
26 0043 SIO_B_C: EQU $43 ; Channel B Control Register
27
28
29 ;-------------------------- CONSTANTS ----------------------------------------
30 FFFF RAMTOP: EQU $FFFF ; 32Kb RAM 8000H-FFFFH
31 000D CR: EQU $0D
32 000A LF: EQU $0A
33 0020 SPACE: EQU $20
34
35 ;******************************************************************************
36 ;* RESET HANDLER *
37 ;* Function: Start Main Program *
38 ;******************************************************************************
39 0000 ORG $0000
40 0000 C3 00 01 JP MAIN ; jump to Main program
41
42
43 ;******************************************************************************
44 ;* SIO INTERRUPT HANDLER *
45 ;* Function: Start Main Program *
46 ;******************************************************************************
47 000C ORG $000C
48 000C A5 01 DEFW RX_CHA_AVAILABLE
49
50 000E ORG $000E
51 000E D5 01 DEFW SPEC_RX_CONDITION
52
53
54 ;******************************************************************************
55 ;* NMI HANDLER *
56 ;* Handles NMI Interrupt Request *
57 ;******************************************************************************
58 0066 ORG $0066
59 0066 21 F5 01 LD HL,NMI_TEXT ; Send NMI to V24
60 0069 CD 94 01 CALL SIO_PUT_STRING
61 006C ED 45 RETN
62
63 ;******************************************************************************
64 ;* MAIN PROGRAM *
65 ;******************************************************************************
66 0100 ORG $100
67 0100 F3 MAIN: DI ; Disable interrupt
68 0101 31 FF FF LD SP,RAMTOP ; Set stack pointer
69 0104 CD 26 01 CALL PIO_INIT ; Init PIO (8255)
70 0107 CD 2B 01 CALL CTC_INIT ; Initialize CTC Channel 1 for 9600 Baud (SIO Channel A)
71 010A CD 34 01 CALL SIO_INIT ; Initialize SIO for character based transfer (9600,n,8,1)
72
73 010D 21 E5 01 LD HL,START_TEXT ; Send Welcome Text to V24
74 0110 CD 94 01 CALL SIO_PUT_STRING
75
76 0113 3E 00 LD A,0
77 0115 ED 47 LD I,A ; Load I Register with zero
78 0117 ED 5E IM 2 ; Set Interrupt 2
79 0119 FB EI ; Enable Interrupt
80
81 011A 3E 01 LD A,$01 ; Initialize moving light
82 011C D3 81 _AGAIN: OUT (PIO_B),A ; output Moving light to LED
83 011E CB 17 RL A ; next bit
84 0120 CD D8 01 CALL _WAIT ; wait 0,5 s
85 0123 C3 1C 01 JP _AGAIN ; endless
86
87
88 ;******************************************************************************
89 ;* Initialize PIO (8255) *
90 ;******************************************************************************
91 0126 3E 99 PIO_INIT: LD A,$99 ; Init PIO 8255 Control Word:
92 0128 ; PA0-PA7=IN (DIP SWITCHES)
93 0128 ; PB0-PB7=OUT (LEDS),
94 0128 D3 83 OUT (PIO_CON),A ; PC0-PC7=IN, Mode 0 Selection
95 012A C9 RET
96
97 ;******************************************************************************
98 ;* Initialize CTC Channel 1 (SIO Channel A Clock) *
99 ;******************************************************************************
100 012B 3E 05 CTC_INIT: LD A,$05 ; Init Timer Counter - Channel 1
101 012D D3 01 OUT (CTC1),A ; for Baudrate 9600 (No Interrupt, Timer Mode, PSC=16,
102 012F ; trigger on positive edge
103 012F 3E 0C LD A,$0C ; Write Time constant 12*16*552ns= 105,98s
104 0131 D3 01 OUT (CTC1),A
105 0133 C9 RET
106
107
108 ;******************************************************************************
109 ;* Initialize SIO Channel A for character based transfer *
110 ;* Interrupt on Received characters on Channel A */
111 ;******************************************************************************
112 0134 3E 30 SIO_INIT: LD A,$30 ; Write to WR0 Register --> Error Reset
113 0136 D3 42 OUT (SIO_A_C),A
114 0138 3E 18 LD A,$18 ; Write to WR0 Register --> Channel Reset
115 013A D3 42 OUT (SIO_A_C),A
116 013C 3E 04 LD A,$04 ; Select WR4 Register
117 013E D3 42 OUT (SIO_A_C),A
118 0140 3E 04 LD A,$04 ; CLK*1, 1STOP Bit, No Parity
119 0142 D3 42 OUT (SIO_A_C),A
120
121 0144 CD 7E 01 CALL A_RTS_ON ; TX on, TX 8Bit, DTR inactive, RTS active; Break off
122
123 0147 3E 01 LD A,$1 ; Select WR1 Register Channel B
124 0149 D3 43 OUT (SIO_B_C),A
125 014B 3E 04 LD A,$04 ; no Interrupt on Channel B, status affects Vector
126 014D D3 43 OUT (SIO_B_C),A ;
127 014F 3E 02 LD A,$2 ; Select WR2 Register Channel B
128 0151 D3 43 OUT (SIO_B_C),A
129 0153 3E 00 LD A,$00 ; Definition Interrupt vector. Bits D3,D2,D1 are changed according to
130 0155 D3 43 OUT (SIO_B_C),A ; RX condition (see interrupt vector table)
131
132 0157 3E 01 LD A,$1 ; Select WR1 Register
133 0159 D3 42 OUT (SIO_A_C),A
134 015B 3E 18 LD A,$18 ; Interrupts on all RX Characters, Parity is not a spec RX Condition
135 015D D3 42 OUT (SIO_A_C),A ; Buffer overrun is a special condition, TX no Interrupt
136
137 015F CD 63 01 CALL SIO_A_EN ; Enable RX Channel A
138 0162 C9 RET
139
140
141 ;******************************************************************************
142 ;* Enable RX Channel A *
143 ;******************************************************************************
144 0163 3E 03 SIO_A_EN: LD A,$03 ; Select WR3 Register
145 0165 D3 42 OUT (SIO_A_C),A
146 0167 3E C1 LD A,$C1 ; RX enable,8 Data Bits
147 0169 D3 42 OUT (SIO_A_C),A
148 016B C9 RET
149
150 ;******************************************************************************
151 ;* Disable RX Channel A *
152 ;******************************************************************************
153 016C 3E 03 SIO_A_DI: LD A,$03 ; Select WR3 Register
154 016E D3 42 OUT (SIO_A_C),A
155 0170 3E C0 LD A,$C0 ; RX diable,8 Data Bits
156 0172 D3 42 OUT (SIO_A_C),A
157 0174 C9 RET
158
159 ;******************************************************************************
160 ;* Channel A RTS inactive (RTS = 1) *
161 ;******************************************************************************
162 0175 3E 05 A_RTS_OFF: LD A,$05 ; Select WR5 Register
163 0177 D3 42 OUT (SIO_A_C),A
164 0179 3E 68 LD A,$68 ; TX on,TX 8 Bit, DTR inactive,RTS inactive; Break off,
165 017B D3 42 OUT (SIO_A_C),A
166 017D C9 RET
167
168 ;******************************************************************************
169 ;* Channel A RTS inactive (RTS=0) *
170 ;******************************************************************************
171 017E 3E 05 A_RTS_ON: LD A,$05 ; Select WR5 Register
172 0180 D3 42 OUT (SIO_A_C),A
173 0182 3E 6A LD A,$6A ; TX on,TX 8 Bit,DTR inactive, RTS active; Break off
174 0184 D3 42 OUT (SIO_A_C),A
175 0186 C9 RET
176
177 ;******************************************************************************
178 ;* Send one Character Via SIO Channel A(Polling Mode) *
179 ;* D- Register: Character to send (ASCII Code) *
180 ;******************************************************************************
181 0187 F5 SIO_PUT_CHAR: PUSH AF
182 0188 DB 42 _TX_READY: IN A,(SIO_A_C) ; Read RRO Register
183 018A CB 57 BIT 2,A ; TX Buffer empty ?
184 018C CA 88 01 JP Z,_TX_READY ; No --> Wait
185 018F 7A LD A,D ; load character in A
186 0190 D3 40 OUT (SIO_A_D),A ; Send character (Transfer Buffer)
187 0192 F1 POP AF
188 0193 C9 RET
189
190
191 ;******************************************************************************
192 ;* SEND STRING to V24 via SIO *
193 ;* HL: contains start address of string *
194 ;******************************************************************************
195 0194 F5 SIO_PUT_STRING: PUSH AF
196 0195 7E _NEXT_CHAR: LD A,(HL) ; get character
197 0196 FE 00 CP $00 ; END of String ?
198 0198 CA A3 01 JP Z,_TEXT_END
199 019B 57 LD D,A
200 019C CD 87 01 CALL SIO_PUT_CHAR ; send character
201 019F 23 INC HL ; next character
202 01A0 C3 95 01 JP _NEXT_CHAR
203 01A3 F1 _TEXT_END: POP AF
204 01A4 C9 RET
205
206
207 ;******************************************************************************
208 ;* INTERUTPT HANDLE SIO CHANNEL A CHARACTER RECEIVE *
209 ;******************************************************************************
210 01A5 F5 RX_CHA_AVAILABLE: PUSH AF
211 01A6 CD 75 01 CALL A_RTS_OFF
212 01A9 DB 40 IN A,(SIO_A_D) ; Read RX Character
213 01AB 57 LD D,A ; load Character in D
214 01AC CD 87 01 CALL SIO_PUT_CHAR ; Echo Char back to Host
215
216 01AF 3E 00 _NEXT_RX_CHAR: LD A,$0 ;Select RR0 Register
217 01B1 D3 42 OUT (SIO_A_C),A
218 01B3 DB 42 IN A,(SIO_A_C) ; Read RRO Register
219 01B5 CB 47 BIT 0,A ; RX Character Available ?
220 01B7 CA C3 01 JP Z,_NEXT_TX_CHAR ; No --> OK
221 01BA DB 40 IN A,(SIO_A_D) ; Read that character
222 01BC 57 LD D,A ; load Character in D
223 01BD CD 87 01 CALL SIO_PUT_CHAR ; Echo Char back to Host
224 01C0 C3 AF 01 JP _NEXT_RX_CHAR
225
226 01C3 3E 01 _NEXT_TX_CHAR: LD A,$1 ; Select RR1 Register
227 01C5 D3 42 OUT (SIO_A_C),A
228 01C7 DB 42 IN A,(SIO_A_C) ; Read RR1 Register
229 01C9 CB 47 BIT 0,A ; ALL Characters sent ?
230 01CB CA C3 01 JP Z,_NEXT_TX_CHAR
231
232 01CE FB _EO_CH_AV: EI
233 01CF CD 7E 01 CALL A_RTS_ON
234 01D2 F1 POP AF
235 01D3 ED 4D RETI
236
237 ;******************************************************************************
238 ;* INTERUTPT HANDLE SIO CHANNEL A ERROR *
239 ;******************************************************************************
240 01D5 SPEC_RX_CONDITION
241 01D5 C3 00 01 JP MAIN ; Restart -> jump to Main program (RESTART)
242
243
244
245 ;*******************************************************************
246 ;* Warteschleife 0,5s *
247 ;*******************************************************************
248 01D8 06 FF _WAIT: LD B,$FF ;
249 01DA 0E FF _OUTER: LD C,$FF ;
250 01DC 0D _INNER: DEC C
251 01DD C2 DC 01 JP NZ,_INNER
252 01E0 05 DEC B
253 01E1 C2 DA 01 JP NZ,_OUTER
254 01E4 C9 RET
255
256 ;******************************************************************************
257 ;* TEXT DEFINITIONS *
258 ;******************************************************************************
259 01E5 0D 0A 5A 38 START_TEXT: DEFB CR,LF,'Z','8','0',SPACE,'D','E','M','O',SPACE,'V','1','.','0',$00
01E9 30 20 44 45
01ED 4D 4F 20 56
01F1 31 2E 30 00
260 01F5 0D 0A 4E 4D NMI_TEXT: DEFB CR,LF,'N','M','I',$00
01F9 49 00
261
262
263
264
265
266
267
268
269
Symbol table:
A_RTS_OFF 0175 A_RTS_ON 017E CR 000D
CTC0 0000 CTC1 0001 CTC2 0002
CTC3 0003 CTC_INIT 012B LF 000A
MAIN 0100 NMI_TEXT 01F5 PIO_A 0080
PIO_B 0081 PIO_C 0082 PIO_CON 0083
PIO_INIT 0126 RAMTOP FFFF RX_CHA_AVAILABLE 01A5
SIO_A_C 0042 SIO_A_D 0040 SIO_A_DI 016C
SIO_A_EN 0163 SIO_B_C 0043 SIO_B_D 0041
SIO_INIT 0134 SIO_PUT_CHAR 0187 SIO_PUT_STRING 0194
SPACE 0020 SPEC_RX_CONDITION 01D5 START_TEXT 01E5
_AGAIN 011C _EO_CH_AV 01CE _INNER 01DC
_NEXT_CHAR 0195 _NEXT_RX_CHAR 01AF _NEXT_TX_CHAR 01C3
_OUTER 01DA _TEXT_END 01A3 _TX_READY 0188
_WAIT 01D8
40 symbols.

View file

@ -0,0 +1,202 @@
1 ;******************************************************************************
2 ;* Z80 Assembler program *
3 ;* Josef Reisinger *
4 ;* josef.reisinger@htl-hl.ac.at *
5 ;* 10/07/2017 *
6 ;******************************************************************************
7
8
9 ; ---------------------------- PIO 82C55 I/O ---------------------------------
10 0080 PIO_A: EQU $80 ; (INPUT)
11 0081 PIO_B: EQU $81 ; (OUTPUT) OUT TO LEDS
12 0082 PIO_C: EQU $82 ; (INPUT) IN from DIP SWITCHES
13 0083 PIO_CON: EQU $83 ; CONTROL BYTE PIO 82C55
14
15
16 ; --------------------------- CTC Z80 Timer Counter --------------------------
17 0000 CTC0 EQU $00 ; Channel 0
18 0001 CTC1 EQU $01 ; Channel 1
19 0002 CTC2 EQU $02 ; Channel 2
20 0003 CTC3 EQU $03 ; Channel 3
21
22 ; -------------------------- SIO (USART) ----------------------------------------
23 0040 SIO_A_D: EQU $40 ; Channel A Data Register
24 0041 SIO_B_D: EQU $41 ; Channel B Data Register
25 0042 SIO_A_C: EQU $42 ; Channel A Control Register
26 0043 SIO_B_C: EQU $43 ; Channel B Control Register
27
28
29 ;-------------------------- CONSTANTS ----------------------------------------
30 FFFF RAMTOP: EQU $FFFF ; 32Kb RAM 8000H-FFFFH
31 000D CR: EQU $0D
32 000A LF: EQU $0A
33 0020 SPACE: EQU $20
34
35 ;******************************************************************************
36 ;* RESET HANDLER *
37 ;* Function: Start Main Program *
38 ;******************************************************************************
39 0000 ORG $0000
40 0000 C3 00 01 JP MAIN ; jump to Main program
41
42
43 ;******************************************************************************
44 ;* NMI HANDLER *
45 ;* Handles NMI Interrupt Request *
46 ;******************************************************************************
47 0066 ORG $0066
48 0066 21 A1 01 LD HL,NMI_TEXT ; Send NMI to V24
49 0069 CD 80 01 CALL SIO_PUT_STRING
50 006C ED 45 RETN
51
52 ;******************************************************************************
53 ;* MAIN PROGRAM *
54 ;******************************************************************************
55 0100 ORG $100
56 0100 F3 MAIN: DI ; Disable interrupt
57 0101 31 FF FF LD SP,RAMTOP ; Set stack pointer
58 0104 CD 1F 01 CALL PIO_INIT ; Init PIO (8255)
59 0107 CD 24 01 CALL CTC_INIT ; Initialize CTC Channl1 for 9600 Baud (SIO Channel A)
60 010A CD 2D 01 CALL SIO_INIT ; Animalize SIO for character based transfer (9600,n,8,1)
61 010D 21 91 01 LD HL,START_TEXT ; Send Welcome Text to V24
62 0110 CD 80 01 CALL SIO_PUT_STRING
63 0113 CD 63 01 _AGAIN: CALL SIO_GET_CHAR ; Wait for Character on V24
64 0116 7B LD A,E ; Output Error to LED's
65 0117 D3 81 OUT (PIO_B),A
66 0119 CD 56 01 CALL SIO_PUT_CHAR ; Echo Character to V24
67 011C C3 13 01 JP _AGAIN
68 011F ;
69
70 ;******************************************************************************
71 ;* Initialize PIO (8255) *
72 ;******************************************************************************
73 011F 3E 99 PIO_INIT: LD A,$99 ; Init PIO 8255 Control Word:
74 0121 ; PA0-PA7=IN (DIP SWITCHES)
75 0121 ; PB0-PB7=OUT (LEDS),
76 0121 D3 83 OUT (PIO_CON),A ; PC0-PC7=IN, Mode 0 Selection
77 0123 C9 RET
78
79 ;******************************************************************************
80 ;* Initialize CTC Channel 1 (SIO Channel A Clock) *
81 ;******************************************************************************
82 0124 3E 05 CTC_INIT: LD A,$05 ; Init Timer Counter - Channel 1
83 0126 D3 01 OUT (CTC1),A ; for Baudrate 9600 (No Interrupt, Timer Mode, PSC=16,
84 0128 ; trigger on positive edge
85 0128 3E 0C LD A,$0C ; Write Time constant 12*16*552ns= 105,98s
86 012A D3 01 OUT (CTC1),A
87 012C C9 RET
88
89
90 ;******************************************************************************
91 ;* Initialize SIO Channel A for character based transfer *
92 ;******************************************************************************
93 012D 3E 30 SIO_INIT: LD A,$30 ; Write to WR0 Register --> Error Reset
94 012F D3 42 OUT (SIO_A_C),A
95 0131 3E 18 LD A,$18 ; Write to WR0 Register --> Channel Reset
96 0133 D3 42 OUT (SIO_A_C),A
97 0135 3E 04 LD A,$04 ; Select WR4 Register
98 0137 D3 42 OUT (SIO_A_C),A
99 0139 3E 04 LD A,$04 ; CLK*1, 1STOP Bit, No Parity
100 013B D3 42 OUT (SIO_A_C),A
101 013D 3E 03 LD A,$03 ; Select WR3 Register
102 013F D3 42 OUT (SIO_A_C),A
103 0141 3E C1 LD A,$C1 ; RX enable,8 Data Bits
104 0143 D3 42 OUT (SIO_A_C),A
105 0145 3E 05 LD A,$05 ; Select WR5 Register
106 0147 D3 42 OUT (SIO_A_C),A
107 0149 3E 68 LD A,$68 ; TX enable,8 Data Bits, DTR inactive, RTS inactive,Break off
108 014B D3 42 OUT (SIO_A_C),A
109 014D 3E 01 LD A,$1 ; Select WR1 Register
110 014F D3 42 OUT (SIO_A_C),A
111 0151 3E 00 LD A,$0 ; No Interrupts for Rx and Tx Characters
112 0153 D3 42 OUT (SIO_A_C),A
113 0155 C9 RET
114
115
116
117 ;******************************************************************************
118 ;* Send one Character Via SIO Channel A(Polling Mode) *
119 ;* D- Register: Character to send (ASCII Code) *
120 ;******************************************************************************
121 0156 F5 SIO_PUT_CHAR: PUSH AF
122 0157 DB 42 _TX_READY: IN A,(SIO_A_C) ; Read RRO Register
123 0159 CB 57 BIT 2,A ; TX Buffer empty ?
124 015B CA 57 01 JP Z,_TX_READY ; No --> Wait
125 015E 7A LD A,D ; load character in A
126 015F D3 40 OUT (SIO_A_D),A ; Send character (Transfer Buffer)
127 0161 F1 POP AF
128 0162 C9 RET
129
130
131 ;******************************************************************************
132 ;* Receive one Character Via SIO Channel A(Polling Mode) *
133 ;* D- Register: Character received (ASCII Code) *
134 ;* E-Register: Error Code *
135 ;******************************************************************************
136 0163 F5 SIO_GET_CHAR: PUSH AF
137 0164 DB 42 _RX_READY: IN A,(SIO_A_C) ; Read RRO Register
138 0166 CB 47 BIT 0,A ; RX Character Available ?
139 0168 CA 64 01 JP Z,_RX_READY ; No --> Wait
140 016B DB 40 IN A,(SIO_A_D) ; Store character
141 016D 57 LD D,A
142 016E 3E 01 LD A,$01 ; Select WR1 Register
143 0170 D3 42 OUT (SIO_A_C),A
144 0172 DB 42 IN A,(SIO_A_C) ; Read Error Register
145 0174 5F LD E,A ; store Error Status
146 0175 E6 70 AND $70 ; only D6(CRC Framing Error),D5(Rx Overrun Error) und D4 (Parity Error)
147 0177 CA 7E 01 JP Z,_RX_EXIT ; return if no error
148 017A 3E 30 LD A,$30 ; reset Error
149 017C D3 42 OUT (SIO_A_C),A
150 017E F1 _RX_EXIT: POP AF
151 017F C9 RET
152
153
154 ;******************************************************************************
155 ;* SEND STRING to V24 via SIO *
156 ;* HL: contains start address of string *
157 ;******************************************************************************
158 0180 F5 SIO_PUT_STRING: PUSH AF
159 0181 7E _NEXT_CHAR: LD A,(HL) ; get character
160 0182 FE 00 CP $00 ; END of String ?
161 0184 CA 8F 01 JP Z,_TEXT_END
162 0187 57 LD D,A
163 0188 CD 56 01 CALL SIO_PUT_CHAR ; send character
164 018B 23 INC HL ; next character
165 018C C3 81 01 JP _NEXT_CHAR
166 018F F1 _TEXT_END: POP AF
167 0190 C9 RET
168
169
170 ;******************************************************************************
171 ;* TEXT DEFINITIONS *
172 ;******************************************************************************
173 0191 0D 0A 5A 38 START_TEXT: DEFB CR,LF,'Z','8','0',SPACE,'D','E','M','O',SPACE,'V','1','.','0',$00
0195 30 20 44 45
0199 4D 4F 20 56
019D 31 2E 30 00
174 01A1 0D 0A 4E 4D NMI_TEXT: DEFB CR,LF,'N','M','I',$00
01A5 49 00
175
176
177
178
179
180
181
182
183
Symbol table:
CR 000D CTC0 0000 CTC1 0001
CTC2 0002 CTC3 0003 CTC_INIT 0124
LF 000A MAIN 0100 NMI_TEXT 01A1
PIO_A 0080 PIO_B 0081 PIO_C 0082
PIO_CON 0083 PIO_INIT 011F RAMTOP FFFF
SIO_A_C 0042 SIO_A_D 0040 SIO_B_C 0043
SIO_B_D 0041 SIO_GET_CHAR 0163 SIO_INIT 012D
SIO_PUT_CHAR 0156 SIO_PUT_STRING 0180 SPACE 0020
START_TEXT 0191 _AGAIN 0113 _NEXT_CHAR 0181
_RX_EXIT 017E _RX_READY 0164 _TEXT_END 018F
_TX_READY 0157
31 symbols.

55
Reischl/lst/pio.lst Normal file
View file

@ -0,0 +1,55 @@
1 ;******************************************************************************
2 ;* Z80 Assemblerprogramm *
3 ;* Josef Reisinger *
4 ;* josef.reisinger@htl-hl.ac.at *
5 ;* 26/04/2015 *
6 ;******************************************************************************
7
8
9 ; ---------------------------- PIO 82C55 I/O ---------------------------------
10 0080 PIO_A: EQU $80 ; (INPUT)
11 0081 PIO_B: EQU $81 ; (OUTPUT) OUT TO LEDS
12 0082 PIO_C: EQU $82 ; (INPUT) IN from DIP SWITCHES
13 0083 PIO_CON: EQU $83 ; CONTROL BYTE PIO 82C55
14
15 ; --------------------------- CTC Z80 Timer Counter --------------------------
16 0000 CTC0 EQU $00 ; Channel 0
17 0001 CTC1 EQU $01 ; Channel 1
18 0002 CTC2 EQU $02 ; Channel 2
19 0003 CTC3 EQU $03 ; Channel 3
20
21 ; -------------------------- SIO (USART) ----------------------------------------
22 0040 SIO_A_D: EQU $40 ; Channel A Data Register
23 0041 SIO_B_D: EQU $41 ; Channel B Data Register
24 0042 SIO_A_C: EQU $42 ; Channel A Control Register
25 0043 SIO_B_C: EQU $43 ; Channel B Control Register
26
27
28 ;-------------------------- CONSTANTS ----------------------------------------
29 FFFF RAMTOP: EQU $FFFF ; 32Kb RAM 8000H-FFFFH
30
31
32 ;******************************************************************************
33 ;* START AFTER RESET, *
34 ;* Function....: ready system and restart *
35 ;******************************************************************************
36 0000 ORG $0000
37 0000 F3 DI ; Disable interrupt
38 0001 31 FF FF LD SP,RAMTOP ; Set stack pointer to top off ram
39 0004 3E 99 LD A,$99 ; PA0-PA7=IN (DIP SWITCHES), PB0-PB7=OUT (LEDS), PC0-PC7=IN, Mode 0 Selektion
40 0006 D3 83 OUT (PIO_CON),A
41 0008 DB 83 IN A,(PIO_CON)
42 000A DB 80 AGAIN: IN A,(PIO_A) ; Read actual status of Switches (PA0-PA7)
43 000C D3 81 OUT (PIO_B),A ; Output Status to LEDs (PB0-PB7)
44 000E C3 0A 00 JP AGAIN ; Endless
45
46
47
Symbol table:
AGAIN 000A CTC0 0000 CTC1 0001 CTC2 0002
CTC3 0003 PIO_A 0080 PIO_B 0081 PIO_C 0082
PIO_CON 0083 RAMTOP FFFF SIO_A_C 0042 SIO_A_D 0040
SIO_B_C 0043 SIO_B_D 0041
14 symbols