Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 1
sp.s
Location Object Type Line Source
A 1 ;
A 2 ; serpar2.s
A 3 ;
A 4 ; interfaccia seriale/parrallela con Z8 (86E30)
A 5 ; a 9600 (19200) baud con 16 bit base di I/O
A 6 ; con 2 input e 2 output fissi
A 7 ;
A 8 ; rev. 0
A 9 ; tc: 5
A 10 ;
A 11 ; mo12apr99 we14apr99 th15apr99 XD.
A 12 ; we28jul99 th29jul99 mo 9aug99 XD.
A 13 ; tu29sep99 fr 1oct99 XD.
A 14 ;
A 15 ; codice modificato per gestione soli comandi
A 16 ; programmatore eprom con 8255
A 17 ;
A 18 ; sa 2oct99 tu35jul00 XD.
A 19 ;
A 20 ; protocollo di comunicazione:
A 21 ; chr 0 -> write 8255 control register
A 22 ; chr 1 -> write 8255 port A
A 23 ; chr 2 -> write 8255 port B
A 24 ; chr 3 -> write 8255 port C
A 25 ; chr 4 -> read 8255 port B
A 26 ;
A 27 ;
A 28 ; P00-P07 -> port A bit 0-7 (nibble I/O)
A 29 ; P20-P27 -> port B bit 0-7 (bit I/O)
A 30 ; P30 -> rs232 serial in
A 31 ; P31-P32 -> input bit port C bit 0-1
A 32 ; P33 -> charge pump in
A 33 ; P34 -> charge pump out
A 34 ; P35-P36 -> output bit port C bit 2-3
A 35 ; P37 -> rs232 serial out
A 36 ;
A 37 ; 1 output
A 38 ; 0 input
A 39 ;
A 40 ; setup porte:
A 41 ; port A 0-7 out/in 8255 dbus
A 42 ; port B 0-3 in 4-7 out 8255 cntrl signal
A 43 ;
A 44 ;
A 45 ; equates
A 46 ;
A 47
A 48 ; general equates
00000010 A 49 WORKREG .equ 10H
A 50 ; numero microsecondi per bit
A 51 ; BAUD .equ 104 ; 9600 bps
00000034 A 52 BAUD .equ 52 ; 19200 bps
A 53 ; contatore di bit
R0 A 54 BITCNT .equ R0
A 55 ; buffer di ricezione rs
R1 A 56 RXBUF .equ R1
A 57 ; registro d'appoggio ingresso rs
R2 A 58 RSINP .equ R2
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 2
sp.s
Location Object Type Line Source
A 59 ; byte ricevuto dalla seriale
0000000C A 60 RXBYTE .equ 0CH
A 61 ; byte trasmesso alla seriale
0000000D A 62 TXBYTE .equ 0DH
A 63 ; puntatore al rx buffer
00000000 A 64 RXPNT
A 65 ; flag di ricezione
00000000 A 66 RXFLAG
A 67 ; t1int equates
0000000E A 68 TR14 .equ 0EH
0000000F A 69 TR15 .equ 0FH
A 70 ; registri temporanei
R3 A 71 TEMP .equ R3
R4 A 72 TEMP2 .equ R4
A 73 ;
A 74 .org 0000H
00000000 FF FF A 75 .word 0FFFFH
00000002 FF FF A 76 .word 0FFFFH
00000004 FF FF A 77 .word 0FFFFH
00000006 FF FF A 78 .word 0FFFFH ; SERIN ; P30 falling edge
00000008 00 F8 A 79 .word T0INT
0000000A FF FF A 80 .word 0FFFFH ; T1INT
A 81 .org 000CH
A 82 ; disabilita le interruzioni
0000000C FF FF A 83 RESET dw 0FFFFH
0000000E FF A 84 db 0FFH
0000000F 8F A 85 DI
A 86 ; setup porte P0,P24-27 out stack int
00000010 E6 F8 04 A 87 LD P01M,#00000100B
00000013 E6 F6 0F A 88 LD P2M,#00FH
00000016 E6 F7 01 A 89 LD P3M,#00000001B ; P3 digital
A 90 ; setup z8 regs
00000019 B0 FA A 91 CLR IRQ
0000001B E6 F9 03 A 92 LD IPR,#00000011B
0000001E B0 FB A 93 CLR IMR
A 94 ; stack pointer 00f0h
00000020 B0 FE A 95 CLR SPH
00000022 E6 FF F0 A 96 LD SPL,#0F0H
A 97 ; seleziona registri lavoro
00000025 31 10 A 98 SRP #WORKREG
A 99 ;
A 100
A 101
A 102 ; ricevi carattere comando da rs232
00000027 FF FF A 103 LOOP dw 0FFFFH
00000029 FF A 104 db 0FFH
A 105 ; EI ; check
A 106 ;
0000002A D6 00 CE A 107 CALL RXRS232
0000002D A6 0C 00 A 108 CP RXBYTE,#0
00000030 EB 0E A 109 JR NZ,CP00
A 110 ; chr 0 -> write control
00000032 D6 00 CE A 111 CALL RXRS232
00000035 E4 0C 00 A 112 LD P0,RXBYTE
00000038 E6 02 E0 A 113 LD P2,#0E0H
0000003B E6 02 F0 A 114 LD P2,#0F0H
0000003E 8B E7 A 115 JR LOOP
00000040 A6 0C 01 A 116 CP00 CP RXBYTE,#1
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 3
sp.s
Location Object Type Line Source
00000043 EB 0E A 117 JR NZ,CP01
A 118 ; chr 1 -> write port a
00000045 D6 00 CE A 119 CALL RXRS232
00000048 E4 0C 00 A 120 LD P0,RXBYTE
0000004B E6 02 20 A 121 LD P2,#020H
0000004E E6 02 30 A 122 LD P2,#030H
00000051 8B D4 A 123 JR LOOP
00000053 A6 0C 02 A 124 CP01 CP RXBYTE,#2
00000056 EB 0E A 125 JR NZ,CP02
A 126 ; chr 2 -> write port b
00000058 D6 00 CE A 127 CALL RXRS232
0000005B E4 0C 00 A 128 LD P0,RXBYTE
0000005E E6 02 A0 A 129 LD P2,#0A0H
00000061 E6 02 B0 A 130 LD P2,#0B0H
00000064 8B C1 A 131 JR LOOP
00000066 A6 0C 03 A 132 CP02 CP RXBYTE,#3
00000069 EB 0E A 133 JR NZ,CP03
A 134 ; chr 3 -> write port c
0000006B D6 00 CE A 135 CALL RXRS232
0000006E E4 0C 00 A 136 LD P0,RXBYTE
00000071 E6 02 60 A 137 LD P2,#060H
00000074 E6 02 70 A 138 LD P2,#070H
00000077 8B AE A 139 JR LOOP
00000079 A6 0C 04 A 140 CP03 CP RXBYTE,#4
0000007C EB A9 A 141 JR NZ,LOOP ; not valid command
A 142 ; chr 4 -> read port b
0000007E E6 F8 45 A 143 LD P01M,#45H
00000081 E6 02 90 A 144 LD P2,#090H
00000084 E6 02 B0 A 145 LD P2,#0B0H
00000087 E4 00 0D A 146 LD TXBYTE,P0
0000008A D6 00 92 A 147 CALL TXRS232
0000008D E6 F8 04 A 148 LD P01M,#04H
00000090 8B 95 A 149 JR LOOP
A 150
A 151
A 152 ;
A 153 ; rs 232 transmitter routine
A 154 ; in: txdata loc mod
A 155 ; usd: tr14 t0int tx data reg
A 156 ; tr15 t0int bitcount reg
A 157 ;
00000092 A 158 TXRS232
00000092 EC 00 A 159 LD R14,#HIGH TXINT
00000094 FC FA A 160 LD R15,#LOW TXINT
A 161 ; salva imr
00000096 70 FB A 162 PUSH IMR
A 163 ; abilita solo t0int
00000098 E6 FB 10 A 164 LD IMR,#00010000B ; CHECK!
A 165 ; added watch dog instruction
A 166 ; WDOG
A 167 ; serial baudrate use t0 for tim'g
0000009B E6 F4 34 A 168 LD T0,#BAUD
A 169 ; 104 ; 9600 bps
A 170 ; 52 ; 19200 bps
0000009E E6 F5 05 A 171 LD PRE0,#00000101B ; pre 1
000000A1 46 F1 03 A 172 OR TMR,#3 ; load enbl t0
A 173 ;
000000A4 9F A 174 EI
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 4
sp.s
Location Object Type Line Source
A 175 ; now send 0 bit & start bit
000000A5 E6 0F 02 A 176 LD TR15,#2
000000A8 E6 0E FD A 177 LD TR14,#11111101B
000000AB A6 0F 00 A 178 RT0 CP TR15,#0
000000AE EB FB A 179 JR NZ,RT0
A 180 ; send 8 bit of data
000000B0 E6 0F 08 A 181 LD TR15,#8
000000B3 E4 0D 0E A 182 LD TR14,TXBYTE ; >> CHECK !!
000000B6 A6 0F 00 A 183 RT1 CP TR15,#0
000000B9 EB FB A 184 JR NZ,RT1
A 185 ; now send stop bit
000000BB E6 0F 01 A 186 LD TR15,#1
000000BE E6 0E FF A 187 LD TR14,#0FFH
000000C1 A6 0F 00 A 188 RT2 CP TR15,#0
000000C4 EB FB A 189 JR NZ,RT2
A 190 ;
000000C6 8F A 191 DI
000000C7 56 F1 FC A 192 AND TMR,#11111100B
A 193 ; ripristina imr
000000CA 50 FB A 194 POP IMR
A 195 ;
000000CC 9F A 196 EI
000000CD AF A 197 RET
A 198 ;
A 199 ; routine ricezione di un byte da P30
A 200 ;
000000CE A 201 RXRS232
A 202 ;
000000CE EC 01 A 203 LD R14,#HIGH RXINT
000000D0 FC 08 A 204 LD R15,#LOW RXINT
A 205 ; salva imr
000000D2 70 FB A 206 PUSH IMR
A 207 ; abilita solo t0int
000000D4 E6 FB 10 A 208 LD IMR,#00010000B ; CHECK!
A 209 ; div 1 * 104 0.104 ms 9600 baud
000000D7 E6 F5 05 A 210 LD PRE0,#00000101B
000000DA E6 F4 34 A 211 LD T0,#BAUD
A 212 ; aspetta carattere dalla rs232
000000DD 76 03 01 A 213 WLOOP TM P3,#1 ; P30
000000E0 EB FB A 214 JR NZ,WLOOP
A 215 ; carica abilita t0
000000E2 46 F1 03 A 216 OR TMR,#00000011B
A 217 ; abilita le interruzioni
000000E5 9F A 218 EI
A 219 ; azzera il buffer di ricezione e
A 220 ; carica il contatore di bit con 8
000000E6 B0 E1 A 221 CLR RXBUF
000000E8 0C 08 A 222 LD BITCNT,#8
A 223 ; loopa fino alla ricezione di un
A 224 ; byte dalla seriale
000000EA A6 E0 00 A 225 SERIN0 CP BITCNT,#0
000000ED EB FB A 226 JR NE,SERIN0
A 227 ; copia il buffer di ricezione
A 228 ; nel byte ricevuto dalla seriale
000000EF 19 0C A 229 LD RXBYTE,RXBUF
A 230 ; azzera il buffer di ricezione e
A 231 ; carica il contatore di bit con 1
A 232 ;; CLR RXBUF
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 5
sp.s
Location Object Type Line Source
A 233 ;; LD BITCNT,#1
A 234 ; loopa fino alla ricezione dello
A 235 ; stop bit
A 236 ;; SERIN1 CP BITCNT,#0
A 237 ;; JR NE,SERIN1
A 238 ; disabilita t0
000000F1 8F A 239 DI
000000F2 56 F1 FC A 240 AND TMR,#11111100B
A 241 ; ripristina imr
000000F5 50 FB A 242 POP IMR
A 243 ;
A 244 ; setta il flag recbyte
A 245 ;
A 246 ; OR RXFLAG,#1B
A 247 ;
A 248 ; ripristina program counter
000000F7 AF A 249 RET
A 250 ;
A 251 ;
A 252 ; +--------------------+
A 253 ; | INTERRUPT ROUTINES |
A 254 ; +--------------------+
A 255 ;
A 256 ;
A 257 ; salta alla routine puntata da rr14
000000F8 30 EE A 258 T0INT JP @RR14
A 259 ;
A 260 ; tr14 t0int tx data reg mod
A 261 ; tr15 t0int bitcount reg
A 262 ;
000000FA 00 0F A 263 TXINT DEC TR15
000000FC E0 0E A 264 RR TR14
000000FE 7B 04 A 265 JR C,TI0
00000100 56 03 7F A 266 AND P3,#01111111B ; P37
00000103 BF A 267 IRET
00000104 46 03 80 A 268 TI0 OR P3, #10000000B ; P37
00000107 BF A 269 IRET
A 270 ;
A 271 ; Routine sotto interrupt per la
A 272 ; ricezione dei singoli bit
A 273 ; tramite temporizzazione di t0
A 274 ;
A 275 ; decrementa il contatore di bit
00000108 00 E0 A 276 RXINT DEC BITCNT
A 277 ; carica in rsinp la porta P3
0000010A 28 03 A 278 LD RSINP,P3
A 279 ; ruota a destra 1 volta rsinp
A 280 ; ossia metti P30 nel carry
0000010C E0 E2 A 281 RR RSINP
A 282 ; ruota a destra con il carry
A 283 ; rxbuff
A 284 ; ossia metti il carry (P30)
A 285 ; nel bit 7 di rxbuf
0000010E C0 E1 A 286 RRC RXBUF
A 287 ; ripristina flags
A 288 ; ripristina program counter
A 289 ; riabilita le interruzioni
00000110 BF A 290 IRET
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 6
sp.s
Location Object Type Line Source
A 291 ;
A 292
A 293
A 294
A 295
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 7
sp.s
Symbol Name Value Section
BAUD 00000034
BITCNT R0
code Section code
CP00 00000040 code
CP01 00000053 code
CP02 00000066 code
CP03 00000079 code
LOOP 00000027 code
RESET 0000000C code
RSINP R2
RT0 000000AB code
RT1 000000B6 code
RT2 000000C1 code
RXBUF R1
RXBYTE 0000000C
RXFLAG 00000000 code
RXINT 00000108 code
RXPNT 00000000 code
RXRS232 000000CE code
SERIN0 000000EA code
T0INT 000000F8 code
TEMP R3
TEMP2 R4
TI0 00000104 code
TR14 0000000E
TR15 0000000F
TXBYTE 0000000D
TXINT 000000FA code
TXRS232 00000092 code
WLOOP 000000DD code
WORKREG 00000010
31 Symbols.
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 8
sp.s
Symbol Name References
BAUD 52* 168 211
BITCNT 54* 222 225 276
CP00 109 116*
CP01 117 124*
CP02 125 132*
CP03 133 140*
LOOP 103* 115 123 131 139 141 149
RESET 83*
RSINP 58* 278 281
RT0 178* 179
RT1 183* 184
RT2 188* 189
RXBUF 56* 221 229 286
RXBYTE 60* 108 112 116 120 124 128
132 136 140 229
RXFLAG 66*
RXINT 203 204 276*
RXPNT 64*
RXRS232 107 111 119 127 135 201*
SERIN0 225* 226
T0INT 79 258*
TEMP 71*
TEMP2 72*
TI0 265 268*
TR14 68* 177 182 187 264
TR15 69* 176 178 181 183 186 188
263
TXBYTE 62* 146 182
TXINT 159 160 263*
TXRS232 147 158*
WLOOP 213* 214
WORKREG 49* 98
Zilog Macro Assembler. Version K2.01 01-Jan-80 11:31:50 Page: 9
sp.s
0 Warnings
0 Errors