copyrigth TAPR 2005 http://tapr.org/kits_metcon2.html MC2LDEV MC-2 Development 990419-2.00v PAGE 1 1 $NOOBJECT 2 $PRINT 3 $LIST 4 $SYMBOLS =1 5 $INCLUDE(METCON2D.ASM) ; this is it =1 6 $PAGING =1 7 $PAGEWIDTH(131) =1 8 $TITLE(MC-2 Development 990419-2.00v) =1 9 $MOD52 =1 10 =1 11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =1 12 ; METCON-1 -- TeleMETry and CONtrol, System 1 =1 13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =1 14 0000 =1 15 FALSE EQU 0 0001 =1 16 TRUE EQU 1 =1 17 0001 =1 18 DEV EQU TRUE ; code will execute from monitor RAM 0001 =1 19 CPU8052 EQU TRUE ; flag for 8052 CPU 0001 =1 20 UARTINT EQU TRUE ; flag for UART internal (false for external) 0001 =1 21 UCOM EQU TRUE ; set true when uart console in system 0001 =1 22 I2CBB EQU TRUE ; I2C implemented with bit-banging 0000 =1 23 I2C751 EQU FALSE ; True when I2c implemented with 87C751 HW 0001 =1 24 VALP0 EQU TRUE ; Valid P0, do P0 updates when TRUE 0001 =1 25 VALP2 EQU TRUE ; Valid P2, do P2 updates when TRUE 0000 =1 26 VALP4 EQU FALSE ; Valid P4, do P4 updates when TRUE 0000 =1 27 VALP5 EQU FALSE ; Valid P5, do P5 updates when TRUE 0000 =1 28 VALP6 EQU FALSE ; Valid P6, do P6 updates when TRUE =1 29 =2 30 $INCLUDE(NOTES.ASM) ; include programmers notes =2 31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 32 ; +++ NOTES.ASM =2 33 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 34 =2 35 =2 36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 37 ; Assembler =2 38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 39 ; =2 40 ; The assembler used to assemble this code is ASM51 by =2 41 ; =2 42 ; MetaLink Corporation =2 43 ; Post Office Box 1329 =2 44 ; Chandler, AZ 85244-1329 =2 45 ; +1-602-926-0797 [voice] =2 46 ; +1-602-926-1198 [fax] =2 47 ; =2 48 ; MetaLink makes this assembler available, free of charge, =2 49 ; as an advertising vehicle for their other products. =2 50 ; The assembler (and lots of other wonderful code) can be =2 51 ; downloaded from the Phillips web site at =2 52 ; http://www.PhilipsMCU.com/ftp.html or at their dial up BBS =2 53 ; at +1-408-991-2406 or, for those in the U.S. at 800-451-6644. =2 54 ; =2 55 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 56 ; Revision History =2 57 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 58 ; MC2LDEV MC-2 Development 990419-2.00v PAGE 2 =2 59 ; 910326-1.000 Initial Release =2 60 ; =2 61 ; 910731-1.01 First Revision =2 62 ; Fix binary to Decimal Coversion =2 63 ; Add Serious Authentication System =2 64 ; Add Auto Disconnect if Not Logged In w/in 60 sec =2 65 ; =2 66 ; 910907-1.02 Second Revision =2 67 ; Make Byte Read/Write give data in Decimal, not just =2 68 ; Hex and Binary =2 69 ; Add Accumulating Pulse Counters =2 70 ; Correct Authentication Problem When Not SYSADMIN =2 71 ; Move ECHO and NLF to Restricted Memory =2 72 ; Change ECHO (active high) to NECHO (disable when high) =2 73 ; =2 74 ; 911125-1.03 Third Revision =2 75 ; In file IO.ASM added code to UDP0 to clear change bits =2 76 ; for all inputs on port 0 that are configured for =2 77 ; accumulating pulse counters =2 78 ; =2 79 ; 920405-1.04 Fourth Revision =2 80 ; Change sequence of startup if EEPROM failure detected =2 81 ; Provide individual CHANGE bits for each input =2 82 ; Move NII and NIO to restricted memory =2 83 ; Only accumulate pulse values on those ports that are =2 84 ; configured as pulse counters. In version 1.02 and =2 85 ; 1.03 an input configured for pulse counter worked fine. =2 86 ; However, inputs configured as frequency counters =2 87 ; contained a value equal to the frequency PLUS the =2 88 ; number of pulses counted (sampled at a 20 samples =2 89 ; per second rate). A work-around for 1.02 and 1.03 =2 90 ; is to set the input ports used for frequency =2 91 ; counters to 1 (i.e, cmd =AS4x where x is 0-7, do =2 92 ; for each input used as freq or pulse ctr). =2 93 ; =2 94 ; 921014-1.05 Fifth Revision =2 95 ; Add station ID to Fast Upload Response =2 96 ; Provide response to =AED command (-A- OK) =2 97 ; Provide 20 Hz signal on T1 output for test purposes =2 98 ; Allow user to select value of UART D7 output =2 99 ; Move major system flags one byte lower in memory map =2 100 ; =2 101 ; 921031-1.06 Sixth Revision =2 102 ; Change Date (no other code chages since 1.05) =2 103 ; Change release notes regarding non-support of BIT SET/CLEAR/DISPLAY =2 104 ; =2 105 ; 930117-1.07 Seventh Revision =2 106 ; Correct Number of Bytes sent for FLU0 and FLU1 =2 107 ; Added new flag bit, AFLU, (Badr 003) to select =AFLU0 as =2 108 ; as alternative to =AM for auto display timeout =2 109 ; =2 110 ; 990311-2.00t METCON-2 Test Code =2 111 ; - normally inputs are not inverted and output is inverted =2 112 ; - sysadm input on B7 is active low regardless of input =2 113 ; inversion flag =2 114 ; - default baud rate temporarily changed to 9600 baud =2 115 ; - corrected number of bytes to store in EEPROM from 18 to 17 =2 116 ; - SYSADM when active internally causes DCD flag to be active MC2LDEV MC-2 Development 990419-2.00v PAGE 3 =2 117 ; regardless of hardware state of DCD =2 118 ; - DCD required to be active except for when SYSADM is active =2 119 ; =2 120 ; 990419-2.00v METCON-2 Test Code =2 121 ; - correct problem with ADC not shifting enough bits =2 122 ; - correct max allowable read address =2 123 ; - correct word write to ADC memory =2 124 ; - correct MAP mneumonic for ADC address =2 125 ; =2 126 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 127 ; Features that should be added before next release =2 128 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 129 ; =2 130 ; - Need to correct EEPROM error reporting =2 131 =2 132 =2 133 $INCLUDE(EQU.ASM) ; include defines and equates =2 134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 135 ; +++ EQU.ASM =2 136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 137 =2 138 =2 139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 140 ; Global Constants =2 141 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 142 =2 143 ; configuration dependent stuff 00B0 =2 144 STKBAS EQU 00B0H ; first location used for stack =2 145 =2 146 IF (DEV) ; if development 8800 =2 147 PGMBAS EQU 08800H ; start of program memory EFFD =2 148 VIE0 EQU 0EFFDH ; pt to monitor vector for ext int 0 EFFA =2 149 VTF0 EQU 0EFFAH ; pt to monitor vector for timer 0 EFF7 =2 150 VIE1 EQU 0EFF7H ; pt to monitor vector for ext int 1 EFF4 =2 151 VTF1 EQU 0EFF4H ; pt to monitor vector for timer 1 EFF1 =2 152 VRITI EQU 0EFF1H ; pt to monitor vector for RX and TX UART =2 153 ELSE ; must be finished ROMed code =2 154 PGMBAS EQU 00000H ; start of code space =2 155 ENDIF =2 156 =2 157 ; additional system defines 0000 =2 158 RB0 EQU 000H ; value for MOV PSW,RXn to set to RB0 0008 =2 159 RB1 EQU 008H ; value for MOV PSW,RXn to set to RB1 0010 =2 160 RB2 EQU 010H ; value for MOV PSW,RXn to set to RB2 0018 =2 161 RB3 EQU 018H ; value for MOV PSW,RXn to set to RB3 =2 162 =2 163 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 164 ; I2C Address Assignments =2 165 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 0040 =2 166 I2CEXP EQU 040H ; Slave address for PCF8574 I/O expandor 0048 =2 167 I2CTON EQU 048H ; Slave address for PCF3311/3312 tone generator 0090 =2 168 I2CADC EQU 090H ; Slave address for PCF8591 ADC Converter 00A4 =2 169 I2CEEP EQU 0A0H+4 ; Slave address for PCF8581/82 EEPROM 00A0 =2 170 I2CCLK EQU 0A0H ; Slave address for PCF8583 Clock Calendar =2 171 =2 172 =2 173 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 174 ; P1, Port Bit Assignments MC2LDEV MC-2 Development 990419-2.00v PAGE 4 =2 175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 176 =2 177 ; Port 1 Equivalents 0090 =2 178 MUX0 EQU P1.0 ; freq counter mux A0 0091 =2 179 MUX1 EQU P1.1 ; freq counter mux A1 0092 =2 180 MUX2 EQU P1.2 ; freq counter mux A2 0093 =2 181 WDT EQU P1.3 ; watch dog timer input 0094 =2 182 XCLK EQU P1.4 ; external clock 0095 =2 183 XDOT EQU P1.5 ; external data output 0096 =2 184 I2CLK EQU P1.6 ; I2C serial clock line. 0097 =2 185 I2DAT EQU P1.7 ; I2C serial data line. =2 186 =2 187 =2 188 ; Port 3 Equivalents 00B0 =2 189 QRXD EQU P3.0 ; (RXD) data from console 00B1 =2 190 QTXD EQU P3.1 ; (TXD) data to console 00B2 =2 191 QINT0 EQU P3.2 ; (INT0*) RTC interrupt 00B3 =2 192 XOST EQU P3.3 ; (INT1*) XOST* (xternal output strobe) 00B4 =2 193 ADI EQU P3.4 ; (T0) ADC input 00B5 =2 194 FCTR EQU P3.5 ; (T1) FCTR input 00B6 =2 195 QRD EQU P3.6 ; sys read 00B7 =2 196 QWR EQU P3.7 ; sys write =2 197 =2 198 =2 199 ; IC13 (1st) 82c55 address assignments F8FC =2 200 PP1BAS EQU 0F8FCH ; 1st 82c55 base address F8FC =2 201 PP1A EQU PP1BAS+0 ; 1st 82c55 port A address F8FD =2 202 PP1B EQU PP1BAS+1 ; 1st 82c55 port B address F8FE =2 203 PP1C EQU PP1BAS+2 ; 1st 82c55 port C address F8FF =2 204 PP1T EQU PP1BAS+3 ; 1st 82c55 port CONTROL address =2 205 =2 206 =2 207 ; IC15 (2nd) 82c55 address assignments F8FC =2 208 PP2BAS EQU 0F8FCH ; 2nd 82c55 base address F8FC =2 209 PP2A EQU PP2BAS+0 ; 2nd 82c55 port A address F8FD =2 210 PP2B EQU PP2BAS+1 ; 2nd 82c55 port B address F8FE =2 211 PP2C EQU PP2BAS+2 ; 2nd 82c55 port C address F8FF =2 212 PP2T EQU PP2BAS+3 ; 2nd 82c55 port CONTROL address =2 213 =2 214 ;DCD EQU P5.7 ; 0 for DCD active, com device OK if zero =2 215 ;DTR EQU P5.6 ; 0 for DTR active, METCON1 OK if zero =2 216 ;;;; not used in METCON-2 SYSASW EQU P3.2 ; 0 for sysadmin =2 217 =2 218 ; character constants 000A =2 219 ALF EQU 00AH ; ASCII LF char 000D =2 220 ACR EQU 00DH ; ASCII CR char 0020 =2 221 ASP EQU ' ' ; ASCII SPACE char 0003 =2 222 ACTLC EQU 003H ; ASCII CONTROL C 0008 =2 223 ABSP EQU 008H ; ASCII BACK-SPACE char 0009 =2 224 ATAB EQU 009H ; ASCII TAB char 001B =2 225 AESC EQU 01BH ; ASCII ESCAPE char 007F =2 226 ADEL EQU 07FH ; ASCII DELETE char 0000 =2 227 ANULL EQU 000H ; ASCII NULL char 005F =2 228 AERR EQU '_' ; ASCII ERROR char 0027 =2 229 AAPOS EQU 027H ; ASCII APOSTROPHY 0007 =2 230 ABELL EQU 007H ; ASCII BELL 003D =2 231 CMDMRK EQU '=' ; Command marker character =2 232 MC2LDEV MC-2 Development 990419-2.00v PAGE 5 =2 233 ;;;;;;;;; =2 234 ; Maxes and other limits =2 235 ;;;;;;;;; =2 236 0007 =2 237 MXRADR EQU 007H ; maximum permissable restricted memory address 0032 =2 238 MXOADR EQU 032H ; maximum permissable open memory address 003C =2 239 LITIME EQU 60 ; 60 seconds to login 0004 =2 240 LITRY EQU 4 ; 4 tries to login =2 241 =2 242 ;;;;;;;;; =2 243 ; RAM assignments =2 244 ; =2 245 ; RB0 uses 00-07, main line processing =2 246 ; RB1 uses 08, 09, 0A for interrupt processing =2 247 ; 0B-0F available if not needed for interrupt stuff =2 248 ; 10-1F available =2 249 ; 20-2F available for bit assignments =2 250 ; 30-5F available for assignment =2 251 ; 68-7F assigned to stack =2 252 ;;;;;;;;; =2 253 =2 254 ;;;;;;;;; =2 255 ; RAM assignments, 08-0F (RB1) =2 256 ;;;;;;;;; =2 257 ; used only for interrupts =2 258 ;RB1-R0 EQU 008H ; (08) RB1 R0 =2 259 ;RB1-R1 EQU 009H ; (09) RB1 R1 =2 260 ;RB1-R2 EQU 00AH ; (0A) RB1 R2 =2 261 ;RB1-R3 EQU 00BH ; (0B) RB1 R3 =2 262 =2 263 ; line input memory 000C =2 264 LBUFC EQU 00CH ; (0C) line buffer counter 000D =2 265 LBUFP EQU 00DH ; (0D) line buffer pointer 000E =2 266 LBUF EQU 00EH ; (0E-19) line buffer 000C =2 267 LBUFSZ EQU 12 ; 12 locations in line buffer =2 268 =2 269 ; interrupt memory locations 001A =2 270 TCTR EQU 01AH ; clock tic counter (36 tics per 10 mS) 001B =2 271 MS10CTR EQU 01BH ; 10 ms counter for interrupts 001C =2 272 ISEC EQU 01CH ; 1 second counter for interrupts 001D =2 273 TL0OVF EQU 01DH ; TL0 overflow counter for MSB 001E =2 274 CTRCHAN EQU 01EH ; current counter channel being timed 001F =2 275 ADCHAN EQU 01FH ; current A/D channel being measured =2 276 =2 277 ;;;;;;;;; =2 278 ; RAM assignments, Flags, 20-2F =2 279 ;;;;;;;;; =2 280 =2 281 ; flags starting at or above 020H go here 0020 =2 282 SF0 EQU 020H ; address for system flags 0 0000 =2 283 TMPB0 EQU SF0.0 ; flag for temp 0001 =2 284 TMPB1 EQU SF0.1 ; flag for temp 0002 =2 285 NCSEC EQU SF0.2 ; flag for new clock second 0003 =2 286 WUDIO EQU SF0.3 ; flag for update I/O wanted 0004 =2 287 DAMAP EQU SF0.4 ; do auto map 0005 =2 288 LGISTAT EQU SF0.5 ; SET if LOGGED IN 0006 =2 289 SYSADMN EQU SF0.6 ; SET if SYSTEM ADMINISTRATOR 0007 =2 290 WDTFLG EQU SF0.7 ; SET if watch dog timer should toggle MC2LDEV MC-2 Development 990419-2.00v PAGE 6 =2 291 0021 =2 292 SF1 EQU 021H ; address for system flags 1 000B =2 293 I2CIP EQU SF1.3 ; I2C flag, Transfer in Progress 000C =2 294 I2CUCW EQU SF1.4 ; I2C flag, Use Control Word 000D =2 295 I2CFLT EQU SF1.5 ; I2C flag, Bus Fault Detected 000E =2 296 I2CNACK EQU SF1.6 ; I2C flag, No Acknowledge Found 000F =2 297 I2CX EQU SF1.7 ; I2C flag, problem of some sort =2 298 0022 =2 299 SF2 EQU 022H ; address for system flags 2 (82c55 port C) 0010 =2 300 DTR EQU SF2.0 ; Serial port DTR output image 0011 =2 301 RTS EQU SF2.1 ; Serial port RTS output image 0012 =2 302 XDCD EQU SF2.2 ; Serial port TXDCD output image 0013 =2 303 ADCSN EQU SF2.3 ; Exp port ADC/CS* output image 0014 =2 304 DCD EQU SF2.4 ; Serial port DCD input image 0015 =2 305 CTSRI EQU SF2.5 ; Serial port CTS/RI input image 0016 =2 306 DSR EQU SF2.6 ; Serial port DSR input image 0017 =2 307 EXPIN EQU SF2.7 ; Exp port Bit input =2 308 =2 309 ;;;; not used in METCON-2 SYSASW EQU SF2.3 ; system admin input =2 310 ;;;ADCK EQU SF2.4 ; ADC clock =2 311 ;;;ADCE EQU SF2.5 ; ADC Chip enable =2 312 ;;;ADDO EQU SF2.6 ; ADC data output =2 313 ;;ADDI EQU SF2.7 ; ADC data input =2 314 =2 315 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 316 ; Non-Volitile Memory Stuff =2 317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 318 0011 =2 319 NVRAML EQU 17 ; # of bytes to be saved 0011 =2 320 NVCHKL EQU 17 ; # of bytes to be checked (incl NVRAM) 002C =2 321 RIDX EQU 02CH ; reference index for user memory =2 322 =2 323 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 324 ; Restricted User Memory =2 325 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 0024 =2 326 NVRAM EQU RIDX-008H ; (24) start and checksum for EEPROM =2 327 0025 =2 328 RSTAT0 EQU RIDX-007H ; (25) restricted status0 0028 =2 329 SPS0 EQU RSTAT0.0 ; serial port speed 0 0029 =2 330 SPS1 EQU RSTAT0.1 ; serial port speed 1 002A =2 331 SPS2 EQU RSTAT0.2 ; serial port speed 1 002B =2 332 AONLI EQU RSTAT0.3 ; Auto Output when Not Logged In 002C =2 333 ADIS EQU RSTAT0.4 ; Auto DISCONNECT wanted when SET 002D =2 334 NECHO EQU RSTAT0.5 ; no echo of input data when set 002E =2 335 NLF EQU RSTAT0.6 ; no line feeds when set =2 336 0026 =2 337 RSTAT1 EQU RIDX-006H ; (26) restricted status0 0030 =2 338 INVI EQU RSTAT1.0 ; invert standard input 0031 =2 339 NINVO EQU RSTAT1.1 ; no invert output =2 340 ;;;UARTD7 EQU RSTAT1.0 ; UARTD7 value =2 341 0027 =2 342 ACHGMSK EQU RIDX-005H ; (27) change flags for each input =2 343 0028 =2 344 PSWD0 EQU RIDX-004H ; (28) password 0029 =2 345 PSWD1 EQU RIDX-003H ; (29) password 002A =2 346 PSWD2 EQU RIDX-002H ; (2A) password =2 347 002B =2 348 STNADR EQU RIDX-001H ; (2B) station address MC2LDEV MC-2 Development 990419-2.00v PAGE 7 =2 349 =2 350 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 351 ; Open User Memory =2 352 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 353 002C =2 354 OSTAT0 EQU RIDX+000H ; (2C) open memory status0 0060 =2 355 AD1 EQU OSTAT0.0 ; auto display every 1 minute 0061 =2 356 AD15 EQU OSTAT0.1 ; auto display every 15 minutes 0062 =2 357 FSR EQU OSTAT0.2 ; fast (100 mS) sample update rate 0063 =2 358 AFLU EQU OSTAT0.3 ; Auto-Display is Fast Load Up (all) =2 359 002D =2 360 PULFLG EQU RIDX+001H ; (2D) pulse flag (1=pulse ctr, 0=freq ctr) 0068 =2 361 PULCTR0 EQU PULFLG.0 ; pulse counter flag 0 0069 =2 362 PULCTR1 EQU PULFLG.1 ; pulse counter flag 1 006A =2 363 PULCTR2 EQU PULFLG.2 ; pulse counter flag 2 006B =2 364 PULCTR3 EQU PULFLG.3 ; pulse counter flag 3 006C =2 365 PULCTR4 EQU PULFLG.4 ; pulse counter flag 4 006D =2 366 PULCTR5 EQU PULFLG.5 ; pulse counter flag 5 006E =2 367 PULCTR6 EQU PULFLG.6 ; pulse counter flag 6 006F =2 368 PULCTR7 EQU PULFLG.7 ; pulse counter flag 7 =2 369 002E =2 370 ADCTYP EQU RIDX+002H ; (2E) A/D configuration type =2 371 002F =2 372 ADCFLG EQU RIDX+003H ; (2F) A/D configuration flags 0078 =2 373 ADC01B EQU ADCFLG.0 ; chan 0/1 balanced 0079 =2 374 ADC01R EQU ADCFLG.1 ; chan 0/1 reversed when balanced 0078 =2 375 ADC23B EQU ADCFLG.0 ; chan 2/3 balanced 0079 =2 376 ADC23R EQU ADCFLG.1 ; chan 2/3 reversed when balanced 0078 =2 377 ADC45B EQU ADCFLG.0 ; chan 4/5 balanced 0079 =2 378 ADC45R EQU ADCFLG.1 ; chan 4/5 reversed when balanced 0078 =2 379 ADC67B EQU ADCFLG.0 ; chan 6/7 balanced 0079 =2 380 ADC67R EQU ADCFLG.1 ; chan 6/7 reversed when balanced =2 381 =2 382 ; port tx (output) images 0030 =2 383 PT0IMG EQU RIDX+004H ; (30) port tx 0 image 0031 =2 384 PT1IMG EQU RIDX+005H ; (31) port tx 1 image 0032 =2 385 PT2IMG EQU RIDX+006H ; (32) port tx 2 image 0033 =2 386 PT3IMG EQU RIDX+007H ; (33) port tx 3 image 0034 =2 387 PT4IMG EQU RIDX+008H ; (34) port tx 4 image =2 388 =2 389 ; port rx (input) images 0035 =2 390 PR0IMG EQU RIDX+009H ; (35) port rx 0 image 0036 =2 391 PR1IMG EQU RIDX+00AH ; (36) port rx 1 image 0037 =2 392 PR2IMG EQU RIDX+00BH ; (37) port rx 2 image 0038 =2 393 PR3IMG EQU RIDX+00CH ; (38) port rx 3 image 0039 =2 394 PR4IMG EQU RIDX+00DH ; (39) port rx 4 image =2 395 =2 396 ; port rx (input) changed images 003A =2 397 PR0CIMG EQU RIDX+00EH ; (3A) port rx 0 input change image 003B =2 398 PR1CIMG EQU RIDX+00FH ; (3B) port rx 1 input change image 003C =2 399 PR2CIMG EQU RIDX+010H ; (3C) port rx 2 input change image 003D =2 400 PR3CIMG EQU RIDX+011H ; (3D) port rx 3 input change image 003E =2 401 PR4CIMG EQU RIDX+012H ; (3E) port rx 4 input change image =2 402 =2 403 ; Counter Channel Inputs 003F =2 404 CCHAN0 EQU RIDX+013H ; (3F) LSBy of counter channel 0 0041 =2 405 CCHAN1 EQU RIDX+015H ; (41) LSBy of counter channel 1 0043 =2 406 CCHAN2 EQU RIDX+017H ; (43) LSBy of counter channel 2 MC2LDEV MC-2 Development 990419-2.00v PAGE 8 0045 =2 407 CCHAN3 EQU RIDX+019H ; (45) LSBy of counter channel 3 0047 =2 408 CCHAN4 EQU RIDX+01BH ; (47) LSBy of counter channel 4 0049 =2 409 CCHAN5 EQU RIDX+01DH ; (49) LSBy of counter channel 5 004B =2 410 CCHAN6 EQU RIDX+01FH ; (4B) LSBy of counter channel 6 004D =2 411 CCHAN7 EQU RIDX+021H ; (4D) LSBy of counter channel 7 =2 412 =2 413 ; A/D Inputs 004F =2 414 ADCH0 EQU RIDX+023H ; (4F) A/D LSBy Channel 0 0051 =2 415 ADCH1 EQU RIDX+025H ; (51) A/D LSBy Channel 1 0053 =2 416 ADCH2 EQU RIDX+027H ; (53) A/D LSBy Channel 2 0055 =2 417 ADCH3 EQU RIDX+029H ; (55) A/D LSBy Channel 3 0057 =2 418 ADCH4 EQU RIDX+02BH ; (57) A/D LSBy Channel 4 0059 =2 419 ADCH5 EQU RIDX+02DH ; (59) A/D LSBy Channel 5 005B =2 420 ADCH6 EQU RIDX+02FH ; (5B) A/D LSBy Channel 6 005D =2 421 ADCH7 EQU RIDX+031H ; (5D) A/D LSBy Channel 7 =2 422 =2 423 ; bit input last data input images, used for change flags 005F =2 424 LDPR0 EQU RIDX+033H ; (5F) last data port RX 0 0060 =2 425 LDPR1 EQU RIDX+034H ; (60) last data port RX 1 0061 =2 426 LDPR2 EQU RIDX+035H ; (61) last data port RX 2 0062 =2 427 LDPR3 EQU RIDX+036H ; (62) last data port RX 3 0063 =2 428 LDPR4 EQU RIDX+037H ; (63) last data port RX 3 =2 429 0064 =2 430 RN0 EQU RIDX+038H ; (64) random number memory 0065 =2 431 RN1 EQU RIDX+039H ; (65) random number memory 0066 =2 432 RN2 EQU RIDX+03AH ; (66) random number memory =2 433 0067 =2 434 CH0 EQU RIDX+03BH ; (67) challenge memory 0068 =2 435 CH1 EQU RIDX+03CH ; (68) challenge memory 0069 =2 436 CH2 EQU RIDX+03DH ; (69) challenge memory` =2 437 =2 438 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 439 ; RAM assignments for Time-Of-Day Clock =2 440 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 441 =2 442 ;CYEAR EQU RIDX+036H ; (6A) PBCD years =2 443 ;CMON EQU RIDX+037H ; (6B) PBCD months =2 444 ;CDAY EQU RIDX+038H ; (6C) PBCD days =2 445 ;CHOUR EQU RIDX+039H ; (6D) PBCD hours =2 446 ;CMIN EQU RIDX+03AH ; (6E) PBCD minutes =2 447 ;CSEC EQU RIDX+03BH ; (6F) PBCD seconds =2 448 ;CDOW EQU RIDX+03CH ; (70) day of week =2 449 006A =2 450 DCDSEC EQU RIDX+03EH ; (6A) DCD Seconds counter, autologout 006B =2 451 DCDTRY EQU RIDX+03FH ; (6B) DCD Try counter, autologout 006C =2 452 PULOLD EQU RIDX+040H ; (6C) last PUL COUNT sample input =2 453 0070 =2 454 CLKBUF EQU RIDX+044H ; (70-90) clock read/write buffer =2 455 =2 456 $INCLUDE(LOWMEM.ASM) ; ram, strings and tables =2 457 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 458 ; +++ LOWMEM.ASM =2 459 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 460 =2 461 8800 =2 462 ORG PGMBAS ; start of program =2 463 8800 0288A6 =2 464 NULL: LJMP START ; skip all the vector stuff MC2LDEV MC-2 Development 990419-2.00v PAGE 9 =2 465 =2 466 ; set up any interrupt jumps that might be needed =2 467 IF (DEV) ; if development then vector to RAM =2 468 ELSE ; if not development then vector direct =2 469 IE0INT: ; vector to IE0 interrupt routine =2 470 DB 0,0,0,0,0,0,0,0 ; reserve space up to 000BH =2 471 TF0INT: ; vector to TF0 interrupt routine =2 472 DB 0,0,0,0,0,0,0,0 ; reserve space up to 0013H =2 473 IE1INT: ; vector to IE1 interrupt routine =2 474 DB 0,0,0,0,0,0,0,0 ; reserve space up to 001BH =2 475 TF1INT: LJMP INTRPT ; vector to interrupt routine =2 476 DB 0,0,0,0,0 ; reserve space up to 0023H =2 477 RITIINT: ; vector to IE1 interrupt routine =2 478 ENDIF =2 479 8803 =2 480 CPYRIT: ; copyright 8803 =2 481 VERMSG: ; version message 8803 =2 482 SIGNMSG: 8803 0D0A0D0A =2 483 DB ACR,ALF,ACR,ALF 8807 4D432D32 =2 484 DB 'MC-2 990419-2.00v ' 880B 20393930 880F 3431392D 8813 322E3030 8817 76202020 881B 20 =2 485 IF (DEV) ; if development 881C 202A2A2A =2 486 DB ' *** DEVELOPEMENT *** ' 8820 20444556 8824 454C4F50 8828 454D454E 882C 54202A2A 8830 2A2020 =2 487 ELSE ; must be finished ROMed code =2 488 ENDIF 8833 0D0A =2 489 DB ACR,ALF 8835 4D455443 =2 490 DB 'METCON-2 990419-2.00v Copyright (c) ' 8839 4F4E2D32 883D 20393930 8841 3431392D 8845 322E3030 8849 76202020 884D 436F7079 8851 72696768 8855 74202863 8859 2920 885B 5061756C =2 491 DB 'Paul Newland, P.E. 1992-1999. ' 885F 204E6577 8863 6C616E64 8867 2C20502E 886B 452E2020 886F 31393932 8873 2D313939 8877 392E2020 887B 416C6C20 =2 492 DB 'All Rights Reserved' 887F 52696768 8883 74732052 8887 65736572 888B 766564 MC2LDEV MC-2 Development 990419-2.00v PAGE 10 888E 0D0A00 =2 493 DB ACR,ALF,ANULL 8891 20202020 =2 494 DB ' '; padding space, null ends 8895 20202020 8899 20202020 889D 20202020 88A1 20202020 88A5 00 =2 495 DB ANULL =2 496 =2 497 88A6 =2 498 START: ; first, ensure int's are off and desired RB is selected 88A6 C2AF =2 499 CLR EA ; ensure no interrupts at this point 88A8 75D000 =2 500 MOV PSW,#RB0 ; select default register bank =2 501 =2 502 ; next, clear out the ram aread =2 503 ;;;;;;; MOV R0,#127 ; pt to top ram location (8051) 88AB 78FF =2 504 MOV R0,#255 ; pt to top ram location (8052) 88AD 7600 =2 505 STAR10: MOV @R0,#0 ; fill with zero 88AF D8FC =2 506 DJNZ R0,STAR10 ; decrement pointer and do again till 0 =2 507 =2 508 ; next, set up monitor vectors for interrupts =2 509 IF (DEV) ; if development then vector to RAM 88B1 90EFFA =2 510 MOV DPTR,#VTF0 ; pt to monitor vector for timer 0 88B4 7402 =2 511 MOV A,#002H ; get long jump op code 88B6 F0 =2 512 MOVX @DPTR,A ; move to ram 88B7 A3 =2 513 INC DPTR ; pt to next byte 88B8 7491 =2 514 MOV A,#HIGH INTRPT ; get high byte of address 88BA F0 =2 515 MOVX @DPTR,A ; move to ram 88BB A3 =2 516 INC DPTR ; pt to next byte 88BC 7425 =2 517 MOV A,#LOW INTRPT ; get low byte of address 88BE F0 =2 518 MOVX @DPTR,A ; move to ram =2 519 ENDIF =2 520 88BF C2AF =2 521 CLR EA ; ensure no interrupts at this point 88C1 75D000 =2 522 MOV PSW,#RB0 ; select default register bank 88C4 7581AF =2 523 MOV SP,#STKBAS-1 ; initial stack position 88C7 1291D8 =2 524 CALL INITTI ; initialize timers & interrupt regs 88CA 1291EE =2 525 CALL INITPP ; init the parallel ports 88CD 1291FB =2 526 CALL INITSP ; init the serial port 88D0 1297D5 =2 527 CALL INITMEM ; initialize any memory locations needed 88D3 129349 =2 528 CALL ILBUF ; init the line buffer values =2 529 88D6 C200 =2 530 CLR TMPB0 ; clear temp bit 0 88D8 C201 =2 531 CLR TMPB1 ; clear temp bit 1 =2 532 ;; CALL EEWDIS ; EEPROM write DISABLE after powerup 88DA 12892C =2 533 CALL EERDBK ; read in block of data 88DD 9200 =2 534 MOV TMPB0,C ; save status in TMP 0 88DF 128A38 =2 535 CALL RAMV ; see if RAM is valid 88E2 9201 =2 536 MOV TMPB1,C ; save status in TMP 0 88E4 8200 =2 537 ANL C,TMPB0 ; and in prior value 88E6 4003 =2 538 JC STAR20 ; jump if both were OK (high) 88E8 128A4A =2 539 CALL DEFAULT ; else, load in default values 88EB =2 540 STAR20: 88EB 12964B =2 541 CALL SSPEED ; ensure correct baudrate selected =2 542 ;;;;;; CALL INITI ; init interrupt structure and let it rip 88EE D2AF =2 543 SETB EA ; enable the interrupts 88F0 129714 =2 544 CALL SIGNON ; print the signon message 88F3 200003 =2 545 JB TMPB0,STAR30 ; jump if EEPROM I2C was OK 88F6 1298D5 =2 546 CALL EEPTERR ; else, print transfer error MC2LDEV MC-2 Development 990419-2.00v PAGE 11 88F9 200103 =2 547 STAR30: JB TMPB1,STAR40 ; jump if EEPROM data was OK 88FC 1298FE =2 548 CALL EEPDERR ; else, print data error 88FF 0295BC =2 549 STAR40: JMP MAIN ; do the main stuff, don't come back here =2 550 =2 551 =2 552 $INCLUDE(EEPROM.ASM) ; EEPROM processing, put first for ACALL pblm =2 553 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 554 ; +++ EEPROM.ASM =2 555 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 556 =2 557 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 558 ; I2C EEPROM CODE =2 559 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 560 =2 561 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 562 ; EEREAD -- Read from EEPROM =2 563 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 564 ; 8902 =2 565 EEREAD: 8902 C0A8 =2 566 PUSH IE ; save IE regsiter on stack 8904 C2AF =2 567 CLR EA ; disable all ints during EEPROM read 8906 312C =2 568 ACALL EERDBK ; read in block of data 8908 D0A8 =2 569 POP IE ; restore EA value from stack 890A 300F03 =2 570 JNB I2CX,EEREA10 ; jump if no I2C problem 890D 0298D5 =2 571 JMP EEPTERR ; jump to EEPROM transfer failure message 8910 =2 572 EEREA10: 8910 5138 =2 573 ACALL RAMV ; see if RAM is valid 8912 4006 =2 574 JC EEREA20 ; jump if data valid 8914 128A4A =2 575 CALL DEFAULT ; bad read, get defaults 8917 0298FE =2 576 JMP EEPDERR ; jump to EEPROM transfer failure message 891A =2 577 EEREA20: 891A 22 =2 578 RET =2 579 =2 580 =2 581 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 582 ; EEWRITE -- Write to EEPROM =2 583 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 584 ; 891B =2 585 EEWRITE: 891B 5133 =2 586 ACALL VALRAM ; make cksum correct 891D C0A8 =2 587 PUSH IE ; save IE register on stack 891F C2AF =2 588 CLR EA ; disable all ints during EEPROM write 8921 =2 589 EEWRI10: 8921 3150 =2 590 ACALL EEWRBK ; do write command 8923 D0A8 =2 591 POP IE ; restore EA value from stack 8925 A20F =2 592 MOV C,I2CX ; get I2C gen error flag 8927 129F6E =2 593 CALL CDUMP ;+++ show result 892A 2102 =2 594 AJMP EEREAD ; and do read with test =2 595 =2 596 IF (I2CBB) ; if bit banged I2C =2 597 =2 598 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 599 ; EERDBK - EEPROM Read Block =2 600 ; entry: none =2 601 ; exit: read block of bytes from EEprom to NVRAM =2 602 ; set CY if all OK, clear CY if problem =2 603 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 604 ; MC2LDEV MC-2 Development 990419-2.00v PAGE 12 892C =2 605 EERDBK: 892C 7CA4 =2 606 MOV R4,#I2CEEP ; slave write address of EEPROM 892E 7D10 =2 607 MOV R5,#010H ; start with location 10 (control word) 8930 7E11 =2 608 MOV R6,#NVRAML ; get number of bytes to move 8932 7824 =2 609 MOV R0,#NVRAM ; pt to NV ram space 8934 C20D =2 610 CLR I2CFLT ; no I2C Bus Fault Detected yet 8936 C20E =2 611 CLR I2CNACK ; no I2C No Acknowledge yet 8938 D20C =2 612 SETB I2CUCW ; I2C Use Control Word (R5) 893A 31B5 =2 613 ACALL I2SCW ; I2C send address and control 893C 200F0D =2 614 JB I2CX,EERDB10 ; jump if I2C problem 893F C20C =2 615 CLR I2CUCW ; do NOT use control word (R5) 8941 0C =2 616 INC R4 ; pt to read slave address 8942 3192 =2 617 ACALL I2RSTR ; I2C receive string from device 8944 200D05 =2 618 JB I2CFLT,EERDB10 ; jump if there was a bus fault 8947 200E02 =2 619 JB I2CNACK,EERDB10 ; jump if missing ack 894A D3 =2 620 SETB C ; mark good 894B 22 =2 621 RET ; and exit 894C =2 622 EERDB10: 894C D20F =2 623 SETB I2CX ; mark bad 894E C3 =2 624 CLR C ; mark bad 894F 22 =2 625 RET =2 626 =2 627 =2 628 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 629 ; EEWRBK - EEPROM Write Block =2 630 ; entry: none =2 631 ; exit: write block of bytes to EEprom =2 632 ; exit: ADR in R3, DATL in R4, DATH in R5 =2 633 ; mod: A, R0, R2, R3, R4, R5, R6, R7 =2 634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 635 ; 8950 =2 636 EEWRBK: ; EEPROM Write Block 8950 7824 =2 637 MOV R0,#NVRAM ; pt to NV ram space 8952 7CA4 =2 638 MOV R4,#I2CEEP ; address of EEPROM 8954 7D10 =2 639 MOV R5,#010H ; start with location 10 (eeprom addr) 8956 7A11 =2 640 MOV R2,#NVRAML ; get number of bytes to write 8958 =2 641 EEWRB10: 8958 3164 =2 642 ACALL EEWR ; write a byte 895A 5004 =2 643 JNC EEWRB20 ; jump if error found 895C 0D =2 644 INC R5 ; advance eeprom address 895D DAF9 =2 645 DJNZ R2,EEWRB10 ; do till done 895F D3 =2 646 SETB C ; ensure CY is set (good write) 8960 =2 647 EEWRB20: 8960 D20F =2 648 SETB I2CX ; mark bad 8962 C3 =2 649 CLR C ; mark bad 8963 22 =2 650 RET =2 651 =2 652 =2 653 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 654 ; EEWR - EEPROM write code for 1 byte =2 655 ; entry: R3 is address, R4 is data low, R5 is data high =2 656 ; exit: write 2 bytes to EEprom =2 657 ; mod: A, R6, R7 =2 658 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 659 ; 8964 C20D =2 660 EEWR: CLR I2CFLT ; no I2C Bus Fault Detected yet 8966 C20E =2 661 CLR I2CNACK ; no I2C No Acknowledge yet 8968 D20C =2 662 SETB I2CUCW ; I2C Use Control Word (R5) MC2LDEV MC-2 Development 990419-2.00v PAGE 13 896A 7CA4 =2 663 MOV R4,#I2CEEP ; PCF8582 EEPROM 896C 7E01 =2 664 MOV R6,#1 ; send 1 data byte 896E 31A2 =2 665 ACALL I2TSTR ; I2C transmit string to device 8970 200D06 =2 666 JB I2CFLT,EEWR10 ; jump if fault 8973 200E03 =2 667 JB I2CNACK,EEWR10 ; jump if missing ack 8976 D3 =2 668 SETB C ; mark good 8977 217C =2 669 AJMP EEWR20 ; skip 8979 C3 =2 670 EEWR10: CLR C ; mark bad 897A D20F =2 671 SETB I2CX ; mark bad 897C C0D0 =2 672 EEWR20: PUSH PSW ; save C on stack 897E 3186 =2 673 ACALL W60MS ; wait for 60 milliseconds 8980 D0D0 =2 674 POP PSW ; restore C from stack 8982 22 =2 675 RET =2 676 =2 677 =2 678 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 679 ; W2US - Wait 2 uS for EEPROM timing =2 680 ; entry: none =2 681 ; exit: delay accomplished =2 682 ; mod: none =2 683 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 684 ; 8983 00 =2 685 W2US: NOP ; 2 NOPs is plenty, overhead of CALL 8984 00 =2 686 NOP ; is really all that's needed 8985 22 =2 687 RET =2 688 =2 689 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 690 ; W60MS - Wait 60 ms for EEPROM timing =2 691 ; entry: none =2 692 ; exit: none, delayed 60 ms =2 693 ; mod: R6, R7; both set to zero =2 694 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 695 ; 8986 =2 696 W60MS: ; wait 60 milli-seconds for program delay, at 11.0952 MHz clock =2 697 ; entry: none =2 698 ; exit: delay accomplished =2 699 ; mod: R6, R7 8986 128989 =2 700 CALL W30MS ; do it once, then fall through 8989 =2 701 W30MS: ; wait 30 milli-seconds for program delay, at 11.0952 MHz clock 8989 7E36 =2 702 MOV R6,#54 ; do 54 outer loops 898B 7F00 =2 703 W30M10: MOV R7,#0 ; do 256 inner loops 898D DFFE =2 704 W30M20: DJNZ R7,W30M20 ; inner loop (2.17 uS per lap) 898F DEFA =2 705 DJNZ R6,W30M10 ; outer loop (558.81 uS per lap) 8991 22 =2 706 RET =2 707 =2 708 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 709 ; I2C Read/Write Functions =2 710 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 711 ; =2 712 ; Note that R1, R2 and R3 are not used by I2C routines =2 713 ; also, I2C status flags can bit in any bit addressable =2 714 ; flag -- B reg is usually used but it can be anywhere =2 715 ; =2 716 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 717 =2 718 =2 719 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 720 ; I2RSTR - I2C Receive String from I2C device MC2LDEV MC-2 Development 990419-2.00v PAGE 14 =2 721 ; entry =2 722 ; R0 - Buffer Pointer to Internal Ram =2 723 ; R4 - I2C Address of Device =2 724 ; R5 - I2C Control Word (optional) =2 725 ; R6 - Data Byte Count (excluding address) =2 726 ; I2CUCW - I2C Use Control Word =2 727 ; exit =2 728 ; Internal Ram written =2 729 ; I2CFLT - I2C Bus Fault Detected =2 730 ; I2CNACK - I2C NACK =2 731 ; I2CIP - I2C transfer in Progress =2 732 ; modified =2 733 ; R0 - Buffer Pointer to Internal Ram =2 734 ; R6 - Data Byte Count =2 735 ; R7 - Bit Counter =2 736 ; ACC - Used for GP stuff =2 737 ; =2 738 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 739 ; 8992 31BA =2 740 I2RSTR: ACALL I2STAR ; send start and address 8994 200E06 =2 741 JB I2CNACK,I2RS20 ; jump if no ack 8997 31DC =2 742 I2RS10: ACALL I2RBYT ; get a byte from I2C device 8999 F6 =2 743 MOV @R0,A ; save to ram 899A 08 =2 744 INC R0 ; increment address pointer 899B DEFA =2 745 DJNZ R6,I2RS10 ; loop till done 899D 5110 =2 746 I2RS20: ACALL I2STOP ; stop the transfer 899F D20F =2 747 SETB I2CX ; mark bad 89A1 22 =2 748 RET =2 749 =2 750 =2 751 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 752 ; I2TSTR - I2C Transmit String to I2C device =2 753 ; entry =2 754 ; Internal Ram with data =2 755 ; R0 - Buffer Pointer to Internal Ram =2 756 ; R4 - I2C Address of Device =2 757 ; R5 - I2C Control Word (optional) =2 758 ; R6 - Data Byte Count (excluding address) =2 759 ; I2CUCW - I2C Use Control Word =2 760 ; exit =2 761 ; I2CFLT - I2C Bus Fault Detected =2 762 ; I2CNACK - I2C NACK =2 763 ; I2CIP - I2C transfer in Progress =2 764 ; modified =2 765 ; R0 - Buffer Pointer to Internal Ram =2 766 ; R6 - Data Byte Count =2 767 ; R7 - Bit Counter =2 768 ; ACC - Used for GP stuff =2 769 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 770 ; 89A2 31BA =2 771 I2TSTR: ACALL I2STAR ; send start and address 89A4 200E09 =2 772 JB I2CNACK,I2TS20 ; jump if no ack 89A7 E6 =2 773 I2TS10: MOV A,@R0 ; get byte from ram 89A8 08 =2 774 INC R0 ; increment address pointer 89A9 31F7 =2 775 ACALL I2TBYT ; transmit a byte to I2C device 89AB 200EEF =2 776 JB I2CNACK,I2RS20 ; jump if no ack 89AE DEF7 =2 777 DJNZ R6,I2TS10 ; loop till done 89B0 5110 =2 778 I2TS20: ACALL I2STOP ; stop the transfer MC2LDEV MC-2 Development 990419-2.00v PAGE 15 89B2 D20F =2 779 SETB I2CX ; mark bad 89B4 22 =2 780 RET =2 781 =2 782 =2 783 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 784 ;I2SCW ; Send Start, Address, (optional) Control Word and Stop =2 785 ; entry =2 786 ; Internal Ram with data =2 787 ; R4 - I2C Address of Device =2 788 ; R5 - I2C Control Word (optional) =2 789 ; I2CUCW - I2C Use Control Word =2 790 ; exit =2 791 ; I2CFLT - I2C Bus Fault Detected =2 792 ; I2CNACK - I2C NACK =2 793 ; I2CIP - I2C transfer in Progress =2 794 ; modified =2 795 ; R7 - Bit Counter =2 796 ; ACC - Used for GP stuff =2 797 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 798 ; 89B5 =2 799 I2SCW: ; Send Start, Address, (optional) Control Word and Stop 89B5 31BA =2 800 ACALL I2STAR ; send start and address 89B7 5110 =2 801 ACALL I2STOP ; stop the transfer 89B9 22 =2 802 RET =2 803 =2 804 =2 805 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 806 ;I2STAR ; Send Start and Address (and optional Control Word) =2 807 ; entry =2 808 ; R4 - Address of I2C device =2 809 ; R5 - I2C Control Word (optional) =2 810 ; ACC - Data to I2C device =2 811 ; I2CUCW - I2C Use Control Word =2 812 ; exit =2 813 ; I2CFLT - I2C Bus Fault Detected =2 814 ; I2CNACK - I2C NACK =2 815 ; I2CIP - I2C transfer in Progress =2 816 ; modified =2 817 ; ACC - Used for GP stuff =2 818 ; R7 - Bit counter =2 819 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 820 ; 89BA =2 821 I2STAR: ; send start and address 89BA D20B =2 822 SETB I2CIP ; mark I2C transfer in progress 89BC C20D =2 823 CLR I2CFLT ; no I2C Bus Fault Detected yet 89BE C20E =2 824 CLR I2CNACK ; no I2C No Acknowledge yet 89C0 309614 =2 825 JNB I2CLK,I2ST20 ; jump if bus fault 89C3 309711 =2 826 JNB I2DAT,I2ST20 ; jump if bus fault 89C6 512B =2 827 ACALL I2LODAT ; first data low & delay 89C8 5121 =2 828 ACALL I2LOCLK ; set low clock & delay (start condx) 89CA EC =2 829 MOV A,R4 ; get address of device to select 89CB 31F7 =2 830 ACALL I2TBYT ; send the byte 89CD 200E06 =2 831 JB I2CNACK,I2ST10 ; jump if no ack 89D0 300C03 =2 832 JNB I2CUCW,I2ST10 ; jump if no control word wanted 89D3 ED =2 833 MOV A,R5 ; get address of device to select 89D4 31F7 =2 834 ACALL I2TBYT ; send the byte, I2CNACK on return 89D6 22 =2 835 I2ST10: RET 89D7 D20D =2 836 I2ST20: SETB I2CFLT ; I2C Bus Fault Detected MC2LDEV MC-2 Development 990419-2.00v PAGE 16 89D9 D20F =2 837 SETB I2CX ; mark bad 89DB 22 =2 838 RET =2 839 =2 840 =2 841 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 842 ; I2RBYT - I2C Receive Byte from I2C device =2 843 ; entry =2 844 ; R6 - Data Byte Count =2 845 ; exit =2 846 ; ACC - Data from I2C device =2 847 ; modified =2 848 ; R7 - Bit counter =2 849 ; I2CNACK - I2C NACK =2 850 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 851 ; 89DC 7F08 =2 852 I2RBYT: MOV R7,#8 ; 8 bits per byte 89DE =2 853 I2RBY10: 89DE 5119 =2 854 ACALL I2HICLK ; set & wait for high clock & delay 89E0 A297 =2 855 MOV C,I2DAT ; get I2C data bit input 89E2 33 =2 856 RLC A ; rotate left through carry 89E3 5121 =2 857 ACALL I2LOCLK ; set low clock & delay 89E5 DFF7 =2 858 DJNZ R7,I2RBY10 ; loop for all 8 bits 89E7 BE0104 =2 859 CJNE R6,#1,I2RBY20 ; jump if not end of last byte =2 860 ; come here if last byte to be received 89EA 5126 =2 861 ACALL I2HIDAT ; data high & delay to mark end 89EC 21F0 =2 862 AJMP I2RBY30 ; skip 89EE =2 863 I2RBY20: =2 864 ; come here if not last byte to be received 89EE 512B =2 865 ACALL I2LODAT ; first low & delay for ack 89F0 =2 866 I2RBY30: =2 867 ; come here for all bytes 89F0 5119 =2 868 ACALL I2HICLK ; set & wait for high clock & delay 89F2 5121 =2 869 ACALL I2LOCLK ; set low clock & delay 89F4 5126 =2 870 ACALL I2HIDAT ; data high & delay 89F6 22 =2 871 RET =2 872 =2 873 =2 874 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 875 ; I2TBYT - I2C Transmit Byte to I2C device =2 876 ; entry =2 877 ; ACC - Data to I2C device =2 878 ; I2CNACK - I2C NACK =2 879 ; exit =2 880 ; I2CNACK - I2C NACK =2 881 ; modified =2 882 ; ACC - Data to I2C device =2 883 ; R7 - Bit counter =2 884 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 885 ; 89F7 7F08 =2 886 I2TBYT: MOV R7,#8 ; 8 bits per byte 89F9 =2 887 I2TBY10: 89F9 33 =2 888 RLC A ; rotate left through carry 89FA 9297 =2 889 MOV I2DAT,C ; put data bit to I2C device 89FC 5130 =2 890 ACALL I2DELAY ; delay 89FE 5119 =2 891 ACALL I2HICLK ; set & wait for high clock & delay 8A00 5121 =2 892 ACALL I2LOCLK ; set low clock & delay 8A02 DFF5 =2 893 DJNZ R7,I2TBY10 ; loop for all 8 bits 8A04 5126 =2 894 ACALL I2HIDAT ; data high & delay, float before ack chk MC2LDEV MC-2 Development 990419-2.00v PAGE 17 8A06 5119 =2 895 ACALL I2HICLK ; set & wait for high clock & delay 8A08 309702 =2 896 JNB I2DAT,I2TBY20 ; jump if ack found 8A0B D20E =2 897 SETB I2CNACK ; mark no ack found 8A0D =2 898 I2TBY20: 8A0D 5121 =2 899 ACALL I2LOCLK ; set low clock & delay 8A0F 22 =2 900 RET =2 901 =2 902 =2 903 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 904 ;I2STOP ; Send Stop Command to I2C Bus =2 905 ; entry =2 906 ; =2 907 ; exit =2 908 ; I2CIP - I2C transfer in Progress =2 909 ; modified =2 910 ; I2CLK - I2C Clock =2 911 ; I2DAT - I2C Data =2 912 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 913 ; 8A10 =2 914 I2STOP: ; send stop command 8A10 512B =2 915 ACALL I2LODAT ; first data low & delay 8A12 5119 =2 916 ACALL I2HICLK ; set & wait for high clock & delay 8A14 5126 =2 917 ACALL I2HIDAT ; data high & delay, after clk stopped 8A16 C20B =2 918 CLR I2CIP ; mark I2C transfer processes stopped 8A18 22 =2 919 RET =2 920 =2 921 =2 922 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 923 ; I2HICLK - set & wait for high clock =2 924 ; entry =2 925 ; =2 926 ; exit =2 927 ; I2CLK - I2C Clock =2 928 ; modified =2 929 ; I2CLK - I2C Clock =2 930 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 931 ; 8A19 =2 932 I2HICLK: 8A19 D296 =2 933 SETB I2CLK ; release clock for pull up high 8A1B 3096FD =2 934 JNB I2CLK,$ ; loop till it acutally goes high 8A1E 5130 =2 935 ACALL I2DELAY ; delay 8A20 22 =2 936 RET =2 937 =2 938 =2 939 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 940 ; I2LOCLK - set low clock =2 941 ; entry =2 942 ; =2 943 ; exit =2 944 ; I2CLK - I2C Clock =2 945 ; modified =2 946 ; I2CLK - I2C Clock =2 947 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 948 ; 8A21 =2 949 I2LOCLK: 8A21 C296 =2 950 CLR I2CLK ; release clock for pull up high 8A23 5130 =2 951 ACALL I2DELAY ; delay 8A25 22 =2 952 RET MC2LDEV MC-2 Development 990419-2.00v PAGE 18 =2 953 =2 954 =2 955 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 956 ; I2HIDAT - set high data =2 957 ; entry =2 958 ; =2 959 ; exit =2 960 ; I2DAT - I2C Data =2 961 ; modified =2 962 ; I2DAT - I2C Data =2 963 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 964 ; 8A26 =2 965 I2HIDAT: 8A26 D297 =2 966 SETB I2DAT ; release data for pull up high 8A28 5130 =2 967 ACALL I2DELAY ; delay 8A2A 22 =2 968 RET =2 969 =2 970 =2 971 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 972 ; I2LODAT - set low data =2 973 ; entry =2 974 ; =2 975 ; exit =2 976 ; I2DAT - I2C Data =2 977 ; modified =2 978 ; I2DAT - I2C Data =2 979 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 980 ; 8A2B =2 981 I2LODAT: 8A2B C297 =2 982 CLR I2DAT ; release data for pull up low 8A2D 5130 =2 983 ACALL I2DELAY ; delay 8A2F 22 =2 984 RET =2 985 =2 986 =2 987 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 988 ;I2DELAY ; Delay for change of bus leads =2 989 ; entry =2 990 ; =2 991 ; exit =2 992 ; =2 993 ; modified =2 994 ; =2 995 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 996 ; 8A30 =2 997 I2DELAY: 8A30 00 =2 998 NOP ; kill some time 8A31 00 =2 999 NOP ; kill some time 8A32 22 =2 1000 RET =2 1001 =2 1002 ENDIF =2 1003 =2 1004 IF (I2C751) ; I2C implemented with 87C751 HW =2 1005 =2 1006 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1007 ; I2C Routines for 87C751 -- Based heavily on =2 1008 ; code from from Philips AN422 =2 1009 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1010 MC2LDEV MC-2 Development 990419-2.00v PAGE 19 =2 1011 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1012 ; EEWRBK - EEPROM Write Block =2 1013 ; entry =2 1014 ; none =2 1015 ; exit =2 1016 ; write block of bytes from IRAM to EEprom =2 1017 ; I2CX - I2C fault of some sort =2 1018 ; I2CFLT - I2C Bus Fault Detected =2 1019 ; I2CNACK - I2C NACK =2 1020 ; I2CIP - I2C transfer in Progress =2 1021 ; modified =2 1022 ; ACC - Address =2 1023 ; R0, R2, R4, R5, R7 =2 1024 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1025 ; =2 1026 EEWRBK: =2 1027 CLR I2CFLT ; clear I2C Bus Fault Detected flag =2 1028 CLR I2CNACK ; clear I2C NACK Detected flag =2 1029 CLR I2CX ; clear I2C generic problem flag =2 1030 MOV R0,#NVRAM ; pt to NV ram space =2 1031 MOV R2,#NVRAML ; get number of bytes to write =2 1032 MOV R3,#010H =2 1033 EEWRB10: =2 1034 MOV A,#I2CEEP ; put eeprom I2C write address A =2 1035 ACALL SNDADR ; send address =2 1036 JB I2CX,EEWRB20 ; jump if any I2C problems =2 1037 MOV A,R3 ; put eeprom internal adr in A =2 1038 ACALL TXBY ; send byte to eeprom =2 1039 JB I2CX,EEWRB20 ; jump if any I2C problems =2 1040 MOV A,@R0 ; get data from memory =2 1041 INC R0 ; pt to next iram data =2 1042 INC R3 ; pt to next eeprom address =2 1043 ACALL TXBY ; send byte to eeprom =2 1044 JB I2CX,EEWRB20 ; jump if any I2C problems =2 1045 ACALL SNDSP ; send stop =2 1046 ACALL DY60MS ; wait for 60 milliseconds =2 1047 DJNZ R2,EEWRB10 ; loop till done =2 1048 EEWRB20: =2 1049 RET =2 1050 =2 1051 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1052 ; EERDBK - EEPROM Read Block =2 1053 ; entry =2 1054 ; none =2 1055 ; exit =2 1056 ; write block of bytes from EEprom to IRAM =2 1057 ; I2CX - I2C fault of some sort =2 1058 ; I2CFLT - I2C Bus Fault Detected =2 1059 ; I2CNACK - I2C NACK =2 1060 ; I2CIP - I2C transfer in Progress =2 1061 ; modified =2 1062 ; ACC - Address =2 1063 ; R0, R2, R4, R5, R7 =2 1064 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1065 ; =2 1066 EERDBK: =2 1067 ; MOV R0,#010H =2 1068 ; MOV R2,#20 MC2LDEV MC-2 Development 990419-2.00v PAGE 20 =2 1069 ;EEXX10 MOV A,R0 =2 1070 ; MOV @R0,A =2 1071 ; INC R0 =2 1072 ; DJNZ R2,EEXX10 =2 1073 ;;; ACALL SHWMEM =2 1074 =2 1075 CLR I2CFLT ; clear I2C Bus Fault Detected flag =2 1076 CLR I2CNACK ; clear I2C NACK Detected flag =2 1077 CLR I2CX ; clear I2C generic problem flag =2 1078 MOV R0,#NVRAM ; pt to NV ram space =2 1079 MOV R2,#NVRAML ; get number of bytes to write =2 1080 MOV A,#I2CEEP ; put eeprom I2C write address A =2 1081 ACALL SNDADR ; send address =2 1082 JB I2CX,EERD40 ; jump if any I2C problems =2 1083 MOV A,#010H ; put eeprom internal start adr in A =2 1084 ACALL TXBY ; send byte =2 1085 JB I2CX,EERD40 ; jump if any I2C problems =2 1086 ACALL REPST ; send repeated start =2 1087 JB I2CX,EERD40 ; jump if any I2C problems =2 1088 MOV A,#I2CEEP+1 ; get EEPROM I2C read address =2 1089 ACALL SNDSUB ; send EEPROM address =2 1090 JB I2CX,EERD40 ; jump if any I2C problems =2 1091 DJNZ R2,EERD20 ; jump if not last time =2 1092 AJMP EERD30 ; last time, don't ack =2 1093 EERD20: ACALL RDACK ; not last time, so get data & send ACK =2 1094 JB I2CX,EERD40 ; jump if any I2C problems =2 1095 MOV @R0,A ; move data to memory =2 1096 INC R0 ; pt to next memory location =2 1097 DJNZ R2,EERD20 ; loop till done, fall through on last =2 1098 EERD30: ; last time through loop, don't ack =2 1099 ACALL RXBY ; get last byte from EEPROM =2 1100 JB I2CX,EERD40 ; jump if any I2C problems =2 1101 MOV @R0,A ; move data to memory =2 1102 MOV I2DAT,#080H ; send NACK =2 1103 JNB ATN,$ ; wait for NACK to be sent =2 1104 ;; JNB DRDY,BFREC ; if not data then bus fault =2 1105 EERD40: ACALL SNDSP ; send stop =2 1106 RET =2 1107 =2 1108 =2 1109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1110 ; BFREC -- Bus Fault Recovery =2 1111 ; Attempt to restore the bus for next time. =2 1112 ; If all else fails, power will need to be cycled. =2 1113 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1114 ; =2 1115 ;?BFREC: ; first see if simple fix will work =2 1116 ;; MOV A,#55H ;++ ; mark BFREC =2 1117 ;; ACALL ADUMP ;++ =2 1118 ;; ACALL SHWMEM ;++ =2 1119 =2 1120 ; CLR MASTRQ ; turn off I2C functions =2 1121 ; SETB SCL ; ensure I/O port is not locking I2C bus =2 1122 ; SETB SDA ; same for data port =2 1123 ; JNB SCL,BFREC40 ; if clock stuck low then can't fix =2 1124 ; JB SDA,BFREC20 ; jump to stop if data is high =2 1125 ; MOV R7,#9 ; set max number of tries to clear bus =2 1126 ;BFREC10 CLR SCL ; force I2C clock low MC2LDEV MC-2 Development 990419-2.00v PAGE 21 =2 1127 ; ACALL DY20US ; delay 20 uS or so =2 1128 ; JB SDA,BFREC20 ; if idle then jump out =2 1129 ; SETB SCL ; force I2C clock high =2 1130 ; ACALL DY20US ; delay 20 uS or so =2 1131 ; DJNZ R7,BFREC10 ; loop until fixed or tries out =2 1132 ; AJMP BFREC40 ; get out as failure =2 1133 ;BFREC20 CLR SDA ; try forcing stop since SCL=0 & SDA=1 =2 1134 ; ACALL DY20US ; delay 20 uS or so =2 1135 ; SETB SCL ; force I2C clock high =2 1136 ; ACALL DY20US ; delay 20 uS or so =2 1137 ; SETB SDA ; set data high =2 1138 ; ACALL DY20US ; delay 20 uS or so =2 1139 ; JNB SCL,BFREC40 ; if SCL still low then bad, jump =2 1140 ; JNB SDA,BFREC40 ; if SDA still low then bad, jump =2 1141 ;BFREC30 RET ; that's all to try =2 1142 ;BFREC40 CLR BMRQ ; release bus =2 1143 ; MOV I2CON,#0BCH ; clear all I2C flags =2 1144 ; RET =2 1145 =2 1146 =2 1147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1148 ; SNDADR -- Send I2C address to device =2 1149 ; entry =2 1150 ; ACC - Address of I2C device =2 1151 ; I2CX - I2C fault of some sort =2 1152 ; I2CFLT - I2C Bus Fault Detected =2 1153 ; I2CNACK - I2C NACK =2 1154 ; I2CIP - I2C transfer in Progress =2 1155 ; exit =2 1156 ; I2CX - I2C fault of some sort =2 1157 ; I2CFLT - I2C Bus Fault Detected =2 1158 ; I2CNACK - I2C NACK =2 1159 ; I2CIP - I2C transfer in Progress =2 1160 ; modified =2 1161 ; ACC - Address =2 1162 ; R7 - Bit counter =2 1163 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1164 ; =2 1165 SNDADR: MOV I2CFG,#BMRQ+BTIR+CTVAL ; request I2C bus =2 1166 JNB ATN,$ ; wait for grant =2 1167 JNB MASTER,SNDA10 ; if not master then bus fault =2 1168 SNDSUB: ; enter here for sub address =2 1169 MOV I2DAT,A ; send 1st bit, clears DRDY =2 1170 MOV I2CON,#BCARL+BCSTR+BCSTP ; clear start, release SCL =2 1171 AJMP TXADR ; continue with address =2 1172 SNDA10: SETB I2CFLT ; mark bus fault =2 1173 SETB I2CX ; I2C fault, generic =2 1174 RET =2 1175 =2 1176 =2 1177 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1178 ; TXADR -- Transmit Address to I2C device =2 1179 ; entry =2 1180 ; ACC - Address of I2C device =2 1181 ; I2CX - I2C fault of some sort =2 1182 ; I2CFLT - I2C Bus Fault Detected =2 1183 ; I2CNACK - I2C NACK =2 1184 ; I2CIP - I2C transfer in Progress MC2LDEV MC-2 Development 990419-2.00v PAGE 22 =2 1185 ; exit =2 1186 ; I2CX - I2C fault of some sort =2 1187 ; I2CFLT - I2C Bus Fault Detected =2 1188 ; I2CNACK - I2C NACK =2 1189 ; I2CIP - I2C transfer in Progress =2 1190 ; modified =2 1191 ; ACC - (possibly) =2 1192 ; R7 - Bit counter =2 1193 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1194 ; =2 1195 TXADR: MOV R7,#8 ; adr is 7 bits, but will skip MSBit =2 1196 AJMP TXBYAD ; jump to bit loop routine =2 1197 =2 1198 =2 1199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1200 ; TXBY -- Transmit Byte to I2C device =2 1201 ; entry =2 1202 ; ACC - Data to I2C device =2 1203 ; I2CX - I2C fault of some sort =2 1204 ; I2CFLT - I2C Bus Fault Detected =2 1205 ; I2CNACK - I2C NACK =2 1206 ; I2CIP - I2C transfer in Progress =2 1207 ; exit =2 1208 ; I2CX - I2C fault of some sort =2 1209 ; I2CFLT - I2C Bus Fault Detected =2 1210 ; I2CNACK - I2C NACK =2 1211 ; I2CIP - I2C transfer in Progress =2 1212 ; modified =2 1213 ; ACC - (possibly) =2 1214 ; R7 - Bit counter =2 1215 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1216 ; =2 1217 TXBY: MOV R7,#8 ; 8 bits for data =2 1218 TXBY10: MOV I2DAT,A ; send a bit =2 1219 TXBYAD: ; entry point for TXADR =2 1220 RL A ; get next bit to MSB, LSB is old MSB =2 1221 JNB ATN,$ ; wait for bit to be sent =2 1222 JNB DRDY,TXBY30 ; if not data then bus fault =2 1223 DJNZ R7,TXBY10 ; loop till done =2 1224 MOV I2CON,#BCDR+BCXA ; now do receive mode =2 1225 JNB ATN,$ ; wait for ACK =2 1226 JNB RDAT,TXBY20 ; jump if ACK =2 1227 SETB I2CNACK ; mark no ack =2 1228 SETB I2CX ; I2C fault, generic =2 1229 TXBY20: RET =2 1230 TXBY30: SETB I2CFLT ; mark bus fault =2 1231 SETB I2CX ; I2C fault, generic =2 1232 RET =2 1233 =2 1234 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1235 ; RDACK -- Receive Byte with ACK =2 1236 ; entry =2 1237 ; =2 1238 ; exit =2 1239 ; ACC - Data from I2C device =2 1240 ; modified =2 1241 ; R7 - Bit counter =2 1242 ; I2CX - I2C fault of some sort MC2LDEV MC-2 Development 990419-2.00v PAGE 23 =2 1243 ; I2CFLT - I2C Bus Fault Detected =2 1244 ; I2CIP - I2C transfer in Progress =2 1245 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1246 ; =2 1247 RDACK: ACALL RXBY ; get a data byte =2 1248 MOV I2DAT,#0 ; send ack =2 1249 JNB ATN,$ ; wait for ack to be sent =2 1250 JNB DRDY,RXBY20 ; if not data then bus fault =2 1251 RET =2 1252 =2 1253 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1254 ; RXBY -- Receive Byte without ACK =2 1255 ; entry =2 1256 ; =2 1257 ; exit =2 1258 ; ACC - Data from I2C device =2 1259 ; modified =2 1260 ; R7 - Bit counter =2 1261 ; I2CX - I2C fault of some sort =2 1262 ; I2CFLT - I2C Bus Fault Detected =2 1263 ; I2CIP - I2C transfer in Progress =2 1264 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1265 ; =2 1266 RXBY: MOV R7,#8 ; set bit count =2 1267 CLR A ; init rx byte to zero =2 1268 RXBY10: ORL A,I2DAT ; get bit to ACC, clear ATN =2 1269 RL A ; shift data =2 1270 JNB ATN,$ ; wait for next bit =2 1271 JNB DRDY,RXBY20 ; if not data then bus fault =2 1272 DJNZ R7,RXBY10 ; loop till all done =2 1273 MOV C,RDAT ; get last bit, don't clear ATN =2 1274 RLC A ; shift into A =2 1275 RET =2 1276 RXBY20: SETB I2CFLT ; mark bus fault =2 1277 SETB I2CX ; I2C fault, generic =2 1278 RET =2 1279 =2 1280 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1281 ; SNDSP - Send Stop =2 1282 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1283 ; =2 1284 SNDSP: CLR MASTRQ ; release as bus master =2 1285 MOV I2CON,#BCDR+BXSTP ; generate bus stop =2 1286 JNB ATN,$ ; wait for ATN =2 1287 MOV I2CON,#BCDR ; clear data ready =2 1288 JNB ATN,$ ; wait for stop =2 1289 MOV I2CON,#BCARL+BCSTP+BCXA ; clear I2C bus =2 1290 CLR TIRUN ; stop timer I =2 1291 RET =2 1292 =2 1293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1294 ; REPST -- Repeated Start Routine =2 1295 ; only called once, can be put in line =2 1296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1297 ; =2 1298 REPST: MOV I2CON,#BCDR+BXSTR ; send repeated start =2 1299 JNB ATN,$ ; wait for ATN =2 1300 MOV I2CON,#BCDR ; clear data ready MC2LDEV MC-2 Development 990419-2.00v PAGE 24 =2 1301 JNB ATN,$ ; wait for repeated start sent =2 1302 RET =2 1303 =2 1304 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1305 ; DY20US - Delay 20 uS for I2C Bus timing =2 1306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1307 ; =2 1308 ;DY20US NOP =2 1309 ; NOP =2 1310 ; NOP =2 1311 ; NOP =2 1312 ; NOP =2 1313 ; NOP =2 1314 ; NOP =2 1315 ; RET =2 1316 =2 1317 ENDIF =2 1318 =2 1319 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1320 ; VALRAM - Validate Ram. Correct the checksum. =2 1321 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1322 ; 8A33 5138 =2 1323 VALRAM: ACALL RAMV ; get the correct check to R3 8A35 EB =2 1324 MOV A,R3 ; move to A 8A36 F7 =2 1325 MOV @R1,A ; and put into check location 8A37 22 =2 1326 RET =2 1327 =2 1328 =2 1329 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1330 ; RAMV - Ram Vaild? =2 1331 ; CY = 1 and A = 0 if the checksum on NVRAM is correct =2 1332 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1333 ; 8A38 7934 =2 1334 RAMV: MOV R1,#NVRAM+NVCHKL-1 ; pt to last of protected NVRAM 8A3A 7B10 =2 1335 MOV R3,#NVCHKL-1 ; get check length less one 8A3C E4 =2 1336 CLR A ; clear A 8A3D 27 =2 1337 RAMV10: ADD A,@R1 ; add a byte 8A3E 2403 =2 1338 ADD A,#003 ; plus three, just to scramble result 8A40 19 =2 1339 DEC R1 ; pt to next less NVRAM loc 8A41 DBFA =2 1340 DJNZ R3,RAMV10 ; loop till all data is done 8A43 FB =2 1341 MOV R3,A ; save sum in R3 8A44 67 =2 1342 XRL A,@R1 ; compare with checksum loc 8A45 C3 =2 1343 CLR C ; assume data incorrect 8A46 7001 =2 1344 JNZ RAMV20 ; jump if incorrect 8A48 D3 =2 1345 SETB C ; set C to show correct 8A49 22 =2 1346 RAMV20: RET =2 1347 =2 1348 =2 1349 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1350 ; DEFAULT - Load default values of user option data from ROM =2 1351 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1352 ; 8A4A =2 1353 DEFAULT: ; load default values of user option data from ROM 8A4A 7925 =2 1354 MOV R1,#NVRAM+1 ; pt to NVRAM data 8A4C 7B10 =2 1355 MOV R3,#NVRAML-1 ; get length of data 8A4E 908A59 =2 1356 MOV DPTR,#DEFA20 ; pt to table 8A51 E4 =2 1357 DEFA10: CLR A ; clear A 8A52 93 =2 1358 MOVC A,@A+DPTR ; get a char MC2LDEV MC-2 Development 990419-2.00v PAGE 25 8A53 F7 =2 1359 MOV @R1,A ; save at NVRAM 8A54 09 =2 1360 INC R1 ; increment NVRAM ptr 8A55 A3 =2 1361 INC DPTR ; increment the index 8A56 DBF9 =2 1362 DJNZ R3,DEFA10 ; loop till all are done 8A58 22 =2 1363 RET 8A59 05 =2 1364 DEFA20: DB 005H ; (r-7-F9) RSTAT0, 9600 bps 8A5A 00 =2 1365 DB 000H ; (r-6-FA) RSTAT1 8A5B 00 =2 1366 DB 000H ; (r-5-FB) ACHANGE MASK 8A5C 12 =2 1367 DB 012H ; (r-4-FC) PSWD0, 12 is default password 8A5D 34 =2 1368 DB 034H ; (r-3-FD) PSWD1, 34 is default password 8A5E 56 =2 1369 DB 056H ; (r-2-FE) PSWD2, 56 is default password 8A5F 41 =2 1370 DB 'A' ; (r-1-FF) default stn address is 'A' 8A60 00 =2 1371 DB 000H ; (r+0) OSTAT0, all off 8A61 00 =2 1372 DB 000H ; (r+1) OSTAT1, all off 8A62 00 =2 1373 DB 000H ; (r+2) PULFLG, all off 8A63 00 =2 1374 DB 000H ; (r+3) ADCFLG, all singled ended 8A64 00 =2 1375 DB 000H ; (r+4) ODP0, output image 8A65 00 =2 1376 DB 000H ; (r+5) ODP2, output image 8A66 00 =2 1377 DB 000H ; (r+6) ODP4, output image 8A67 00 =2 1378 DB 000H ; (r+7) ODP5, output image 8A68 00 =2 1379 DB 000H ; (r+8) ODP6, output image 8A69 00 =2 1380 DB 000H ; (r+9) IDP0, input image (in case needed for even) =2 1381 =2 1382 $INCLUDE(BBWCMD.ASM) ; bit, byte and word command proc =2 1383 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1384 ; +++ BBWCMD.ASM =2 1385 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1386 8A6A =2 1387 BITDSP: ; display a bit of memory 8A6A 12982B =2 1388 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 8A6D 4003 =2 1389 JC BITD05 ; jump if address OK 8A6F 0298B4 =2 1390 JMP ADRERR ; address error, print error message 8A72 129864 =2 1391 BITD05: CALL SMR7 ; swap and mask R7 for ls nibble 8A75 12986A =2 1392 BITD10: CALL PSTNADM ; print station address marker 8A78 EF =2 1393 BITD20: MOV A,R7 ; get bit address 8A79 FA =2 1394 MOV R2,A ; and save in R2 8A7A 742C =2 1395 MOV A,#RIDX ; get table offset 8A7C 2E =2 1396 ADD A,R6 ; add in address 8A7D F8 =2 1397 MOV R0,A ; move index to R0 8A7E E6 =2 1398 MOV A,@R0 ; get the byte 8A7F 0A =2 1399 INC R2 ; add one to bit address 8A80 13 =2 1400 BITD30: RRC A ; rotate data into C 8A81 DAFD =2 1401 DJNZ R2,BITD30 ; loop till bit in CY 8A83 9200 =2 1402 MOV TMPB0,C ; save bit in TMPB0 8A85 129817 =2 1403 CALL PR6HX ; print R6 address as hex 8A88 EF =2 1404 MOV A,R7 ; get bit address 8A89 2430 =2 1405 ADD A,#'0' ; add in ascii offset 8A8B 129226 =2 1406 CALL PUTCHAR ; print bit address 8A8E 742D =2 1407 MOV A,#'-' ; get delimiter 8A90 129226 =2 1408 CALL PUTCHAR ; print it 8A93 A200 =2 1409 MOV C,TMPB0 ; move data back into C 8A95 12979F =2 1410 CALL PBINBIT ; print binary bit 8A98 129721 =2 1411 CALL CRLF ; print newline 8A9B 22 =2 1412 RET =2 1413 8A9C =2 1414 BITSET: ; bit set, set the addressed bit to one 8A9C 12982B =2 1415 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 8A9F 4003 =2 1416 JC BITS05 ; jump if address OK MC2LDEV MC-2 Development 990419-2.00v PAGE 26 8AA1 0298B4 =2 1417 JMP ADRERR ; address error, print error message 8AA4 129864 =2 1418 BITS05: CALL SMR7 ; swap and mask R7 for ls nibble 8AA7 EF =2 1419 MOV A,R7 ; move bit address to A 8AA8 FA =2 1420 MOV R2,A ; and save in R2 8AA9 742C =2 1421 MOV A,#RIDX ; get table offset 8AAB 2E =2 1422 ADD A,R6 ; add in address 8AAC F8 =2 1423 MOV R0,A ; move index to R0 8AAD D3 =2 1424 SETB C ; set the CY 8AAE 0A =2 1425 INC R2 ; add one to bit address 8AAF E4 =2 1426 CLR A ; clear A 8AB0 33 =2 1427 BITS10: RLC A ; rotate data left from C 8AB1 DAFD =2 1428 DJNZ R2,BITS10 ; loop till bit in CY 8AB3 46 =2 1429 ORL A,@R0 ; set the bit to one 8AB4 F6 =2 1430 MOV @R0,A ; and resave 8AB5 80BE =2 1431 JMP BITD10 ; display the newly set bit =2 1432 8AB7 =2 1433 BITCLR: ; bit clear, clear the addressed bit to zero 8AB7 12982B =2 1434 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 8ABA 4003 =2 1435 JC BITC05 ; jump if address OK 8ABC 0298B4 =2 1436 JMP ADRERR ; address error, print error message 8ABF 129864 =2 1437 BITC05: CALL SMR7 ; swap and mask R7 for ls nibble 8AC2 EF =2 1438 MOV A,R7 ; get bit address 8AC3 FA =2 1439 MOV R2,A ; and save in R2 8AC4 742C =2 1440 MOV A,#RIDX ; get table offset 8AC6 2E =2 1441 ADD A,R6 ; add in address 8AC7 F8 =2 1442 MOV R0,A ; move index to R0 8AC8 D3 =2 1443 SETB C ; set the CY 8AC9 0A =2 1444 INC R2 ; add one to bit address 8ACA E4 =2 1445 CLR A ; clear A 8ACB 33 =2 1446 BITC10: RLC A ; rotate data left from C 8ACC DAFD =2 1447 DJNZ R2,BITC10 ; loop till bit in CY 8ACE F4 =2 1448 CPL A ; invert the mask 8ACF 56 =2 1449 ANL A,@R0 ; clear the bit to zero 8AD0 F6 =2 1450 MOV @R0,A ; and resave 8AD1 80A2 =2 1451 JMP BITD10 ; display the newly cleared bit =2 1452 8AD3 =2 1453 BITWR: ; bit write to memory 8AD3 12982B =2 1454 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 8AD6 4003 =2 1455 JC BITW05 ; jump if address OK 8AD8 0298B4 =2 1456 JMP ADRERR ; address error, print error message 8ADB 8FF0 =2 1457 BITW05: MOV B,R7 ; get bit value to B.0 8ADD 129864 =2 1458 CALL SMR7 ; swap and mask R7 for ls nibble 8AE0 EF =2 1459 MOV A,R7 ; get bit address 8AE1 FA =2 1460 MOV R2,A ; and save in R2 8AE2 742C =2 1461 MOV A,#RIDX ; get table offset 8AE4 2E =2 1462 ADD A,R6 ; add in address 8AE5 F8 =2 1463 MOV R0,A ; move index to R0 8AE6 D3 =2 1464 SETB C 8AE7 0A =2 1465 INC R2 ; add one to bit address 8AE8 E4 =2 1466 CLR A ; clear A 8AE9 33 =2 1467 BITW10: RLC A ; rotate data left from C 8AEA DAFD =2 1468 DJNZ R2,BITW10 ; loop till bit in CY 8AEC 20F005 =2 1469 JB B.0,BITW20 ; jump if data one is wanted 8AEF F4 =2 1470 CPL A ; inver bit mask 8AF0 56 =2 1471 ANL A,@R0 ; set the bit to zero 8AF1 F6 =2 1472 MOV @R0,A ; and resave 8AF2 8081 =2 1473 JMP BITD10 ; display the newly set bit 8AF4 46 =2 1474 BITW20: ORL A,@R0 ; set the bit to one MC2LDEV MC-2 Development 990419-2.00v PAGE 27 8AF5 F6 =2 1475 MOV @R0,A ; and resave 8AF6 4175 =2 1476 JMP BITD10 ; display the newly written bit =2 1477 8AF8 =2 1478 BYTDSP: ; display a byte of memory 8AF8 12982B =2 1479 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 8AFB 4003 =2 1480 JC BYTD10 ; jump if address OK 8AFD 0298B4 =2 1481 JMP ADRERR ; address error, print error message 8B00 742C =2 1482 BYTD10: MOV A,#RIDX ; get table offset 8B02 2E =2 1483 ADD A,R6 ; add in address 8B03 F8 =2 1484 MOV R0,A ; move index to R0 8B04 E6 =2 1485 MOV A,@R0 ; get the byte 8B05 FC =2 1486 MOV R4,A ; save data in R4 8B06 12986A =2 1487 CALL PSTNADM ; print station address marker 8B09 129817 =2 1488 CALL PR6HX ; print R6 (address) as hex 8B0C 742D =2 1489 MOV A,#'-' ; get delimiter 8B0E 129226 =2 1490 CALL PUTCHAR ; print it 8B11 EC =2 1491 MOV A,R4 ; get data back from R4 =2 1492 ;;;; MOV R6,A ; move data to R6 =2 1493 ;;;; CALL PR6HX ; print R6 (address) as hex 8B12 128BC7 =2 1494 CALL PBIN ; print data in A has 3 digit decimal 8B15 1297B5 =2 1495 CALL SPACE2 ; print two space chars 8B18 EC =2 1496 MOV A,R4 ; get data back from R4 8B19 12976E =2 1497 CALL PHXBYTE ; print as a byte 8B1C 1297B5 =2 1498 CALL SPACE2 ; print two space chars 8B1F EC =2 1499 MOV A,R4 ; get data back from R4 8B20 12978B =2 1500 CALL PBYTBIT ; print byte as 8 bits 8B23 129721 =2 1501 CALL CRLF ; print newline 8B26 22 =2 1502 RET =2 1503 8B27 =2 1504 BYTWR: ; write a byte of memory 8B27 12982B =2 1505 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 8B2A 4003 =2 1506 JC BYTW10 ; jump if address OK 8B2C 0298B4 =2 1507 LJMP ADRERR ; address error, print error message 8B2F 742C =2 1508 BYTW10: MOV A,#RIDX ; get table offset 8B31 2E =2 1509 ADD A,R6 ; add in address 8B32 F8 =2 1510 MOV R0,A ; move index to R0 8B33 EF =2 1511 MOV A,R7 ; recall data from R7 8B34 F6 =2 1512 MOV @R0,A ; save to memory 8B35 80C9 =2 1513 JMP BYTD10 ; and print result =2 1514 8B37 =2 1515 WRDDSP: ; display a word of memory 8B37 12982B =2 1516 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 8B3A 4003 =2 1517 JC WRDD10 ; jump if address OK 8B3C 02005F =2 1518 LJMP AERR ; address error, print error message 8B3F 128B6D =2 1519 WRDD10: CALL GWORD ; get a word at R6 w/o int intf to R4/R5 8B42 12986A =2 1520 CALL PSTNADM ; print station address marker 8B45 129817 =2 1521 CALL PR6HX ; print R6 (address) as hex 8B48 742D =2 1522 MOV A,#'-' ; get delimiter 8B4A 129226 =2 1523 CALL PUTCHAR ; print it 8B4D 128B81 =2 1524 CALL PWRDDEC ; print word in R4,R5 as decimal 8B50 1297B5 =2 1525 CALL SPACE2 ; print two space chars 8B53 ED =2 1526 MOV A,R5 ; get high byte from R5 8B54 12976E =2 1527 CALL PHXBYTE ; print as a byte 8B57 EC =2 1528 MOV A,R4 ; get low byte from R4 8B58 12976E =2 1529 CALL PHXBYTE ; print as a byte 8B5B 1297B5 =2 1530 CALL SPACE2 ; print two space chars 8B5E ED =2 1531 MOV A,R5 ; get high byte from R5 8B5F 12978B =2 1532 CALL PBYTBIT ; print byte as 8 bits MC2LDEV MC-2 Development 990419-2.00v PAGE 28 8B62 1297B8 =2 1533 CALL SPACE1 ; print a space char 8B65 EC =2 1534 MOV A,R4 ; get low byte from R4 8B66 12978B =2 1535 CALL PBYTBIT ; print byte as 8 bits 8B69 129721 =2 1536 CALL CRLF ; print newline 8B6C 22 =2 1537 RET =2 1538 8B6D =2 1539 GWORD: ; get a word pointed to by R6 (rel) w/o interrupt interference 8B6D 742C =2 1540 MOV A,#RIDX ; get table offset 8B6F 2E =2 1541 ADD A,R6 ; add in address 8B70 F8 =2 1542 MOV R0,A ; move index to R0 8B71 E6 =2 1543 MOV A,@R0 ; get the low byte 8B72 FC =2 1544 MOV R4,A ; save low byte in R4 8B73 08 =2 1545 INC R0 ; p++ 8B74 E6 =2 1546 MOV A,@R0 ; get the high byte 8B75 FD =2 1547 MOV R5,A ; save high byte in R5 8B76 18 =2 1548 DEC R0 ; p-- =2 1549 ; now test for interrupt writing new value 8B77 E6 =2 1550 MOV A,@R0 ; get low byte again 8B78 6C =2 1551 XRL A,R4 ; compare them 8B79 70F2 =2 1552 JNZ GWORD ; loop if not same 8B7B 08 =2 1553 INC R0 ; p++ 8B7C E6 =2 1554 MOV A,@R0 ; get high byte again 8B7D 6D =2 1555 XRL A,R5 ; compare them 8B7E 70ED =2 1556 JNZ GWORD ; loop if not same =2 1557 ; any interrupt overwrite now resolved, R4 low byte, R5 high byte 8B80 22 =2 1558 RET =2 1559 8B81 =2 1560 PWRDDEC: ; print binary word value contained in R4,R5 as decimal =2 1561 ; need to redo this to make it faster 8B81 7900 =2 1562 MOV R1,#0 ; clear R1 8B83 7A00 =2 1563 MOV R2,#0 ; clear R2 8B85 7B00 =2 1564 MOV R3,#0 ; clear R3 8B87 EC =2 1565 MOV A,R4 ; get low from R4 8B88 FE =2 1566 MOV R6,A ; save in R6 8B89 ED =2 1567 MOV A,R5 ; get high from R5 8B8A FF =2 1568 MOV R7,A ; save in R7 8B8B 7006 =2 1569 JNZ PWRD10 ; jump if not zero 8B8D EE =2 1570 MOV A,R6 ; check R6 8B8E 7003 =2 1571 JNZ PWRD10 ; jump if not zero 8B90 028BA4 =2 1572 JMP PWRD20 ; zero, print it 8B93 128BB1 =2 1573 PWRD10: CALL INCR123 ; increment R1,R2,R3 with DAA 8B96 1E =2 1574 DEC R6 ; decrement units counter 8B97 EE =2 1575 MOV A,R6 ; get new units value 8B98 7004 =2 1576 JNZ PWRD15 ; jump if not zero 8B9A EF =2 1577 MOV A,R7 ; get 256s counter 8B9B 6007 =2 1578 JZ PWRD20 ; jump if both zero (done) 8B9D EE =2 1579 MOV A,R6 ; get new units value 8B9E B4FFF2 =2 1580 PWRD15: CJNE A,#0FFH,PWRD10 ; loop if not underflow 8BA1 1F =2 1581 DEC R7 ; else, dec 256s counter 8BA2 80EF =2 1582 JMP PWRD10 ; continue 8BA4 EB =2 1583 PWRD20: MOV A,R3 ; get MS byte 8BA5 12977A =2 1584 CALL PHXCHAR ; print 10,000s 8BA8 EA =2 1585 MOV A,R2 ; get next byte 8BA9 12976E =2 1586 CALL PHXBYTE ; print 1,000s and 100s 8BAC E9 =2 1587 MOV A,R1 ; get next byte 8BAD 12976E =2 1588 CALL PHXBYTE ; print 10s and 1s 8BB0 22 =2 1589 RET =2 1590 MC2LDEV MC-2 Development 990419-2.00v PAGE 29 8BB1 =2 1591 INCR123: ; increment registers R1, R2 and R3 with DAA 8BB1 E9 =2 1592 MOV A,R1 ; get R1 8BB2 2401 =2 1593 ADD A,#1 ; add one 8BB4 D4 =2 1594 DA A ; adjust 8BB5 F9 =2 1595 MOV R1,A ; save in R1 8BB6 4001 =2 1596 JC INCR10 ; jump if cary 8BB8 22 =2 1597 RET 8BB9 EA =2 1598 INCR10: MOV A,R2 ; get R2 8BBA 2401 =2 1599 ADD A,#1 ; add one 8BBC D4 =2 1600 DA A ; adjust 8BBD FA =2 1601 MOV R2,A ; save in R2 8BBE 4001 =2 1602 JC INCR20 ; jump if cary 8BC0 22 =2 1603 RET 8BC1 EB =2 1604 INCR20: MOV A,R3 ; get R3 8BC2 2401 =2 1605 ADD A,#1 ; add one 8BC4 D4 =2 1606 DA A ; adjust 8BC5 FB =2 1607 MOV R3,A ; save in R3 8BC6 22 =2 1608 RET =2 1609 8BC7 =2 1610 PBIN: ; print binary byte value contained in A as 3 decimal chars 8BC7 75F064 =2 1611 MOV B,#100 ; want to divide by 100, just in case 8BCA 84 =2 1612 DIV AB ; do the divide, A has 100s and B has 10/1s 8BCB 2430 =2 1613 ADD A,#'0' ; convert to ascii, show errors 8BCD 129226 =2 1614 CALL PUTCHAR ; print it 8BD0 E5F0 =2 1615 MOV A,B ; put 10s and 1s in A 8BD2 75F00A =2 1616 MOV B,#10 ; want to divide by 10 8BD5 84 =2 1617 DIV AB ; do the divide, A has 10s and B has 1s 8BD6 2430 =2 1618 ADD A,#'0' ; convert to ascii, show errors 8BD8 129226 =2 1619 CALL PUTCHAR ; print it 8BDB E5F0 =2 1620 MOV A,B ; get 1s 8BDD 2430 =2 1621 ADD A,#'0' ; convert to ascii, show errors 8BDF 129226 =2 1622 CALL PUTCHAR ; print it 8BE2 22 =2 1623 RET =2 1624 8BE3 =2 1625 PNBBIT: ; print R6 bytes @R0 as bits, going downward 8BE3 E6 =2 1626 MOV A,@R0 ; get data 8BE4 18 =2 1627 DEC R0 ; pt to next least value 8BE5 12978B =2 1628 CALL PBYTBIT ; print byte as bits 8BE8 1297B5 =2 1629 CALL SPACE2 ; print two space chars 8BEB DEF6 =2 1630 DJNZ R6,PNBBIT ; loop through all 8BED 22 =2 1631 RET =2 1632 8BEE =2 1633 MAPDISP: ; map display of memory 8BEE 12986A =2 1634 CALL PSTNADM ; print station address marker =2 1635 ;;MAPD10: 8BF1 909CA6 =2 1636 MOV DPTR,#MAP0M ; pt to map 0 message 8BF4 12972E =2 1637 CALL CPUTS ; put string to console 8BF7 782F =2 1638 MOV R0,#ADCFLG ; pt to last of status registers 8BF9 7E04 =2 1639 MOV R6,#4 ; number of bytes to show 8BFB 71E3 =2 1640 CALL PNBBIT ; print 4 bytes @R0 as bits, downward 8BFD 909CF9 =2 1641 MOV DPTR,#MAP0MA ; pt to map 0A message 8C00 12972E =2 1642 CALL CPUTS ; put string to console =2 1643 8C03 909D10 =2 1644 MOV DPTR,#MAP1M ; pt to map 1 message 8C06 12972E =2 1645 CALL CPUTS ; put string to console 8C09 7834 =2 1646 MOV R0,#PT4IMG ; pt to last of tx (output) images 8C0B 7E05 =2 1647 MOV R6,#5 ; number of bytes to show 8C0D 71E3 =2 1648 CALL PNBBIT ; print 5 bytes @R0 as bits, downward MC2LDEV MC-2 Development 990419-2.00v PAGE 30 8C0F 909D4B =2 1649 MOV DPTR,#MAP2M ; pt to map 2 message 8C12 12972E =2 1650 CALL CPUTS ; put string to console =2 1651 8C15 909D65 =2 1652 MOV DPTR,#MAP3MA ; pt to map 3a message 8C18 12972E =2 1653 CALL CPUTS ; put string to console 8C1B 7839 =2 1654 MOV R0,#PR4IMG ; pt to last of input images 8C1D 7E05 =2 1655 MOV R6,#5 ; number of bytes to show 8C1F 71E3 =2 1656 CALL PNBBIT ; print 5 bytes @R0 as bits, downward 8C21 909DA0 =2 1657 MOV DPTR,#MAP3M ; pt to map 3 message 8C24 12972E =2 1658 CALL CPUTS ; put string to console 8C27 783E =2 1659 MOV R0,#PR4CIMG ; pt to last of change images 8C29 7E05 =2 1660 MOV R6,#5 ; number of bytes to show 8C2B 71E3 =2 1661 CALL PNBBIT ; print 5 bytes @R0 as bits, downward 8C2D 909DBA =2 1662 MOV DPTR,#MAP4M ; pt to map 4 message 8C30 12972E =2 1663 CALL CPUTS ; put string to console 8C33 758321 =2 1664 MOV DPH,#CCHAN7-RIDX ; pt to 7th counter (w/o rel offset) 8C36 758208 =2 1665 MOV DPL,#8 ; want 8 counters 8C39 AE83 =2 1666 MAPD20: MOV R6,DPH ; move to adr to R6 8C3B 716D =2 1667 CALL GWORD ; get wrd @ R6 (rel) w/o int intf to R4/R5 8C3D 7181 =2 1668 CALL PWRDDEC ; print word in R4,R5 as decimal 8C3F 1583 =2 1669 DEC DPH ; pt to high byte of previous ctr 8C41 1583 =2 1670 DEC DPH ; pt to low byte of previous counter 8C43 1297B8 =2 1671 CALL SPACE1 ; print one space chars 8C46 D582F0 =2 1672 DJNZ DPL,MAPD20 ; loop through all counters 8C49 909E77 =2 1673 MOV DPTR,#MAP5M ; pt to map 5 message 8C4C 12972E =2 1674 CALL CPUTS ; put string to console =2 1675 =2 1676 8C4F 758331 =2 1677 MOV DPH,#ADCH7-RIDX ; pt to 7th ADC reg (w/o rel offset) 8C52 758208 =2 1678 MOV DPL,#8 ; want 8 counters 8C55 AE83 =2 1679 MAPD30: MOV R6,DPH ; move to adr to R6 8C57 716D =2 1680 CALL GWORD ; get wrd @ R6 (rel) w/o int intf to R4/R5 8C59 7181 =2 1681 CALL PWRDDEC ; print word in R4,R5 as decimal 8C5B 1583 =2 1682 DEC DPH ; pt to high byte of previous ctr 8C5D 1583 =2 1683 DEC DPH ; pt to low byte of previous counter 8C5F 1297B8 =2 1684 CALL SPACE1 ; print one space chars 8C62 D582F0 =2 1685 DJNZ DPL,MAPD30 ; loop through all counters 8C65 909E96 =2 1686 MOV DPTR,#MAP6M ; pt to map 5 message 8C68 12972E =2 1687 CALL CPUTS ; put string to console =2 1688 =2 1689 ; MOV R0,#ADCH7 ; pt to 7th A/D =2 1690 ; MOV R7,#8 ; want 8 ADC values =2 1691 ;MAPD30: MOV A,@R0 ; get value =2 1692 ; CALL PBIN ; print bin val in R6 as 3 dec chars =2 1693 ; DEC R0 ; pt to next A/D image, downward =2 1694 ; CALL SPACE2 ; print three space chars =2 1695 ; DJNZ R7,MAPD30 ; loop through all A/D images =2 1696 ; MOV DPTR,#MAP6M ; pt to map 6 message =2 1697 ; CALL CPUTS ; put string to console =2 1698 8C6B 12986A =2 1699 CALL PSTNADM ; print station address marker 8C6E 1297B8 =2 1700 CALL SPACE1 ; print one space chars 8C71 909EB7 =2 1701 MOV DPTR,#MAP7M ; pt to map 7 message 8C74 12972E =2 1702 CALL CPUTS ; put string to console 8C77 22 =2 1703 RET =2 1704 =2 1705 $INCLUDE(CLOCK.ASM) ; clock and timer functions =2 1706 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MC2LDEV MC-2 Development 990419-2.00v PAGE 31 =2 1707 ; +++ CLOCK.ASM =2 1708 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 1709 =2 1710 ; change routines to do all clock buffer stuff via @R0 to =2 1711 ; ensure that if buffer is at/above 080H that it's to/from =2 1712 ; RAM and not SFRs =2 1713 ; 8C78 =2 1714 STIME: ; set time using info on command line 8C78 128DE4 =2 1715 CALL GETCLK ; get clock data to buffer area 8C7B 12937E =2 1716 CALL LBLEN ; get line buffer length to A 8C7E 14 =2 1717 DEC A ; ignore = 8C7F 14 =2 1718 DEC A ; ignore stn address 8C80 14 =2 1719 DEC A ; ignore command char 8C81 7911 =2 1720 MOV R1,#LBUF+3 ; pt to input data, past command 8C83 B4000A =2 1721 CJNE A,#0,STIM20 ; jump if not 0 for display 8C86 12986A =2 1722 STIM10: CALL PSTNADM ; print station address marker 8C89 128E1F =2 1723 CALL PDTSTR ; print date/time string 8C8C 129721 =2 1724 CALL CRLF ; new line 8C8F 22 =2 1725 RET 8C90 B40644 =2 1726 STIM20: CJNE A,#6,STIM30 ; jump if not 6 chars 8C93 128E09 =2 1727 CALL APHEX ; convert ascii pair to hex (year) 8C96 7A00 =2 1728 MOV R2,#0 ; use R2 base year counter 8C98 =2 1729 STIM22: ; calculate base year, to add 2 bits + base 8C98 B40400 =2 1730 CJNE A,#04H,STIM24 ; set CY if A < 4 8C9B 400A =2 1731 STIM24: JC STIM26 ; jump if in 0-3 range 8C9D 2496 =2 1732 ADD A,#96H ; same as subtracting 4 8C9F D4 =2 1733 DA A ; decimal adjust 8CA0 CA =2 1734 XCH A,R2 ; swap them 8CA1 2404 =2 1735 ADD A,#4 ; add 4 to base year counter 8CA3 D4 =2 1736 DA A ; decimal adjust 8CA4 CA =2 1737 XCH A,R2 ; swap them back 8CA5 80F1 =2 1738 JMP STIM22 ; loop till done =2 1739 8CA7 =2 1740 STIM26: ; update year in mem, A has year 0-3, R2 as base (00, 04, 96) 8CA7 C0E0 =2 1741 PUSH ACC ; save A on stack 8CA9 EA =2 1742 MOV A,R2 ; put year offset in A 8CAA 7880 =2 1743 MOV R0,#CLKBUF+16 ; pt to first clock ram 8CAC F6 =2 1744 MOV @R0,A ; save year offset at first clock ram 8CAD D0E0 =2 1745 POP ACC ; restore 0-4 year value to A 8CAF C4 =2 1746 SWAP A ; move year to high nibble 8CB0 23 =2 1747 RL A ; move left 8CB1 23 =2 1748 RL A ; move left 8CB2 54C0 =2 1749 ANL A,#0C0H ; save only two high bits 8CB4 FA =2 1750 MOV R2,A ; save shifted value in R2 8CB5 7875 =2 1751 MOV R0,#CLKBUF+0+5 ; pt to year byte (b+5) 8CB7 E6 =2 1752 MOV A,@R0 ; get year byte from memory 8CB8 543F =2 1753 ANL A,#03FH ; strip off year data 8CBA 4A =2 1754 ORL A,R2 ; or in new value 8CBB F6 =2 1755 MOV @R0,A ; save it back to memory =2 1756 ; now do month 8CBC 128E09 =2 1757 CALL APHEX ; convert ascii pair to hex (month) 8CBF 541F =2 1758 ANL A,#01FH ; save only low 5 bits 8CC1 FA =2 1759 MOV R2,A ; save value in R2 8CC2 08 =2 1760 INC R0 ; pt to month/dow byte (b+6) 8CC3 E6 =2 1761 MOV A,@R0 ; get month/dow byte from memory 8CC4 54E0 =2 1762 ANL A,#0E0H ; save only DOW data 8CC6 4A =2 1763 ORL A,R2 ; or in new value 8CC7 F6 =2 1764 MOV @R0,A ; save it back to memory MC2LDEV MC-2 Development 990419-2.00v PAGE 32 =2 1765 =2 1766 ; now do day 8CC8 128E09 =2 1767 CALL APHEX ; convert ascii pair to hex (day) 8CCB 543F =2 1768 ANL A,#03FH ; save only low 6 bits 8CCD FA =2 1769 MOV R2,A ; save value in R2 8CCE 18 =2 1770 DEC R0 ; pt to year byte (b+5) 8CCF E6 =2 1771 MOV A,@R0 ; get month/dow byte from memory 8CD0 54C0 =2 1772 ANL A,#0C0H ; save only year data 8CD2 4A =2 1773 ORL A,R2 ; or in new value 8CD3 F6 =2 1774 MOV @R0,A ; save it back to memory 8CD4 028D53 =2 1775 JMP STIM98 ; jump to normal end =2 1776 8CD7 B40415 =2 1777 STIM30: CJNE A,#4,STIM40 ; jump if not 4 chars =2 1778 ; now do hour 8CDA 128E09 =2 1779 CALL APHEX ; convert ascii pair to hex (hour) 8CDD 543F =2 1780 ANL A,#03FH ; save only low 6 bits 8CDF FA =2 1781 MOV R2,A ; save value in R2 8CE0 7874 =2 1782 MOV R0,#CLKBUF+0+4 ; pt to hours byte (b+4) 8CE2 E6 =2 1783 MOV A,@R0 ; get hours byte from memory 8CE3 54C0 =2 1784 ANL A,#0C0H ; save only year data 8CE5 4A =2 1785 ORL A,R2 ; or in new value 8CE6 F6 =2 1786 MOV @R0,A ; save it back to memory =2 1787 =2 1788 ; now do min 8CE7 128E09 =2 1789 CALL APHEX ; convert ascii pair to hex (min) 8CEA 18 =2 1790 DEC R0 ; pt to minutes byte (b+3) 8CEB F6 =2 1791 MOV @R0,A ; save it back to memory 8CEC 028D53 =2 1792 JMP STIM98 ; jump to normal end =2 1793 8CEF B4020E =2 1794 STIM40: CJNE A,#2,STIM50 ; jump if not 2 chars =2 1795 ; now do sec 8CF2 128E09 =2 1796 CALL APHEX ; convert ascii pair to hex (sec) 8CF5 7872 =2 1797 MOV R0,#CLKBUF+0+2 ; pt to seconds byte (b+2) 8CF7 F6 =2 1798 MOV @R0,A ; save it back to memory =2 1799 =2 1800 ; clear sub seconds values 8CF8 E4 =2 1801 CLR A ; clear A 8CF9 18 =2 1802 DEC R0 ; pt to hundredths of sec byte (b+1) 8CFA F6 =2 1803 MOV @R0,A ; save at hundredths of sec 8CFB 18 =2 1804 DEC R0 ; pt to control/status byte (b+1) 8CFC F6 =2 1805 MOV @R0,A ; save at control/status reg 8CFD 028D53 =2 1806 JMP STIM98 ; jump to normal end =2 1807 8D00 B40135 =2 1808 STIM50: CJNE A,#1,STIM60 ; jump if not 1 chars =2 1809 ; one argument, if + then inc minute =2 1810 ; if - then dec minute, if 0 then clear seconds 8D03 E7 =2 1811 MOV A,@R1 ; get sub cmd char 8D04 B42B12 =2 1812 CJNE A,#'+',STIM54 ; jump if not minute increment 8D07 7872 =2 1813 MOV R0,#CLKBUF+0+2 ; pt to minutes byte (b+2) 8D09 E6 =2 1814 MOV A,@R0 ; get minutes 8D0A B45905 =2 1815 CJNE A,#059H,STIM52 ; jump if not to be min overflow 8D0D 7600 =2 1816 MOV @R0,#00H ; zero it out 8D0F 028D53 =2 1817 JMP STIM98 ; that's all 8D12 2401 =2 1818 STIM52: ADD A,#01H ; add one 8D14 D4 =2 1819 DA A ; decimal adjust 8D15 F6 =2 1820 MOV @R0,A ; save it 8D16 028D53 =2 1821 JMP STIM98 ; that's all =2 1822 MC2LDEV MC-2 Development 990419-2.00v PAGE 33 8D19 B42D12 =2 1823 STIM54: CJNE A,#'-',STIM57 ; jump if not minute decrement 8D1C 7873 =2 1824 MOV R0,#CLKBUF+0+3 ; pt to minutes byte (b+3) 8D1E E6 =2 1825 MOV A,@R0 ; get minutes 8D1F B40005 =2 1826 CJNE A,#00H,STIM55 ; jump if not to be min underflow 8D22 7659 =2 1827 MOV @R0,#059H ; set to max minutes 8D24 028D53 =2 1828 JMP STIM98 ; that's all 8D27 2499 =2 1829 STIM55: ADD A,#099H ; subtract one (add 99) 8D29 D4 =2 1830 DA A ; decimal adjust 8D2A F6 =2 1831 MOV @R0,A ; save it 8D2B 028D53 =2 1832 JMP STIM98 ; that's all =2 1833 8D2E B43007 =2 1834 STIM57: CJNE A,#'0',STIM60 ; jump if not 0, clear secs 8D31 7872 =2 1835 MOV R0,#CLKBUF+0+2 ; pt to seconds byte (b+2) 8D33 7600 =2 1836 MOV @R0,#0H ; zero seconds 8D35 028D53 =2 1837 JMP STIM98 ; that's all =2 1838 8D38 B43000 =2 1839 STIM60: CJNE A,#'0',STIM61 ; set C if less than 1 8D3B 4020 =2 1840 STIM61: JC STIM99 ; if C then error 8D3D B43A00 =2 1841 CJNE A,#'9'+1,STIM62 ; set C if A is 9 or less 8D40 501B =2 1842 STIM62: JNC STIM99 ; if no C then error =2 1843 ; day of week 8D42 14 =2 1844 DEC A ; change from 1-7 to 0-6 8D43 03 =2 1845 RR A ; rotate right 8D44 03 =2 1846 RR A ; rotate right 8D45 03 =2 1847 RR A ; rotate right 8D46 54E0 =2 1848 ANL A,#0E0H ; keep only 3 MSB 8D48 FA =2 1849 MOV R2,A ; save value in R2 8D49 7876 =2 1850 MOV R0,#CLKBUF+0+6 ; pt to month/dow byte (b+6) 8D4B E6 =2 1851 MOV A,@R0 ; get month/dow byte from memory 8D4C 541F =2 1852 ANL A,#01FH ; strip off dow data 8D4E 4A =2 1853 ORL A,R2 ; or in new value 8D4F F6 =2 1854 MOV @R0,A ; save it back to memory 8D50 028D53 =2 1855 JMP STIM98 ; that's all =2 1856 8D53 128DF9 =2 1857 STIM98: CALL PUTCLK ; put clock data buffer to clock chip 8D56 12986A =2 1858 CALL PSTNADM ; print station address marker 8D59 128E1F =2 1859 CALL PDTSTR ; print date/time string 8D5C 22 =2 1860 RET 8D5D 029893 =2 1861 STIM99: JMP CMDERR ; command error =2 1862 =2 1863 8D60 =2 1864 SALARM: ; set alarm using info on command line 8D60 128DE4 =2 1865 CALL GETCLK ; get clock data to buffer area 8D63 12937E =2 1866 CALL LBLEN ; get line buffer length to A 8D66 14 =2 1867 DEC A ; ignore command char 8D67 790F =2 1868 MOV R1,#LBUF+1 ; pt to input data, past command 8D69 B40007 =2 1869 CJNE A,#0,SALM20 ; jump if not 0 for display 8D6C 128E77 =2 1870 SALM10: CALL PALSTR ; print alarm string 8D6F 129721 =2 1871 CALL CRLF ; new line 8D72 22 =2 1872 RET 8D73 B4061F =2 1873 SALM20: CJNE A,#6,SALM30 ; jump if not 6 chars 8D76 128E09 =2 1874 CALL APHEX ; convert ascii pair to hex (year) =2 1875 ; discard, no YY for alarm =2 1876 ; now do month 8D79 128E09 =2 1877 CALL APHEX ; convert ascii pair to hex (month) 8D7C 541F =2 1878 ANL A,#01FH ; save only low 5 bits 8D7E FA =2 1879 MOV R2,A ; save value in R2 8D7F 787E =2 1880 MOV R0,#CLKBUF+8+6 ; pt to alm month/dow byte (b+8+6) MC2LDEV MC-2 Development 990419-2.00v PAGE 34 8D81 E6 =2 1881 MOV A,@R0 ; get alm month/dow byte from memory 8D82 54E0 =2 1882 ANL A,#0E0H ; save only DOW data 8D84 4A =2 1883 ORL A,R2 ; or in new value 8D85 F6 =2 1884 MOV @R0,A ; save it back to memory =2 1885 =2 1886 ; now do day 8D86 128E09 =2 1887 CALL APHEX ; convert ascii pair to hex (day) 8D89 543F =2 1888 ANL A,#03FH ; save only low 6 bits 8D8B FA =2 1889 MOV R2,A ; save value in R2 8D8C 18 =2 1890 DEC R0 ; pt to alm month/dow byte (b+8+5) 8D8D E6 =2 1891 MOV A,@R0 ; get month/dow byte from memory 8D8E 54C0 =2 1892 ANL A,#0C0H ; save only year data 8D90 4A =2 1893 ORL A,R2 ; or in new value 8D91 F6 =2 1894 MOV @R0,A ; save it back to memory 8D92 028DDA =2 1895 JMP SALM98 ; jump to normal end =2 1896 8D95 B40415 =2 1897 SALM30: CJNE A,#4,SALM40 ; jump if not 4 chars =2 1898 ; now do hour 8D98 128E09 =2 1899 CALL APHEX ; convert ascii pair to hex (hour) 8D9B 543F =2 1900 ANL A,#03FH ; save only low 6 bits 8D9D FA =2 1901 MOV R2,A ; save value in R2 8D9E 787C =2 1902 MOV R0,#CLKBUF+8+4 ; pt to alm hours byte (b+8+4) 8DA0 E6 =2 1903 MOV A,@R0 ; get hours byte from memory 8DA1 54C0 =2 1904 ANL A,#0C0H ; save only year data 8DA3 4A =2 1905 ORL A,R2 ; or in new value 8DA4 F6 =2 1906 MOV @R0,A ; save it back to memory =2 1907 =2 1908 ; now do min 8DA5 128E09 =2 1909 CALL APHEX ; convert ascii pair to hex (min) 8DA8 18 =2 1910 DEC R0 ; pt to alm minutes byte (b+8+3) 8DA9 F6 =2 1911 MOV @R0,A ; save it back to memory 8DAA 028DDA =2 1912 JMP SALM98 ; jump to normal end =2 1913 8DAD B4020C =2 1914 SALM40: CJNE A,#2,SALM50 ; jump if not 2 chars =2 1915 ; now do sec 8DB0 128E09 =2 1916 CALL APHEX ; convert ascii pair to hex (sec) 8DB3 787A =2 1917 MOV R0,#CLKBUF+8+2 ; pt to alm secs byte (b+8+2) 8DB5 F6 =2 1918 MOV @R0,A ; save it back to memory =2 1919 =2 1920 ; clear sub seconds values 8DB6 E4 =2 1921 CLR A ; clear A 8DB7 18 =2 1922 DEC R0 ; pt to alm hundredths byte (b+8+1) 8DB8 F6 =2 1923 MOV @R0,A ; save at hundredths of sec 8DB9 028DDA =2 1924 JMP SALM98 ; jump to normal end =2 1925 =2 1926 8DBC B4050F =2 1927 SALM50: CJNE A,#5,SALM60 ; jump if not 5 chars 8DBF 128E09 =2 1928 CALL APHEX ; convert ascii pair to hex (con/stat) 8DC2 7870 =2 1929 MOV R0,#CLKBUF+0+0 ; pt to control/status byte (b+0+0) 8DC4 F6 =2 1930 MOV @R0,A ; save at control/status 8DC5 128E09 =2 1931 CALL APHEX ; convert ascii pair to hex (alm/con) 8DC8 7878 =2 1932 MOV R0,#CLKBUF+8+0 ; pt to alm control/status byte (b+8+0) 8DCA F6 =2 1933 MOV @R0,A ; save at control/status 8DCB 028DDA =2 1934 JMP SALM98 ; that's all =2 1935 8DCE B40310 =2 1936 SALM60: CJNE A,#3,SALM99 ; jump if not 3 chars 8DD1 128E09 =2 1937 CALL APHEX ; convert ascii pair to hex (con/stat) 8DD4 787E =2 1938 MOV R0,#CLKBUF+8+6 ; pt to alm weekday alm byte (b+8+6) MC2LDEV MC-2 Development 990419-2.00v PAGE 35 8DD6 F6 =2 1939 MOV @R0,A ; save at weekday alarm flag reg 8DD7 028DDA =2 1940 JMP SALM98 ; that's all =2 1941 8DDA 128DF9 =2 1942 SALM98: CALL PUTCLK ; put clock data buffer to clock chip 8DDD 128E77 =2 1943 CALL PALSTR ; print alarm string 8DE0 22 =2 1944 RET 8DE1 029893 =2 1945 SALM99: JMP CMDERR ; command error =2 1946 =2 1947 8DE4 =2 1948 GETCLK: ; get clock data (17 bytes) to buffer area 8DE4 7CA0 =2 1949 MOV R4,#I2CCLK ; slave write address of CLOCK (write) 8DE6 7D00 =2 1950 MOV R5,#000H ; start with location 0 (control word) 8DE8 7E13 =2 1951 MOV R6,#17+2 ; get number of bytes to move 8DEA 7870 =2 1952 MOV R0,#CLKBUF ; pt to buffer 8DEC 75F000 =2 1953 MOV B,#0 ; clear all B bits 8DEF D20C =2 1954 SETB I2CUCW ; I2C Use Control Word (R5) 8DF1 31B5 =2 1955 CALL I2SCW ; I2C send address and control 8DF3 C20C =2 1956 CLR I2CUCW ; do NOT use control word (R5) 8DF5 0C =2 1957 INC R4 ; pt to read slave address 8DF6 3192 =2 1958 CALL I2RSTR ; I2C receive string from device 8DF8 22 =2 1959 RET =2 1960 8DF9 =2 1961 PUTCLK: ; put clock data (17 bytes) from buffer area 8DF9 7CA0 =2 1962 MOV R4,#I2CCLK ; slave write address of CLOCK (write) 8DFB 7D00 =2 1963 MOV R5,#000H ; start with location 0 (control word) 8DFD 7E13 =2 1964 MOV R6,#17+2 ; get number of bytes to move 8DFF 7870 =2 1965 MOV R0,#CLKBUF ; pt to buffer 8E01 75F000 =2 1966 MOV B,#0 ; clear all B bits 8E04 D20C =2 1967 SETB I2CUCW ; I2C Use Control Word (R5) 8E06 31A2 =2 1968 CALL I2TSTR ; I2C transmit string to device 8E08 22 =2 1969 RET =2 1970 8E09 =2 1971 APHEX: ; convert ASCII Pair @R1 to hex value in A 8E09 E7 =2 1972 MOV A,@R1 ; get msb char 8E0A 09 =2 1973 INC R1 ; pt to next char 8E0B 1297D6 =2 1974 CALL CHARHX ; convert to HX 8E0E C4 =2 1975 SWAP A ; move to upper 8E0F FA =2 1976 MOV R2,A ; save in R2 8E10 E7 =2 1977 MOV A,@R1 ; get year msb 8E11 09 =2 1978 INC R1 ; pt to next char 8E12 1297D6 =2 1979 CALL CHARHX ; convert to HX 8E15 4A =2 1980 ORL A,R2 ; or the two together 8E16 22 =2 1981 RET =2 1982 8E17 =2 1983 ASHEX: ; convert ASCII Single @R1 to hex value in A 8E17 E7 =2 1984 MOV A,@R1 ; get msb char 8E18 09 =2 1985 INC R1 ; pt to next char 8E19 1297D6 =2 1986 CALL CHARHX ; convert to HX 8E1C 540F =2 1987 ANL A,#00FH ; only low 4 bits 8E1E 22 =2 1988 RET =2 1989 =2 1990 ;LBLEN: ; line buffer counter, return length of line buffer in A =2 1991 ; MOV R1,#LBUF ; pt to line buffer =2 1992 ; MOV R7,#0 ; clear counter =2 1993 ;LBLE10: MOV A,@R1 ; get a char =2 1994 ; JZ LBLE20 ; jump if end has been found =2 1995 ; INC R7 ; increment the counter =2 1996 ; INC R1 ; increment the pointer MC2LDEV MC-2 Development 990419-2.00v PAGE 36 =2 1997 ; JMP LBLE10 ; loop =2 1998 ;LBLE20: MOV A,R7 ; move data to A =2 1999 ; RET =2 2000 8E1F =2 2001 PDTSTR: ; print date/time string =2 2002 ; first, move clock data to ram buffer 8E1F B1E4 =2 2003 CALL GETCLK ; get clock from buffer area 8E21 7875 =2 2004 MOV R0,#CLKBUF+0+5 ; pt to year byt (b+5) 8E23 E6 =2 2005 MOV A,@R0 ; get year to A 8E24 C4 =2 2006 SWAP A ; move to low nibble 8E25 03 =2 2007 RR A ; rotate right 8E26 03 =2 2008 RR A ; rotate right 8E27 5403 =2 2009 ANL A,#003H ; look only at low 2 bits 8E29 C0E0 =2 2010 PUSH ACC ; save 0-4 year value on stack 8E2B 7880 =2 2011 MOV R0,#CLKBUF+16 ; pt to base year offset (in ram) 8E2D E6 =2 2012 MOV A,@R0 ; get base year offset (from ram) 8E2E FA =2 2013 MOV R2,A ; save in R2 8E2F D0E0 =2 2014 POP ACC ; restore 0-4 year value 8E31 2A =2 2015 ADD A,R2 ; add them 8E32 D4 =2 2016 DA A ; decimal adjust (packed BCD) 8E33 12976E =2 2017 CALL PHXBYTE ; print as byte =2 2018 8E36 7876 =2 2019 MOV R0,#CLKBUF+0+6 ; pt to month byte (b+6) 8E38 E6 =2 2020 MOV A,@R0 ; get months 8E39 541F =2 2021 ANL A,#01FH ; look only at low 5 bits 8E3B 12976E =2 2022 CALL PHXBYTE ; print as byte =2 2023 8E3E 18 =2 2024 DEC R0 ; pt to days (b+5) 8E3F E6 =2 2025 MOV A,@R0 ; get days 8E40 543F =2 2026 ANL A,#03FH ; look only at low 6 bits 8E42 12976E =2 2027 CALL PHXBYTE ; print as byte =2 2028 8E45 742F =2 2029 MOV A,#'/' ; get separator 8E47 129226 =2 2030 CALL PUTCHAR ; print the char =2 2031 8E4A 18 =2 2032 DEC R0 ; pt to days (b+4) 8E4B E6 =2 2033 MOV A,@R0 ; get hours 8E4C 543F =2 2034 ANL A,#03FH ; look only at low 6 bits 8E4E 12976E =2 2035 CALL PHXBYTE ; print as byte =2 2036 =2 2037 8E51 18 =2 2038 DEC R0 ; pt to minutes (b+3) 8E52 E6 =2 2039 MOV A,@R0 ; get minutes 8E53 12976E =2 2040 CALL PHXBYTE ; print as byte =2 2041 8E56 742F =2 2042 MOV A,#'/' ; get separator 8E58 129226 =2 2043 CALL PUTCHAR ; print the char =2 2044 8E5B 18 =2 2045 DEC R0 ; pt to minutes (b+2) 8E5C E6 =2 2046 MOV A,@R0 ; get seconds 8E5D 12976E =2 2047 CALL PHXBYTE ; print as byte =2 2048 8E60 742F =2 2049 MOV A,#'/' ; get separator 8E62 129226 =2 2050 CALL PUTCHAR ; print the char =2 2051 8E65 908EE4 =2 2052 MOV DPTR,#DAYPTR ; pt to day string pointer 8E68 7876 =2 2053 MOV R0,#CLKBUF+0+6 ; pt to month byte (b+6) 8E6A E6 =2 2054 MOV A,@R0 ; get day of week MC2LDEV MC-2 Development 990419-2.00v PAGE 37 8E6B C4 =2 2055 SWAP A ; move to low nibble 8E6C 03 =2 2056 RR A ; rotate right one position 8E6D 5407 =2 2057 ANL A,#007H ; look only at low 3 bits 8E6F FA =2 2058 MOV R2,A ; move value to R2 8E70 128ED8 =2 2059 CALL R2STR ; get "R2th" string 8E73 12972E =2 2060 CALL CPUTS ; print the day of week =2 2061 ;; =2 2062 ;; CALL CRLF ; print newline 8E76 22 =2 2063 RET =2 2064 8E77 =2 2065 PALSTR: ; print alarm string =2 2066 ; XXmmdd/hhmm/ss/weekday/alarmctl 8E77 B1E4 =2 2067 CALL GETCLK ; get clock from buffer area 8E79 7458 =2 2068 MOV A,#'X' ; get an X 8E7B 129226 =2 2069 CALL PUTCHAR ; print X 8E7E 129226 =2 2070 CALL PUTCHAR ; print X, yy has no meaning for alarm =2 2071 8E81 787E =2 2072 MOV R0,#CLKBUF+8+6 ; pt to month byte (b+8+6) 8E83 E6 =2 2073 MOV A,@R0 ; get months 8E84 541F =2 2074 ANL A,#01FH ; look only at low 5 bits 8E86 12976E =2 2075 CALL PHXBYTE ; print as byte =2 2076 8E89 18 =2 2077 DEC R0 ; pt to days bytes (b+8+5) 8E8A E6 =2 2078 MOV A,@R0 ; get days 8E8B 543F =2 2079 ANL A,#03FH ; look only at low 6 bits 8E8D 12976E =2 2080 CALL PHXBYTE ; print as byte =2 2081 8E90 742F =2 2082 MOV A,#'/' ; get separator 8E92 129226 =2 2083 CALL PUTCHAR ; print the char =2 2084 8E95 18 =2 2085 DEC R0 ; pt to days bytes (b+8+4) 8E96 E6 =2 2086 MOV A,@R0 ; get hours 8E97 543F =2 2087 ANL A,#03FH ; look only at low 6 bits 8E99 12976E =2 2088 CALL PHXBYTE ; print as byte =2 2089 8E9C 18 =2 2090 DEC R0 ; pt to days bytes (b+8+3) 8E9D E6 =2 2091 MOV A,@R0 ; get minutes 8E9E 12976E =2 2092 CALL PHXBYTE ; print as byte =2 2093 8EA1 742F =2 2094 MOV A,#'/' ; get separator 8EA3 129226 =2 2095 CALL PUTCHAR ; print the char =2 2096 8EA6 18 =2 2097 DEC R0 ; pt to days bytes (b+8+2) 8EA7 E6 =2 2098 MOV A,@R0 ; get seconds 8EA8 12976E =2 2099 CALL PHXBYTE ; print as byte =2 2100 8EAB 742F =2 2101 MOV A,#'/' ; get separator 8EAD 129226 =2 2102 CALL PUTCHAR ; print the char 8EB0 129226 =2 2103 CALL PUTCHAR ; print the char =2 2104 8EB3 7870 =2 2105 MOV R0,#CLKBUF+0+0 ; pt to con/stat byte (b+0+0) 8EB5 E6 =2 2106 MOV A,@R0 ; get con/stat reg 8EB6 12976E =2 2107 CALL PHXBYTE ; print as byte =2 2108 8EB9 7878 =2 2109 MOV R0,#CLKBUF+8+0 ; pt to alm con/stat byte (b+8+0) 8EBB E6 =2 2110 MOV A,@R0 ; get alarm control reg 8EBC 12976E =2 2111 CALL PHXBYTE ; print as byte =2 2112 MC2LDEV MC-2 Development 990419-2.00v PAGE 38 8EBF 7478 =2 2113 MOV A,#'x' ; get an x 8EC1 129226 =2 2114 CALL PUTCHAR ; print x =2 2115 8EC4 742F =2 2116 MOV A,#'/' ; get separator 8EC6 129226 =2 2117 CALL PUTCHAR ; print the char =2 2118 8EC9 787E =2 2119 MOV R0,#CLKBUF+8+6 ; pt to alm weekday byte (b+8+6) 8ECB E6 =2 2120 MOV A,@R0 ; get weekday alarm flags 8ECC 12976E =2 2121 CALL PHXBYTE ; print as byte =2 2122 8ECF 7478 =2 2123 MOV A,#'x' ; get an x 8ED1 129226 =2 2124 CALL PUTCHAR ; print x =2 2125 8ED4 129721 =2 2126 CALL CRLF ; print newline 8ED7 22 =2 2127 RET =2 2128 8ED8 =2 2129 R2STR: ; pt to the "R2th" string 8ED8 EA =2 2130 MOV A,R2 ; get the count 8ED9 7001 =2 2131 JNZ R2ST10 ; jump if not done 8EDB 22 =2 2132 RET ; stop if zero 8EDC E4 =2 2133 R2ST10: CLR A ; clear A 8EDD 93 =2 2134 MOVC A,@A+DPTR ; get a char 8EDE A3 =2 2135 INC DPTR ; inc the ptr 8EDF 70FB =2 2136 JNZ R2ST10 ; loop till null found 8EE1 DAF9 =2 2137 DJNZ R2,R2ST10 ; loop ti ctr is zero 8EE3 22 =2 2138 RET =2 2139 8EE4 53554E00 =2 2140 DAYPTR: DB 'SUN',ANULL ; 0th day 8EE8 4D4F4E00 =2 2141 DB 'MON',ANULL ; 2nd day 8EEC 54554500 =2 2142 DB 'TUE',ANULL ; 3rd day 8EF0 57454400 =2 2143 DB 'WED',ANULL ; 4th day 8EF4 54485500 =2 2144 DB 'THU',ANULL ; 5th day 8EF8 46524900 =2 2145 DB 'FRI',ANULL ; 6th day 8EFC 53415400 =2 2146 DB 'SAT',ANULL ; 7th day 8F00 FF =2 2147 DB 0FFH ; end of table =2 2148 =2 2149 =2 2150 ;CLKLOOP: ; loop, printing clock and alarm once each second =2 2151 ; ; along with alarm status, terminate on any input =2 2152 ; ; from keyboard =2 2153 ; CALL PDTSTR ; print date string =2 2154 ; CALL PALSTR ; print alarm string =2 2155 ; CALL CRLF =2 2156 ; CALL GETCLK ; get clock from buffer area =2 2157 ; MOV A,CLKBUF+2 ; get clock seconds =2 2158 ; MOV TMP0,A ; save in TMP0 =2 2159 ; =2 2160 ; CALL RBRDY ; CY=1 if char is waiting in receive buffer =2 2161 ; JNC CLKLO20 ; jump if no char waiting =2 2162 ; CALL GETCHAR ; clear the character =2 2163 ; RET =2 2164 ; =2 2165 ;CLKLO20: =2 2166 ; CALL GETCLK ; get clock from buffer area =2 2167 ; MOV A,CLKBUF+2 ; get clock seconds =2 2168 ; XRL A,TMP0 ; see if same =2 2169 ; JZ CLKLO20 ; tight loop if so =2 2170 ; JMP CLKLOOP ; else, big loop MC2LDEV MC-2 Development 990419-2.00v PAGE 39 =2 2171 ; =2 2172 $INCLUDE(CMDPROC.ASM) ; command processing =2 2173 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2174 ; +++ CMDPROC.ASM =2 2175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2176 8F01 =2 2177 CMDPROC: ; get any line input and do command processing if needed 8F01 1292EE =2 2178 CALL GETGP ; get data from console 8F04 4001 =2 2179 JC CMDP05 ; jump if command line finished 8F06 22 =2 2180 RET 8F07 780E =2 2181 CMDP05: MOV R0,#LBUF ; pt to line buffer 8F09 E6 =2 2182 MOV A,@R0 ; get first char 8F0A 643D =2 2183 XRL A,#CMDMRK ; see if command marker 8F0C 6001 =2 2184 JZ CMDP10 ; jump if so 8F0E 22 =2 2185 RET 8F0F E52B =2 2186 CMDP10: MOV A,STNADR ; get station address 8F11 08 =2 2187 INC R0 ; pt to user stn char 8F12 E6 =2 2188 MOV A,@R0 ; get user stn char 8F13 652B =2 2189 XRL A,STNADR ; see if match with station address 8F15 6001 =2 2190 JZ CMDP12 ; jump if so 8F17 22 =2 2191 RET 8F18 200506 =2 2192 CMDP12: JB LGISTAT,CMDP15 ; jump if already logged in 8F1B 200603 =2 2193 JB SYSADMN,CMDP15 ; jump if system administrator 8F1E 02938B =2 2194 JMP LOGIN ; assume login, error if not 8F21 08 =2 2195 CMDP15: INC R0 ; pt to user cmd char 8F22 E6 =2 2196 MOV A,@R0 ; get cmd char 8F23 08 =2 2197 INC R0 ; pt to user char after cmd char 8F24 B45302 =2 2198 CJNE A,#'S',CMDP20 ; jump if not bit SET command 8F27 419C =2 2199 JMP BITSET ; do bit SET command 8F29 B44302 =2 2200 CMDP20: CJNE A,#'C',CMDP22 ; jump if not bit CLR command 8F2C 41B7 =2 2201 JMP BITCLR ; do bit CLR command 8F2E B44402 =2 2202 CMDP22: CJNE A,#'D',CMDP24 ; jump if not bit DISPLAY command 8F31 416A =2 2203 JMP BITDSP ; do bit DISPLAY command 8F33 B45203 =2 2204 CMDP24: CJNE A,#'R',CMDP26 ; jump if not READ command 8F36 028F91 =2 2205 JMP RDCMD ; do READ command 8F39 B45703 =2 2206 CMDP26: CJNE A,#'W',CMDP28 ; jump if not WRITE command 8F3C 028FA5 =2 2207 JMP WRCMD ; do WRITE command 8F3F B44806 =2 2208 CMDP28: CJNE A,#'H',CMDP30 ; jump if not HELP command 8F42 909971 =2 2209 MOV DPTR,#HELPMSG ; pt to HELP message 8F45 02972E =2 2210 JMP CPUTS ; put string to console 8F48 B44D02 =2 2211 CMDP30: CJNE A,#'M',CMDP32 ; jump if not MAP command 8F4B 61EE =2 2212 JMP MAPDISP ; show MAP of memory 8F4D B45402 =2 2213 CMDP32: CJNE A,#'T',CMDP34 ; jump if not TIME command 8F50 8178 =2 2214 JMP STIME ; set or show TIME 8F52 B45603 =2 2215 CMDP34: CJNE A,#'V',CMDP36 ; jump if not VERSION command 8F55 029714 =2 2216 JMP SIGNON ; do VERSION function 8F58 B45A10 =2 2217 CMDP36: CJNE A,#'Z',CMDP38 ; jump if not ZAP change memory command 8F5B 753A00 =2 2218 MOV PR0CIMG,#0 ; clear PR0 change flag image 8F5E 753B00 =2 2219 MOV PR1CIMG,#0 ; clear PR1 change flag image 8F61 753C00 =2 2220 MOV PR2CIMG,#0 ; clear PR2 change flag image 8F64 753D00 =2 2221 MOV PR3CIMG,#0 ; clear PR3 change flag image 8F67 753E00 =2 2222 MOV PR4CIMG,#0 ; clear PR4 change flag image 8F6A 22 =2 2223 RET ; that's all 8F6B B44503 =2 2224 CMDP38: CJNE A,#'E',CMDP40 ; jump if not EEPROM command 8F6E 028FB4 =2 2225 JMP EECOMND ; do EEPROM command 8F71 B45803 =2 2226 CMDP40: CJNE A,#'X',CMDP42 ; jump if not test command 8F74 029954 =2 2227 JMP CKSTACK ; do check stack command 8F77 B44C03 =2 2228 CMDP42: CJNE A,#'L',CMDP44 ; jump if not login/logout wanted MC2LDEV MC-2 Development 990419-2.00v PAGE 40 8F7A 029391 =2 2229 JMP LOGI10 ; jump to login/logout routine 8F7D B44603 =2 2230 CMDP44: CJNE A,#'F',CMDP46 ; jump if not fast load 8F80 02900C =2 2231 JMP FLOAD ; fast load (upload/download) 8F83 B44102 =2 2232 CMDP46: CJNE A,#'A',CMDP48 ; jump if not set alarm 8F86 A160 =2 2233 JMP SALARM ; set alarm 8F88 B44F03 =2 2234 CMDP48: CJNE A,#'O',CMDP50 ; jump if not options 8F8B 0290D2 =2 2235 JMP OPTION ; set options 8F8E 029893 =2 2236 CMDP50: JMP CMDERR ; print error and return =2 2237 8F91 =2 2238 RDCMD: ; do read command 8F91 E6 =2 2239 MOV A,@R0 ; get next char 8F92 08 =2 2240 INC R0 ; pt++ 8F93 B44202 =2 2241 CJNE A,#'B',RDCM10 ; jump if not bit read command 8F96 416A =2 2242 JMP BITDSP ; do bit display command 8F98 B45902 =2 2243 RDCM10: CJNE A,#'Y',RDCM20 ; jump if not byte read command 8F9B 41F8 =2 2244 JMP BYTDSP ; do byte display command 8F9D B45702 =2 2245 RDCM20: CJNE A,#'W',RDCM30 ; jump if not word read command 8FA0 6137 =2 2246 JMP WRDDSP ; do word display command 8FA2 029893 =2 2247 RDCM30: JMP CMDERR ; print error and return =2 2248 8FA5 =2 2249 WRCMD: ; do write command 8FA5 E6 =2 2250 MOV A,@R0 ; get next char 8FA6 08 =2 2251 INC R0 ; pt++ 8FA7 B44202 =2 2252 CJNE A,#'B',WRCM10 ; jump if not bit read command 8FAA 41D3 =2 2253 JMP BITWR ; do bit write command 8FAC B45902 =2 2254 WRCM10: CJNE A,#'Y',WRCM20 ; jump if not byte read command 8FAF 6127 =2 2255 JMP BYTWR ; do byte write command 8FB1 029893 =2 2256 WRCM20: JMP CMDERR ; print error and return =2 2257 8FB4 =2 2258 EECOMND: ; do EEPROM command 8FB4 E6 =2 2259 MOV A,@R0 ; get subcommand char 8FB5 08 =2 2260 INC R0 ; pt++ 8FB6 B4570B =2 2261 CJNE A,#'W',EECO10 ; jump if not EEPROM WRITE command 8FB9 5133 =2 2262 CALL VALRAM ; make cksum correct 8FBB C2AF =2 2263 CLR IE.7 ; disable all ints during EEPROM r/w 8FBD 3150 =2 2264 CALL EEWRBK ; do write command 8FBF D2AF =2 2265 SETB IE.7 ; re-inable all interrupts 8FC1 028FC7 =2 2266 JMP EECO20 ; and do read with test 8FC4 B4521B =2 2267 EECO10: CJNE A,#'R',EECO40 ; jump if not EEPROM READ command 8FC7 =2 2268 EECO20: 8FC7 C0A8 =2 2269 PUSH IE ; save IE regsiter on stack 8FC9 C2AF =2 2270 CLR EA ; disable all ints during EEPROM read 8FCB 312C =2 2271 CALL EERDBK ; read in block of data 8FCD D0A8 =2 2272 POP IE ; restore IE state from stack 8FCF 5138 =2 2273 CALL RAMV ; see if RAM is valid 8FD1 6005 =2 2274 JZ EECO30 ; jump if OK 8FD3 514A =2 2275 CALL DEFAULT ; if not better get defaults 8FD5 0298FE =2 2276 JMP EEPDERR ; do EEPROM data failure msg and return 8FD8 908FF4 =2 2277 EECO30: MOV DPTR,#EECO95 ; pt to GOOD msg 8FDB 12986A =2 2278 CALL PSTNADM ; print address marker 8FDE 12972E =2 2279 CALL CPUTS ; output the message 8FE1 22 =2 2280 RET 8FE2 B4440C =2 2281 EECO40: CJNE A,#'D',EECO50 ; jump if not EEPROM Default command 8FE5 200603 =2 2282 JB SYSADMN,EECO45 ; jump if system administrator 8FE8 029923 =2 2283 JMP SYSAERR ; not system administrator error msg 8FEB 514A =2 2284 EECO45: CALL DEFAULT ; load default values to memory 8FED 12987D =2 2285 CALL CMDOK ; print command OK message 8FF0 22 =2 2286 RET ; that's all MC2LDEV MC-2 Development 990419-2.00v PAGE 41 8FF1 029893 =2 2287 EECO50: JMP CMDERR ; print error and return 8FF4 20454550 =2 2288 EECO95: DB ' EEPROM WRITE/READ OK'; OK msg 8FF8 524F4D20 8FFC 57524954 9000 452F5245 9004 4144204F 9008 4B 9009 0D0A =2 2289 DB ACR,ALF 900B 00 =2 2290 DB ANULL =2 2291 900C =2 2292 FLOAD: ; fast load (upload/download) 900C E6 =2 2293 MOV A,@R0 ; get subcommand char 900D 08 =2 2294 INC R0 ; pt++ 900E B45557 =2 2295 CJNE A,#'U',FLOA50 ; jump if not upload command 9011 E6 =2 2296 MOV A,@R0 ; get block ID 9012 5407 =2 2297 ANL A,#007H ; convert to octal 9014 B40007 =2 2298 CJNE A,#0,FLOA10 ; jump if not block 0 9017 782C =2 2299 MOV R0,#OSTAT0 ; pt to start of open memory 9019 7A31 =2 2300 MOV R2,#49 ; want to write all 49 bytes 901B 029043 =2 2301 JMP FLOA35 ; jump to dump 901E B40107 =2 2302 FLOA10: CJNE A,#1,FLOA12 ; jump if not block 1 9021 782C =2 2303 MOV R0,#OSTAT0 ; pt to start open memory 9023 7A09 =2 2304 MOV R2,#9 ; want to write 9 bytes 9025 029043 =2 2305 JMP FLOA35 ; jump to dump 9028 B40207 =2 2306 FLOA12: CJNE A,#2,FLOA15 ; jump if not block 2 902B 7835 =2 2307 MOV R0,#PR0IMG ; pt to 1st byte of input regs 902D 7A0A =2 2308 MOV R2,#10 ; want to write 10 bytes 902F 029043 =2 2309 JMP FLOA35 ; jump to dump 9032 B40307 =2 2310 FLOA15: CJNE A,#3,FLOA20 ; jump if not block 3 9035 783F =2 2311 MOV R0,#CCHAN0 ; pt to 1st byte of counter regs 9037 7A10 =2 2312 MOV R2,#16 ; want to write 16 bytes 9039 029043 =2 2313 JMP FLOA35 ; jump to dump 903C B40426 =2 2314 FLOA20: CJNE A,#4,FLOA49 ; jump if not block 4 903F 784F =2 2315 MOV R0,#ADCH0 ; pt to 1st byte of A/D regs 9041 7A10 =2 2316 MOV R2,#16 ; want to write 16 bytes 9043 12986A =2 2317 FLOA35: CALL PSTNADM ; print station address mark 9046 7428 =2 2318 FLOA37: MOV A,#'(' ; get start of record marker 9048 129226 =2 2319 CALL PUTCHAR ; print marker 904B 7B00 =2 2320 MOV R3,#0 ; clear check sum 904D E6 =2 2321 FLOA40: MOV A,@R0 ; get byte of memory 904E 12976E =2 2322 CALL PHXBYTE ; print as byte 9051 E6 =2 2323 MOV A,@R0 ; get byte again 9052 04 =2 2324 INC A ; add one to it 9053 2B =2 2325 ADD A,R3 ; add check sum value 9054 FB =2 2326 MOV R3,A ; and save it 9055 08 =2 2327 INC R0 ; pt to next 9056 DAF5 =2 2328 DJNZ R2,FLOA40 ; loop till all are done 9058 EB =2 2329 MOV A,R3 ; get check sum value 9059 12976E =2 2330 CALL PHXBYTE ; print as byte 905C 7429 =2 2331 MOV A,#')' ; get end of record marker 905E 129226 =2 2332 CALL PUTCHAR ; print marker 9061 129721 =2 2333 CALL CRLF ; print new line 9064 22 =2 2334 RET ; that's all 9065 029893 =2 2335 FLOA49: JMP CMDERR ; vector to command error 9068 B444FA =2 2336 FLOA50: CJNE A,#'D',FLOA49 ; jump if not download command 906B 782C =2 2337 MOV R0,#OSTAT0 ; pt to start of user memory 906D 7C00 =2 2338 MOV R4,#0 ; zero byte counter 906F 129219 =2 2339 FLOA60: CALL GETCHAR ; get 1st copy of high nibble MC2LDEV MC-2 Development 990419-2.00v PAGE 42 9072 129810 =2 2340 CALL EPUTC ; echo it (if wanted) 9075 1297D6 =2 2341 CALL CHARHX ; convert to hex 9078 503C =2 2342 JNC FLOA70 ; jump if not hex char 907A FA =2 2343 MOV R2,A ; save in R2 907B 129219 =2 2344 CALL GETCHAR ; get 2nd copy of high nibble 907E 129810 =2 2345 CALL EPUTC ; echo it (if wanted) 9081 1297D6 =2 2346 CALL CHARHX ; convert to hex 9084 5030 =2 2347 JNC FLOA70 ; jump if not hex char 9086 6A =2 2348 XRL A,R2 ; see if same 9087 702D =2 2349 JNZ FLOA70 ; jump if not matched 9089 129219 =2 2350 CALL GETCHAR ; get 1st copy of low nibble 908C 129810 =2 2351 CALL EPUTC ; echo it (if wanted) 908F 1297D6 =2 2352 CALL CHARHX ; convert to hex 9092 5022 =2 2353 JNC FLOA70 ; jump if not hex char 9094 FB =2 2354 MOV R3,A ; save in R3 9095 129219 =2 2355 CALL GETCHAR ; get 2nd copy of low nibble 9098 129810 =2 2356 CALL EPUTC ; echo it (if wanted) 909B 1297D6 =2 2357 CALL CHARHX ; convert to hex 909E 5016 =2 2358 JNC FLOA70 ; jump if not hex char 90A0 6B =2 2359 XRL A,R3 ; see if same 90A1 7013 =2 2360 JNZ FLOA70 ; jump if not matched 90A3 EA =2 2361 MOV A,R2 ; get high nibble 90A4 C4 =2 2362 SWAP A ; move to high nibble of A 90A5 4B =2 2363 ORL A,R3 ; or in low nibble 90A6 FB =2 2364 MOV R3,A ; save in R3 90A7 E8 =2 2365 MOV A,R0 ; get address 90A8 24D4 =2 2366 ADD A,#256-RIDX ; relative to RIDX 90AA FE =2 2367 MOV R6,A ; save in R6 90AB 12984A =2 2368 CALL ADRCK ; address check 90AE 5006 =2 2369 JNC FLOA70 ; jump if address out of range 90B0 EB =2 2370 MOV A,R3 ; recover data 90B1 F6 =2 2371 MOV @R0,A ; save to memory 90B2 08 =2 2372 INC R0 ; pt to next memory 90B3 0C =2 2373 INC R4 ; inc good byte counter 90B4 80B9 =2 2374 JMP FLOA60 ; continue until bad char 90B6 129721 =2 2375 FLOA70: CALL CRLF ; move to new line 90B9 12986A =2 2376 CALL PSTNADM ; print station address mark 90BC 9090CA =2 2377 MOV DPTR,#FLOA75 ; pt to message 90BF 12972E =2 2378 CALL CPUTS ; print it 90C2 EC =2 2379 MOV A,R4 ; get number of bytes saved 90C3 12976E =2 2380 CALL PHXBYTE ; print as hex value 90C6 129721 =2 2381 CALL CRLF ; newline 90C9 22 =2 2382 RET ; that's all 90CA 4C4F4144 =2 2383 FLOA75: DB 'LOADED-' 90CE 45442D 90D1 00 =2 2384 DB ANULL =2 2385 =2 2386 90D2 =2 2387 OPTION: ; set options =2 2388 ; option B for baud =2 2389 ; =sOB0 110, =sOB1 300, =sOB2 1200, =sOB3 2400, =sOB4 4800 =2 2390 ; =sOB5 9600, =sOB6 19200, =sOB7 38400 =2 2391 ; option M for mode =2 2392 ; =sOM0 direct, =sOM1 packet, =sOM2 modem 90D2 200605 =2 2393 JB SYSADMN,OPTI10 ; jump if system administrator 90D5 129923 =2 2394 CALL SYSAERR ; not system administrator error msg 90D8 C3 =2 2395 CLR C ; show bad, just in case 90D9 22 =2 2396 RET MC2LDEV MC-2 Development 990419-2.00v PAGE 43 90DA E6 =2 2397 OPTI10: MOV A,@R0 ; get subcommand char (type of option) 90DB 08 =2 2398 INC R0 ; pt++ 90DC B44212 =2 2399 CJNE A,#'B',OPTI30 ; jump if not baud option 90DF E6 =2 2400 MOV A,@R0 ; get index value 90E0 5407 =2 2401 ANL A,#007H ; convert to octal 90E2 FA =2 2402 MOV R2,A ; save in R2 90E3 E525 =2 2403 MOV A,RSTAT0 ; get status reg 90E5 54F8 =2 2404 ANL A,#0F8H ; strip off low bits 90E7 4A =2 2405 ORL A,R2 ; or in new baud rate status bits 90E8 F525 =2 2406 MOV RSTAT0,A ; save back 90EA 909EF9 =2 2407 MOV DPTR,#OKM ; pt to OK message 90ED 12972E =2 2408 CALL CPUTS ; print it 90F0 22 =2 2409 RET 90F1 B44D2E =2 2410 OPTI30: CJNE A,#'M',OPTI99 ; jump if not mode option 90F4 E6 =2 2411 MOV A,@R0 ; get index value 90F5 5407 =2 2412 ANL A,#007H ; convert to octal 90F7 B40009 =2 2413 CJNE A,#0,OPTI32 ; jump if not 0 (direct connection) 90FA C22C =2 2414 CLR ADIS ; clear auto disconnect (no auto disc) 90FC C22D =2 2415 CLR NECHO ; clear no echo (echo on) 90FE C22E =2 2416 CLR NLF ; clear no lf (lf on) 9100 02911B =2 2417 JMP OPTI98 ; jump OK when done 9103 B40109 =2 2418 OPTI32: CJNE A,#1,OPTI34 ; jump if not 1 (packet connection) 9106 D22C =2 2419 SETB ADIS ; set auto disconnect (auto disc) 9108 D22D =2 2420 SETB NECHO ; set no echo (echo off) 910A D22E =2 2421 SETB NLF ; set no lf (lf off) 910C 02911B =2 2422 JMP OPTI98 ; jump OK when done 910F B40210 =2 2423 OPTI34: CJNE A,#2,OPTI99 ; jump if not 2 (modem connection) 9112 D22C =2 2424 SETB ADIS ; set auto disconnect (auto disc) 9114 C22D =2 2425 CLR NECHO ; clear no echo (echo on) 9116 C22E =2 2426 CLR NLF ; clear no lf (lf on) 9118 02911B =2 2427 JMP OPTI98 ; jump OK when done 911B 909EF9 =2 2428 OPTI98: MOV DPTR,#OKM ; pt to OK message 911E 12972E =2 2429 CALL CPUTS ; print it 9121 22 =2 2430 RET 9122 029893 =2 2431 OPTI99: JMP CMDERR ; vector to command error =2 2432 $INCLUDE(INTRPT.ASM) ; interupt processing =2 2433 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2434 ; +++ INTRPT.ASM =2 2435 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2436 =2 2437 9125 =2 2438 INTRPT: ; come here for main interrupt driver, 36 times per 10 mS =2 2439 ; !!!!!! =2 2440 ; !!!!!! =2 2441 ; !!!!!! THIS SYSTEM USES A RAM ALLOCATION THAT ASSUMES =2 2442 ; !!!!!! THE INTERRUPT ROUTINE ONLY USES REGISTERS R0-R3 =2 2443 ; !!!!!! OF RB1 AND ACC. SO DON'T ADD ANYTHING IN THE =2 2444 ; !!!!!! INTERRUPT ROUTINE THAT USES ANY REGISTERS OTHER =2 2445 ; !!!!!! THAN JUST ACC AND R0-R3 OF RB1 WITHOUT CHANGING =2 2446 ; !!!!!! THE RAM ALLOCATIONS =2 2447 ; !!!!!! =2 2448 ; !!!!!! =2 2449 9125 C0D0 =2 2450 PUSH PSW ; save PSW on stack 9127 C0E0 =2 2451 PUSH ACC ; save ACC on stack 9129 C082 =2 2452 PUSH DPL ; save DPTR low 912B C083 =2 2453 PUSH DPH ; save DPTR high 912D 75D008 =2 2454 MOV PSW,#RB1 ; switch to register bank 1 MC2LDEV MC-2 Development 990419-2.00v PAGE 44 =2 2455 =2 2456 ; interupt processing is below this line, come here 36 times per 10mS =2 2457 =2 2458 9130 051A =2 2459 INTR20: INC TCTR ; increment the tic counter (36 per 10mS) 9132 E51A =2 2460 MOV A,TCTR ; get tic counter 9134 B4243C =2 2461 CJNE A,#36,INTR70 ; jump if not overflow, no other proc 9137 751A00 =2 2462 MOV TCTR,#0 ; clear tic counter (new 10 mS) 913A D207 =2 2463 SETB WDTFLG ; SET watch dog timer flag 913C E51C =2 2464 MOV A,ISEC ; see if unmarked seconds 913E 6007 =2 2465 JZ INTR30 ; jump if not 9140 200204 =2 2466 JB NCSEC,INTR30 ; jump if clock hasn't yet found flag 9143 D202 =2 2467 SETB NCSEC ; mark new second for clock 9145 151C =2 2468 DEC ISEC ; one less count in bucket 9147 E51B =2 2469 INTR30: MOV A,MS10CTR ; get the 10 ms counter 9149 2401 =2 2470 ADD A,#1 ; add one to it 914B D4 =2 2471 DA A ; make it a packed BCD number 914C F51B =2 2472 MOV MS10CTR,A ; save it again 914E 500D =2 2473 JNC INTR50 ; jump if not second overflow 9150 751B00 =2 2474 MOV MS10CTR,#0 ; clear the counter =2 2475 ; if here then a new second has occurred 9153 12917C =2 2476 CALL DOFCTR ; do frequency counter every new second 9156 051C =2 2477 INC ISEC ; increment seconds counter 9158 D203 =2 2478 SETB WUDIO ; always do update i/o on new second 915A 029167 =2 2479 JMP INTR60 ; jump to end 915D 540F =2 2480 INTR50: ANL A,#00FH ; look only at low nibble 915F B40005 =2 2481 CJNE A,#00H,INTR60 ; jump if not 100 mS increment value 9162 306202 =2 2482 JNB FSR,INTR60 ; jump if fast sample rate not wanted 9165 D203 =2 2483 SETB WUDIO ; do update i/o on new 100 milli-second 9167 E51B =2 2484 INTR60: MOV A,MS10CTR ; get 10 mS counter (packed BCD) 9169 A2E1 =2 2485 MOV C,ACC.1 ; get bit 1 to C 916B 92B5 =2 2486 MOV T1,C ; output to T1, makes T1 25 Hz 916D 20E003 =2 2487 JB ACC.0,INTR70 ; skip if even (i.e. even 20 mS increment) 9170 1291B0 =2 2488 CALL PULCTR ; do pulse counter function 9173 =2 2489 INTR70: ; that's all =2 2490 ; interupt processing is above this line 9173 D083 =2 2491 POP DPH ; restore DPTR high 9175 D082 =2 2492 POP DPL ; restore DPTR low 9177 D0E0 =2 2493 POP ACC ; restore ACC from stack 9179 D0D0 =2 2494 POP PSW ; restore PSW from stack 917B 32 =2 2495 RETI =2 2496 917C =2 2497 DOFCTR: ; do frequency counter every new second, interrrupt driven =2 2498 ; first, see if pulse count wanted instead 917C A81E =2 2499 MOV R0,CTRCHAN ; get counter channel 917E 08 =2 2500 INC R0 ; increment 917F E52D =2 2501 MOV A,PULFLG ; get pulse counter flag bits 9181 13 =2 2502 DOFC10: RRC A ; rotate right into CY 9182 D8FD =2 2503 DJNZ R0,DOFC10 ; until channel bit is in CY 9184 400F =2 2504 JC DOFC20 ; don't freq, pulse count wanted instead =2 2505 ; get freq count data and move to memory 9186 E51E =2 2506 MOV A,CTRCHAN ; get counter channel 9188 25E0 =2 2507 ADD A,ACC ; double channel number 918A 243F =2 2508 ADD A,#CCHAN0 ; add in address of counter channel 0 918C F8 =2 2509 MOV R0,A ; move index to R0 918D C28E =2 2510 CLR TR1 ; stop counter where it is 918F A68B =2 2511 MOV @R0,TL1 ; move low byte of counter to memory 9191 08 =2 2512 INC R0 ; pt to high byte MC2LDEV MC-2 Development 990419-2.00v PAGE 45 9192 E58D =2 2513 MOV A,TH1 ; move high byte of counter to A 9194 F6 =2 2514 MOV @R0,A ; move masked high byte of ctr to memory 9195 051E =2 2515 DOFC20: INC CTRCHAN ; increment counter channel 9197 E51E =2 2516 MOV A,CTRCHAN ; get it 9199 B40803 =2 2517 CJNE A,#8,DOFC30 ; jump if not overflow value 919C 751E00 =2 2518 MOV CTRCHAN,#0 ; reset counter channel to zero 919F 74F8 =2 2519 DOFC30: MOV A,#0F8H ; get mask for P1 91A1 5290 =2 2520 ANL P1,A ; ensure channel bits are all off 91A3 E51E =2 2521 MOV A,CTRCHAN ; get channel number 91A5 4290 =2 2522 ORL P1,A ; or into port 91A7 758B00 =2 2523 MOV TL1,#0 ; clear the counter 91AA 758D00 =2 2524 MOV TH1,#0 ; clear the counter 91AD D28E =2 2525 SETB TR1 ; enable counter for next channel 91AF 22 =2 2526 RET ; that's all =2 2527 91B0 =2 2528 PULCTR: ; accumulating pulse counter function 91B0 90F8FD =2 2529 MOV DPTR,#PP1B ; point to 1st 82c55 port B 91B3 E0 =2 2530 MOVX A,@DPTR ; get data from port 91B4 FB =2 2531 MOV R3,A ; save in R3 91B5 656C =2 2532 XRL A,PULOLD ; see what has changed 91B7 8B6C =2 2533 MOV PULOLD,R3 ; save new data in OLD register 91B9 5B =2 2534 ANL A,R3 ; AND change with data input itself 91BA 552D =2 2535 ANL A,PULFLG ; consider only inputs flagged as pulctrs 91BC FB =2 2536 MOV R3,A ; save new pulse counter flag in R3 91BD 783F =2 2537 MOV R0,#CCHAN0 ; move addr of counter channel 0 to R0 91BF 7A08 =2 2538 MOV R2,#8 ; number of bits to check 91C1 EB =2 2539 PULC10: MOV A,R3 ; get new pulse flag from A 91C2 13 =2 2540 RRC A ; move new pulse flag into CY 91C3 FB =2 2541 MOV R3,A ; save new pulse flag into R3 91C4 500D =2 2542 JNC PULC20 ; jump if no carry (i.e., no pulse count) 91C6 E6 =2 2543 MOV A,@R0 ; get low byte 91C7 2401 =2 2544 ADD A,#1 ; add one with flag affected 91C9 F6 =2 2545 MOV @R0,A ; save result in low byte 91CA 08 =2 2546 INC R0 ; increment pointer 91CB E6 =2 2547 MOV A,@R0 ; get high byte 91CC 3400 =2 2548 ADDC A,#0 ; add in carry to high byte 91CE F6 =2 2549 MOV @R0,A ; save result in high byte 91CF 08 =2 2550 INC R0 ; increment pointer 91D0 0291D5 =2 2551 JMP PULC30 ; skip alternate path 91D3 08 =2 2552 PULC20: INC R0 ; no pulse, increment ptr 91D4 08 =2 2553 INC R0 ; no pulse, increment ptr 91D5 DAEA =2 2554 PULC30: DJNZ R2,PULC10 ; loop until all inputs are checked 91D7 22 =2 2555 PULC40: RET =2 2556 $INCLUDE(IO.ASM) ; i/o functions =2 2557 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2558 ; +++ IO.ASM =2 2559 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2560 =2 2561 =2 2562 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2563 ; =2 2564 ; In the METCON-1 system timer 1 was used as the baud rate =2 2565 ; generator and timer 0 was split with T0L providing a counter =2 2566 ; of external events and T0H providing interrupts at 3600i/s =2 2567 ; =2 2568 ; In the METCON-2 system, timer 2 is used for baud rate, =2 2569 ; timer 0 it used for system interrupts and timer 1 is used =2 2570 ; for the frequency counter. Only timer 0 causes an interrupt. MC2LDEV MC-2 Development 990419-2.00v PAGE 46 =2 2571 ; =2 2572 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2573 =2 2574 91D8 =2 2575 INITTI: ; initialize timers & interrupt structure =2 2576 ; timer initialization =2 2577 ; as was done with original METCON, =2 2578 ; timer 0 is system interrupt timer at 3600ints/s =2 2579 ; timer 1 is freq ctr =2 2580 91D8 7400 =2 2581 MOV A,#0 ; clear A 91DA 4402 =2 2582 ORL A,#002H ; timer 0, gate=0, c/t*=0, mode=2 91DC 4450 =2 2583 ORL A,#050H ; timer 1, gate=0, c/t*=1, mode=1 91DE F589 =2 2584 MOV TMOD,A ; save to TMOD =2 2585 =2 2586 ; MOV TL0,#0 ; T0L to zero, for first count 91E0 758C00 =2 2587 MOV TH0,#0 ; T0H to zero, never reload (i.e. /256) 91E3 D28C =2 2588 SETB TR0 ; allow timer T0L to run 91E5 D28E =2 2589 SETB TR1 ; allow timer T0H to run =2 2590 91E7 75B802 =2 2591 MOV IP,#002H ; T0 is highest priority 91EA 75A802 =2 2592 MOV IE,#002H ; prepare to allow T0 to cause ints =2 2593 ; but don't yet enable system ints 91ED 22 =2 2594 RET =2 2595 91EE =2 2596 INITPP: ; init the parallel ports 91EE 90F8FF =2 2597 MOV DPTR,#PP1T ; point to ctl reg of first 82c55 91F1 748A =2 2598 MOV A,#08AH ; control word: Aout, Bin, CLout, CHin 91F3 F0 =2 2599 MOVX @DPTR,A ; move to port 91F4 90F8FC =2 2600 MOV DPTR,#PP1A ; point to A register 91F7 74FF =2 2601 MOV A,#0FFH ; want all outputs off (high) 91F9 F0 =2 2602 MOVX @DPTR,A ; move to port 91FA 22 =2 2603 RET =2 2604 =2 2605 IF (UARTINT) ; if internal UART =2 2606 =2 2607 ;;;;;;;; UART internal to 8051 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2608 =2 2609 91FB =2 2610 INITSP: ; now init the serial port 91FB 759850 =2 2611 MOV SCON,#050H ; mode 1, 8 bits 91FE 438780 =2 2612 ORL PCON,#080H ; set SMOD = 1 9201 75C834 =2 2613 MOV T2CON,#034H ; T2 is baud gen =2 2614 ; at 11.0592 MHz uses the following values for the desired rate =2 2615 ; bps RCAP2H RCAP2L =2 2616 ; 110.........0F3H....0BBH =2 2617 ; 300 0FBH 080H =2 2618 ; 600.........0FDH....0C0H =2 2619 ; 1200 0FEH 0E0H =2 2620 ; 2400.........0FFH....070H =2 2621 ; 4800 0FFH 0B8H =2 2622 ; 9600.........0FFH....0DCH =2 2623 ; 19200 0FFH 0EEH =2 2624 ; 38400........0FFH....0F7H =2 2625 ;; MOV RCAP2H,#0FFH ; FF for rates >= 2400 =2 2626 ; MOV RCAP2L,#0F7H ; reload value 38400 @ 11.0592 MHz =2 2627 ; MOV RCAP2L,#0EEH ; reload value 19200 @ 11.0592 MHz =2 2628 ; MOV RCAP2L,#0DCH ; reload value 9600 @ 11.0592 MHz MC2LDEV MC-2 Development 990419-2.00v PAGE 47 =2 2629 ; MOV RCAP2L,#0B8H ; reload value 4800 @ 11.0592 MHz =2 2630 ; MOV RCAP2L,#070H ; reload value 2400 @ 11.0592 MHz =2 2631 9204 75CBFE =2 2632 MOV RCAP2H,#0FEH ; 1200 high @ 11.0592 MHz 9207 75CAE0 =2 2633 MOV RCAP2L,#0E0H ; 1200 low @ 11.0592 MHz =2 2634 920A D299 =2 2635 SETB TI ; enable transmitter 920C 22 =2 2636 RET =2 2637 =2 2638 ;INITSP: ; now init the serial port assuming timer 1 for baud-rate =2 2639 ; RET ; +++ fix this latter =2 2640 ; MOV A,PCON ; get current PCON value =2 2641 ; SETB ACC.7 ; ensure SMOD is set =2 2642 ; MOV PCON,A ; and restore =2 2643 ; MOV SCON,#052H ; mode 1, 8 bits, TX empty =2 2644 ; RET =2 2645 920D =2 2646 RBRDY: ; CY=1 if char is waiting in receive buffer 920D 129291 =2 2647 CALL WDTTOG ; watch dog timer toggle 9210 A298 =2 2648 MOV C,RI ; move RI to C 9212 22 =2 2649 RET =2 2650 9213 =2 2651 TBRDY: ; CY=1 if TX buffer is ready for next char 9213 129291 =2 2652 CALL WDTTOG ; watch dog timer toggle 9216 A299 =2 2653 MOV C,TI ; move TI to C 9218 22 =2 2654 RET =2 2655 9219 =2 2656 GETCHAR: ; get char from console 9219 129291 =2 2657 CALL WDTTOG ; watch dog timer toggle 921C 3098FA =2 2658 JNB RI,GETCHAR ; loop if RX without data 921F C298 =2 2659 CLR RI ; mark it clear 9221 E599 =2 2660 MOV A,SBUF ; get data from port 9223 547F =2 2661 ANL A,#07FH ; only 7 bits 9225 22 =2 2662 RET ; that's all =2 2663 9226 =2 2664 PUTCHAR: ; put char to console 9226 129291 =2 2665 CALL WDTTOG ; watch dog timer toggle 9229 200603 =2 2666 JB SYSADMN,PUTC05 ; jump if SYSADMN 922C 20140E =2 2667 JB DCD,PUTC20 ; jump if DCD is inactive (high) 922F 3099F4 =2 2668 PUTC05: JNB TI,PUTCHAR ; loop if TX not idle 9232 B40A04 =2 2669 CJNE A,#ALF,PUTC10 ; jump if not line feed 9235 302E01 =2 2670 JNB NLF,PUTC10 ; jump if line feed wanted 9238 22 =2 2671 RET ; that's all 9239 C299 =2 2672 PUTC10: CLR TI ; mark it clear 923B F599 =2 2673 MOV SBUF,A ; save data to port 923D 22 =2 2674 PUTC20: RET ; that's all =2 2675 =2 2676 ELSE ; else assume 8250 at 0xF100 =2 2677 =2 2678 ;;;;;;;; UART using external 8250 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2679 =2 2680 INITSP: ; init the 8250 serial port =2 2681 MOV DPTR,#ACEBAS+3 ; pt to line control register =2 2682 MOV A,#080H ; cmd to access baud rate =2 2683 MOVX @DPTR,A ; open divisor latch =2 2684 MOV DPTR,#ACEBAS+0 ; pt to lsbyte baud rate =2 2685 ;;;; MOV A,#4 ; low BRATE for 9600 @ 3.6864 MHz =2 2686 ;;;; MOV A,#32 ; low BRATE for 1200 @ 3.6864 MHz MC2LDEV MC-2 Development 990419-2.00v PAGE 48 =2 2687 ;;;; MOV A,#96 ; low BRATE for 1200 @ 11.0592 MHz =2 2688 ;;;; MOV A,#12 ; low BRATE for 9600 @ 11.0592 MHz =2 2689 MOV A,#6 ; low BRATE for 19200 @ 11.0592 MHz =2 2690 MOVX @DPTR,A ; move to port =2 2691 INC DPTR ; pt to msbyte baud rate =2 2692 MOV A,#0 ; get baud rate value high =2 2693 MOVX @DPTR,A ; move to port =2 2694 INC DPTR ; tp to int reg =2 2695 INC DPTR ; pt to line control reg =2 2696 MOV A,#003H ; 8 bits, 1 stp, no parity =2 2697 MOVX @DPTR,A ; move to port =2 2698 RET =2 2699 =2 2700 GETCHAR; ; console input =2 2701 CALL WDTTOG ; watch dog timer toggle =2 2702 PUSH DPL ; save DPTR on stack =2 2703 PUSH DPH =2 2704 MOV DPTR,#ACEBAS+5 ; pt to status register =2 2705 GETC10: MOVX A,@DPTR ; get status =2 2706 JNB ACC.0,GETC10 ; loop until data is waiting =2 2707 MOV DPTR,#ACEBAS+0 ; pt to data register =2 2708 MOVX A,@DPTR ; get data =2 2709 ANL A,#07FH ; only 7 bits =2 2710 POP DPH =2 2711 POP DPL ; restore DPTR from stack =2 2712 RET =2 2713 =2 2714 PUTCHAR: ; console output =2 2715 CALL WDTTOG ; watch dog timer toggle =2 2716 PUSH DPL ; save DPTR on stack =2 2717 PUSH DPH =2 2718 PUSH ACC ; save char on stack =2 2719 MOV DPTR,#ACEBAS+5 ; pt to status register =2 2720 PUTC10: MOVX A,@DPTR ; get status =2 2721 JNB ACC.5,PUTC10 ; loop until data is waiting =2 2722 POP ACC ; get data from stack =2 2723 CJNE A,#ALF,PUTC20 ; jump if not line feed =2 2724 JNB NLF,PUTC20 ; jump if line feed wanted =2 2725 JMP PUTC30 ; that's all =2 2726 PUTC20: MOV DPTR,#ACEBAS+0 ; pt to data register =2 2727 PUSH ACC ; save data on stack =2 2728 MOV C,UARTD7 ; get user specified D7 for UART =2 2729 MOV ACC.7,C ; move to D7 of ACC =2 2730 MOVX @DPTR,A ; move data =2 2731 POP ACC ; restore data =2 2732 PUTC30: POP DPH =2 2733 POP DPL ; restore DPTR from stack =2 2734 RET =2 2735 =2 2736 RBRDY: ; if char waiting return CY == 1 =2 2737 CALL WDTTOG ; watch dog timer toggle =2 2738 PUSH DPL ; save DPTR on stack =2 2739 PUSH DPH =2 2740 MOV DPTR,#ACEBAS+5 ; pt to status register =2 2741 MOVX A,@DPTR ; get status =2 2742 MOV C,ACC.0 ; set C to 1 if data waiting =2 2743 POP DPH =2 2744 POP DPL ; restore DPTR from stack MC2LDEV MC-2 Development 990419-2.00v PAGE 49 =2 2745 RET =2 2746 =2 2747 TBRDY: ; ret CY = 1 if transmit buffer is ready for data =2 2748 CALL WDTTOG ; watch dog timer toggle =2 2749 PUSH DPL ; save DPTR on stack =2 2750 PUSH DPH =2 2751 MOV DPTR,#ACEBAS+5 ; pt to status register =2 2752 MOVX A,@DPTR ; get status =2 2753 MOV C,ACC.5 ; set C to 1 if tx buffer available =2 2754 POP DPH =2 2755 POP DPL ; restore DPTR from stack =2 2756 RET =2 2757 =2 2758 ENDIF =2 2759 923E =2 2760 IOUPDAT: ; i/o updates done when WUDIO is set (P0, P2, P4, P5, P6) 923E 30030E =2 2761 JNB WUDIO,IOUP10 ; jump if don't want update io 9241 C203 =2 2762 CLR WUDIO ; clear the flag bit 9243 129250 =2 2763 CALL UDPR0 ; update port rx 0 9246 129262 =2 2764 CALL UDPT0 ; update port tx 0 9249 12926D =2 2765 CALL UDPCX ; update port C x (both directions) 924C 129281 =2 2766 CALL UDSYS ; update SYSADMN bit =2 2767 ;+++ CALL DIAGNO ; do diagnostic routine 924F 22 =2 2768 IOUP10: RET ; that's all =2 2769 9250 =2 2770 UDPR0: ; update port rx 0 9250 90F8FD =2 2771 MOV DPTR,#PP1B ; point to 1st 82c55 port B 9253 E0 =2 2772 MOVX A,@DPTR ; get data from port 9254 303001 =2 2773 JNB INVI,UDPR010 ; jump if input invert not wanted 9257 F4 =2 2774 CPL A ; invert it 9258 =2 2775 UDPR010: 9258 F535 =2 2776 MOV PR0IMG,A ; save to port RX 0 image data 925A FF =2 2777 MOV R7,A ; save copy of data in R7 925B 655F =2 2778 XRL A,LDPR0 ; compare with Last Data PR0 925D 423A =2 2779 ORL PR0CIMG,A ; OR in bits to change status image 925F 8F5F =2 2780 MOV LDPR0,R7 ; update LAST value 9261 22 =2 2781 RET =2 2782 9262 =2 2783 UDPT0: ; update port tx 0 (output) 9262 90F8FC =2 2784 MOV DPTR,#PP1A ; point to 1st 82c55 port A 9265 E530 =2 2785 MOV A,PT0IMG ; get port tx 0 image data (output) 9267 203101 =2 2786 JB NINVO,UDPT010 ; jump if no output invert wanted 926A F4 =2 2787 CPL A ; invert it 926B =2 2788 UDPT010: 926B F0 =2 2789 MOVX @DPTR,A ; save it to output 926C 22 =2 2790 RET =2 2791 926D =2 2792 UDPCX: ; update port C x (both directions) 926D E522 =2 2793 MOV A,SF2 ; get Status Flags 2 to A 926F 540F =2 2794 ANL A,#00FH ; consider only low nibble 9271 90F8FE =2 2795 MOV DPTR,#PP1C ; point to 1st 82c55 port C 9274 F0 =2 2796 MOVX @DPTR,A ; save it to output 9275 E0 =2 2797 MOVX A,@DPTR ; get the high byte 9276 54F0 =2 2798 ANL A,#0F0H ; keep only high nibble 9278 FA =2 2799 MOV R2,A ; save in R2 9279 E522 =2 2800 MOV A,SF2 ; get SF2 927B 540F =2 2801 ANL A,#00FH ; keep only low nibble 927D 4A =2 2802 ORL A,R2 ; or them together MC2LDEV MC-2 Development 990419-2.00v PAGE 50 927E F522 =2 2803 MOV SF2,A ; save them 9280 22 =2 2804 RET =2 2805 =2 2806 =2 2807 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2808 ; UDSYS - Update SYSADMN bit based in input from port =2 2809 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2810 ; 9281 =2 2811 UDSYS: ; update SYSADMN bit based in input from port =2 2812 ; first, get whatever is serving as bit input =2 2813 ; for system administrator flag 9281 E535 =2 2814 MOV A,PR0IMG ; port rx 0 image 9283 303001 =2 2815 JNB INVI,UDSY10 ; jump if input invert not wanted 9286 F4 =2 2816 CPL A 9287 5480 =2 2817 UDSY10: ANL A,#080H ; look only at MSB 9289 7003 =2 2818 JNZ UDSY20 ; jump if SYSTEM ADMINISTRATOR 928B C206 =2 2819 CLR SYSADMN ; clear SYSADMN 928D 22 =2 2820 RET 928E D206 =2 2821 UDSY20: SETB SYSADMN ; set SYSADMN 9290 22 =2 2822 RET =2 2823 9291 =2 2824 WDTTOG: ; watch dog timer toggle 9291 100701 =2 2825 JBC WDTFLG,WDTT10 ; jump and clear if watch DT flag (10ms) 9294 22 =2 2826 RET 9295 A293 =2 2827 WDTT10: MOV C,WDT ; get WDT value 9297 B3 =2 2828 CPL C ; compliment it 9298 9293 =2 2829 MOV WDT,C ; save it back 929A 22 =2 2830 RET =2 2831 929B =2 2832 ADCONV: ; get A/D conversion value =2 2833 ; entry: A has command info (LSB sent first) =2 2834 ; R7 has number of bits in A =2 2835 ; exit: A has A/D input value 929B C294 =2 2836 CLR XCLK ; ensure clock is low 929D 1292BE =2 2837 CALL ENADC ; enable ADC 92A0 13 =2 2838 ADCO10: RRC A ; rotate command into CY 92A1 9295 =2 2839 MOV XDOT,C ; move data to output bit 92A3 00 =2 2840 NOP ; kill some time 92A4 00 =2 2841 NOP ; kill some time 92A5 D294 =2 2842 SETB XCLK ; set CK high 92A7 00 =2 2843 NOP ; kill some time 92A8 00 =2 2844 NOP ; kill some time 92A9 C294 =2 2845 CLR XCLK ; set CK low 92AB DFF3 =2 2846 DJNZ R7,ADCO10 ; loop until all command bits output 92AD 7F09 =2 2847 MOV R7,#9 ; input one dummy, then 8 data bits 92AF D294 =2 2848 ADCO20: SETB XCLK ; set CK high 92B1 00 =2 2849 NOP ; kill some time 92B2 00 =2 2850 NOP ; kill some time 92B3 C294 =2 2851 CLR XCLK ; set CK low, data bit now ready 92B5 A2B4 =2 2852 MOV C,ADI ; get data input from A/D chip 92B7 33 =2 2853 RLC A ; rotate left CY into lsb 92B8 DFF5 =2 2854 DJNZ R7,ADCO20 ; loop through all bits 92BA 1292C9 =2 2855 CALL DEADC ; release enable bit for ADC 92BD 22 =2 2856 RET =2 2857 92BE =2 2858 ENADC: ; enable chip select for ADC 92BE C0E0 =2 2859 PUSH ACC ; save A on stack =2 2860 MC2LDEV MC-2 Development 990419-2.00v PAGE 51 =2 2861 ;;; MOV DPTR,#PP1C ; point to C reg =2 2862 ;;; MOV A,#000H ; bit 63 clear to low =2 2863 ;;; MOVX @DPTR,A ; put command to port =2 2864 92C0 90F8FF =2 2865 MOV DPTR,#PP1T ; point to ctl reg of first 82c55 92C3 7406 =2 2866 MOV A,#006H ; bit 6 clear to low 92C5 F0 =2 2867 MOVX @DPTR,A ; put command to port =2 2868 92C6 D0E0 =2 2869 POP ACC ; recover A from stack 92C8 22 =2 2870 RET =2 2871 92C9 =2 2872 DEADC: ; de-enable chip select for ADC 92C9 C0E0 =2 2873 PUSH ACC ; save A on stack =2 2874 =2 2875 ;;; MOV DPTR,#PP1C ; point to C reg =2 2876 ;;; MOV A,#0FFH ; bit 63 set high =2 2877 ;;; MOVX @DPTR,A ; put command to port =2 2878 92CB 90F8FF =2 2879 MOV DPTR,#PP1T ; point to ctl reg of first 82c55 92CE 7407 =2 2880 MOV A,#007H ; bit 6 set high 92D0 F0 =2 2881 MOVX @DPTR,A ; put command to port =2 2882 92D1 D0E0 =2 2883 POP ACC ; recover A from stack 92D3 22 =2 2884 RET =2 2885 92D4 =2 2886 DIAGNO: ; do diagnostic routine 92D4 129721 =2 2887 CALL CRLF ; ensure new line 92D7 A214 =2 2888 MOV C,DCD ; get DCD 92D9 129F6E =2 2889 CALL CDUMP ; print value 92DC E535 =2 2890 MOV A,PR0IMG ; port rx 0 image 92DE 5480 =2 2891 ANL A,#080H ; look only at MSB 92E0 129F5A =2 2892 CALL ADUMP ; print input port image 92E3 A206 =2 2893 MOV C,SYSADMN ; get sysadm flag 92E5 129F6E =2 2894 CALL CDUMP ; print value 92E8 A205 =2 2895 MOV C,LGISTAT ; get login status 92EA 129F6E =2 2896 CALL CDUMP ; print value 92ED 22 =2 2897 RET =2 2898 $INCLUDE(LNPROC.ASM) ; input line processing =2 2899 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2900 ; +++ LNPROC.ASM =2 2901 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 2902 =2 2903 92EE =2 2904 GETGP: ; get a group using non-blocking I/O 92EE 510D =2 2905 CALL RBRDY ; see if char waiting 92F0 4001 =2 2906 JC GETG10 ; jump if so 92F2 22 =2 2907 RET ; ret if no char waiting 92F3 5119 =2 2908 GETG10: CALL GETCHAR ; get the char 92F5 129351 =2 2909 CALL MAPC ; map out most junk 92F8 7002 =2 2910 JNZ GETG20 ; jump if char is valid 92FA C3 =2 2911 CLR C ; mark line not done 92FB 22 =2 2912 RET ; return if null or undesirable 92FC AA0C =2 2913 GETG20: MOV R2,LBUFC ; get line buffer counter 92FE A80D =2 2914 MOV R0,LBUFP ; get line buffer pointer 9300 B4081C =2 2915 CJNE A,#ABSP,GETG50 ; jump if char not backspace 9303 E50C =2 2916 MOV A,LBUFC ; else get line buffer count 9305 B40002 =2 2917 CJNE A,#0,GETG30 ; jump if not null 9308 C3 =2 2918 CLR C ; mark line not done MC2LDEV MC-2 Development 990419-2.00v PAGE 52 9309 22 =2 2919 RET ; that's all 930A 7408 =2 2920 GETG30: MOV A,#ABSP ; else echo BS-SP-BS; get BS 930C 129810 =2 2921 CALL EPUTC ; and echo it (if wanted) 930F 7420 =2 2922 MOV A,#ASP ; get SPACE 9311 129810 =2 2923 CALL EPUTC ; and echo it (if wanted) 9314 7408 =2 2924 MOV A,#ABSP ; get BS 9316 129810 =2 2925 CALL EPUTC ; and echo it (if wanted) 9319 150C =2 2926 DEC LBUFC ; dec line buffer counter 931B 150D =2 2927 DEC LBUFP ; dec line buffer pointer 931D C3 =2 2928 GETG40: CLR C ; mark line not done 931E 22 =2 2929 RET ; that's all 931F B40D11 =2 2930 GETG50: CJNE A,#ACR,GETG60 ; jump if not CR 9322 A80D =2 2931 GETG55: MOV R0,LBUFP ; get line buffer pointer 9324 7600 =2 2932 MOV @R0,#0 ; ensure null value 9326 740D =2 2933 MOV A,#ACR ; get CR 9328 129810 =2 2934 CALL EPUTC ; echo it (if wanted) 932B 740A =2 2935 MOV A,#ALF ; get LF 932D 129810 =2 2936 CALL EPUTC ; and echo it (if wanted) 9330 029349 =2 2937 JMP ILBUF ; done, init line buffer and set CY 9333 129810 =2 2938 GETG60: CALL EPUTC ; echo the char (if wanted) 9336 12936D =2 2939 CALL MAPUC ; map to upper case 9339 F6 =2 2940 MOV @R0,A ; save char in buffer 933A 08 =2 2941 INC R0 ; p++ 933B 050C =2 2942 INC LBUFC ; increment the count 933D 050D =2 2943 INC LBUFP ; increment the pointer 933F 7600 =2 2944 MOV @R0,#0 ; add null to end string 9341 E50C =2 2945 MOV A,LBUFC ; get line buffer counter 9343 24F5 =2 2946 ADD A,#256-(LBUFSZ-1) ; see if last byte filled 9345 50D6 =2 2947 JNC GETG40 ; jump if no overflow 9347 80D9 =2 2948 JMP GETG55 ; almost overflow!, CR/LF and stop =2 2949 9349 =2 2950 ILBUF: ; init the line buffer values, and set CY 9349 750C00 =2 2951 MOV LBUFC,#0 ; zero the line buffer counter 934C 750D0E =2 2952 MOV LBUFP,#LBUF ; init the line buffer pointer 934F D3 =2 2953 SETB C ; mark line as complete 9350 22 =2 2954 RET =2 2955 9351 =2 2956 MAPC: ; map required characters for input 9351 B47F03 =2 2957 CJNE A,#ADEL,MAPC10 ; jump if not delete 9354 7408 =2 2958 MOV A,#ABSP ; substitute backspace 9356 22 =2 2959 RET 9357 B40903 =2 2960 MAPC10: CJNE A,#ATAB,MAPC20 ; jump if not tab 935A 7420 =2 2961 MOV A,#ASP ; substitute space 935C 22 =2 2962 RET 935D B40D01 =2 2963 MAPC20: CJNE A,#ACR,MAPC30 ; jump if not CR 9360 22 =2 2964 RET ; no mapping here 9361 B40801 =2 2965 MAPC30: CJNE A,#ABSP,MAPC35 ; jump if not BSP 9364 22 =2 2966 RET ; no mapping here 9365 FF =2 2967 MAPC35: MOV R7,A ; save data in R7 9366 24E0 =2 2968 ADD A,#256-ASP ; clear CY if control char 9368 EF =2 2969 MOV A,R7 ; restore data from R7 9369 4001 =2 2970 JC MAPC40 ; jump if not control char 936B E4 =2 2971 CLR A ; else, return null 936C 22 =2 2972 MAPC40: RET =2 2973 936D =2 2974 MAPUC: ; map char to upper case 936D FF =2 2975 MOV R7,A ; save data in R7 936E 249F =2 2976 ADD A,#256-'a' ; set CY if 'a' or more MC2LDEV MC-2 Development 990419-2.00v PAGE 53 9370 EF =2 2977 MOV A,R7 ; recover data from R7 9371 4001 =2 2978 JC MAPU10 ; jump if so 9373 22 =2 2979 RET 9374 2485 =2 2980 MAPU10: ADD A,#255-'z' ; set CY if more than 'z' 9376 EF =2 2981 MOV A,R7 ; restore data from R7 9377 5001 =2 2982 JNC MAPU20 ; jump if 'z' or less 9379 22 =2 2983 RET 937A EF =2 2984 MAPU20: MOV A,R7 ; recover data from R7 937B 24E0 =2 2985 ADD A,#256-('a'-'A'); convert to upper case 937D 22 =2 2986 RET =2 2987 937E =2 2988 LBLEN: ; line buffer counter, return length of line buffer in A 937E 790E =2 2989 MOV R1,#LBUF ; pt to line buffer 9380 7F00 =2 2990 MOV R7,#0 ; clear counter 9382 E7 =2 2991 LBLE10: MOV A,@R1 ; get a char 9383 6004 =2 2992 JZ LBLE20 ; jump if end has been found 9385 0F =2 2993 INC R7 ; increment the counter 9386 09 =2 2994 INC R1 ; increment the pointer 9387 80F9 =2 2995 JMP LBLE10 ; loop 9389 EF =2 2996 LBLE20: MOV A,R7 ; move data to A 938A 22 =2 2997 RET =2 2998 $INCLUDE(LOGIN.ASM) ; Login/Logout processing =2 2999 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3000 ; +++ LOGIN.ASM =2 3001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3002 =2 3003 938B =2 3004 LOGIN: ; do any login/logout functions needed 938B 08 =2 3005 INC R0 ; pt to user cmd char 938C E6 =2 3006 MOV A,@R0 ; get user command char 938D B44C3B =2 3007 CJNE A,#'L',LOGI65 ; jump if other than login 9390 08 =2 3008 INC R0 ; pt to sub command char 9391 =2 3009 LOGI10: ; come here pointing to sub command 9391 E6 =2 3010 MOV A,@R0 ; get sub command 9392 B44304 =2 3011 CJNE A,#'C',LOGI20 ; see if CHALENGE wanted, jump if not 9395 129457 =2 3012 CALL GPCHAL ; get new CHAL and print 9398 22 =2 3013 RET 9399 =2 3014 LOGI20: ; come here pointing to sub command 9399 E6 =2 3015 MOV A,@R0 ; get sub command 939A B4410A =2 3016 CJNE A,#'A',LOGI55 ; see if AUTH TABLE wanted, jump if not 939D 200603 =2 3017 JB SYSADMN,LOGI50 ; skip over if SYSADMN 93A0 029923 =2 3018 JMP SYSAERR ; else, not SYSADMN error msg 93A3 129490 =2 3019 LOGI50: CALL PAUTAB ; print authentication table 93A6 22 =2 3020 RET 93A7 B44F4F =2 3021 LOGI55: CJNE A,#'O',LOGI75 ; jump if LOGOUT not wanted 93AA C205 =2 3022 CLR LGISTAT ; clear login status 93AC 756A00 =2 3023 MOV DCDSEC,#0 ; clear DCDSEC counter, want full timeout 93AF 756B00 =2 3024 MOV DCDTRY,#0 ; clear DCDTRY counter, want all tries 93B2 12986A =2 3025 CALL PSTNADM ; print station address marker 93B5 9093BC =2 3026 MOV DPTR,#LOGI60 ; pt to logout message 93B8 12972E =2 3027 CALL CPUTS ; print the message 93BB 22 =2 3028 RET 93BC 4C4F4747 =2 3029 LOGI60: DB 'LOGGED OUT',ACR,ALF,ANULL 93C0 4544204F 93C4 55540D0A 93C8 00 93C9 056B =2 3030 LOGI63: INC DCDTRY ; was failed login try so inc TRY ctr 93CB 12986A =2 3031 LOGI65: CALL PSTNADM ; print station I/D MC2LDEV MC-2 Development 990419-2.00v PAGE 54 93CE 9093D8 =2 3032 MOV DPTR,#LOGI70 ; pt to message 93D1 12972E =2 3033 CALL CPUTS ; put the string 93D4 129457 =2 3034 CALL GPCHAL ; get new CHAL and print 93D7 22 =2 3035 RET 93D8 21212120 =2 3036 LOGI70: DB '!!! ERROR, USER MUST LOGIN !!!',ACR,ALF,ANULL 93DC 4552524F 93E0 522C2055 93E4 53455220 93E8 4D555354 93EC 204C4F47 93F0 494E2021 93F4 21210D0A 93F8 00 93F9 B449CF =2 3037 LOGI75: CJNE A,#'I',LOGI65 ; jump if not login wanted 93FC 08 =2 3038 INC R0 ; pt to 1st user password char 93FD 7928 =2 3039 MOV R1,#PSWD0 ; pt to user password 93FF E7 =2 3040 MOV A,@R1 ; get high byte of password 9400 64FF =2 3041 XRL A,#0FFH ; see same as 0FFH 9402 602C =2 3042 JZ LOGI90 ; do authentication login 9404 12982B =2 3043 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 9407 E7 =2 3044 MOV A,@R1 ; get first byte from sys password 9408 6E =2 3045 XRL A,R6 ; see if match with user input 9409 70BE =2 3046 JNZ LOGI63 ; failed login attempt 940B 09 =2 3047 INC R1 ; pt to PSWD1 940C E7 =2 3048 MOV A,@R1 ; get 2nd byte of sys password 940D 6F =2 3049 XRL A,R7 ; see if match with user input 940E 70B9 =2 3050 JNZ LOGI63 ; failed login attempt 9410 12982B =2 3051 CALL A4TOBIN ; get adr to R6,R7, CY=1 if R6 in range 9413 09 =2 3052 INC R1 ; pt to PSWD2 9414 E7 =2 3053 MOV A,@R1 ; get 3rd byte of sys password 9415 6E =2 3054 XRL A,R6 ; see if match with user input 9416 70B1 =2 3055 JNZ LOGI63 ; failed login attempt 9418 D205 =2 3056 LOGI80: SETB LGISTAT ; mark login valid 941A 12986A =2 3057 CALL PSTNADM ; print station address marker 941D 909424 =2 3058 MOV DPTR,#LOGI85 ; pt to successful message 9420 12972E =2 3059 CALL CPUTS ; print the message 9423 22 =2 3060 RET ; that's all 9424 4C4F4747 =2 3061 LOGI85: DB 'LOGGED IN',ACR,ALF,ANULL 9428 45442049 942C 4E0D0A00 9430 09 =2 3062 LOGI90: INC R1 ; pt to PSWD1 9431 E7 =2 3063 MOV A,@R1 ; get byte 9432 F583 =2 3064 MOV DPH,A ; move to DPH 9434 09 =2 3065 INC R1 ; pt to PSWD2 9435 E7 =2 3066 MOV A,@R1 ; get byte 9436 F582 =2 3067 MOV DPL,A ; move to DPL 9438 7967 =2 3068 MOV R1,#CH0 ; pt to challenge location 0 943A 7A03 =2 3069 MOV R2,#3 ; check 3 bytes 943C 12981C =2 3070 LOGI93: CALL GHXR0 ; convert 2 chars @r0 to hex 943F E7 =2 3071 MOV A,@R1 ; get challenge value 9440 09 =2 3072 INC R1 ; pt to next chal value 9441 129511 =2 3073 CALL GAUTHV ; get expected user value 9444 6F =2 3074 XRL A,R7 ; compare 9445 7082 =2 3075 JNZ LOGI63 ; error if not same 9447 DAF3 =2 3076 DJNZ R2,LOGI93 ; loop through all bytes 9449 80CD =2 3077 JMP LOGI80 ; if here then login =2 3078 944B =2 3079 GENCHAL: ; generate challenge indices for memory MC2LDEV MC-2 Development 990419-2.00v PAGE 55 944B 7A03 =2 3080 MOV R2,#3 ; want 3 loops 944D 7867 =2 3081 MOV R0,#CH0 ; pt to challenge 0 address 944F 12947B =2 3082 GENC10: CALL CRANKRN ; crank out another RN 9452 F6 =2 3083 MOV @R0,A ; save at @R0 9453 08 =2 3084 INC R0 ; pt to next 9454 DAF9 =2 3085 DJNZ R2,GENC10 ; loop through all 9456 22 =2 3086 RET =2 3087 9457 =2 3088 GPCHAL: ; generate challenge indices and print them 9457 914B =2 3089 CALL GENCHAL ; gen challenge indices to for memory 9459 12986A =2 3090 CALL PSTNADM ; print station address marker 945C 909474 =2 3091 MOV DPTR,#GPCH20 ; pt to first message 945F 12972E =2 3092 CALL CPUTS ; print it 9462 7A03 =2 3093 MOV R2,#3 ; want 3 loops 9464 7867 =2 3094 MOV R0,#CH0 ; pt to challenge 0 address 9466 E6 =2 3095 GPCH10: MOV A,@R0 ; get from @R0 9467 08 =2 3096 INC R0 ; pt to next 9468 12976E =2 3097 CALL PHXBYTE ; print it 946B 1297B8 =2 3098 CALL SPACE ; add a space 946E DAF6 =2 3099 DJNZ R2,GPCH10 ; loop through all 9470 129721 =2 3100 CALL CRLF ; end the line 9473 22 =2 3101 RET 9474 4348414C =2 3102 GPCH20: DB 'CHAL: ',ANULL 9478 3A2000 =2 3103 947B =2 3104 CRANKRN: ; crank out another random number set, value in A 947B 7964 =2 3105 MOV R1,#RN0 ; pt to RN0 947D E7 =2 3106 MOV A,@R1 ; get it 947E 2411 =2 3107 ADD A,#17 ; add 17 9480 F7 =2 3108 MOV @R1,A ; save it back 9481 FB =2 3109 MOV R3,A ; and in R3 9482 09 =2 3110 INC R1 ; pt to RN1 9483 E7 =2 3111 MOV A,@R1 ; get it 9484 2425 =2 3112 ADD A,#37 ; add 37 9486 F7 =2 3113 MOV @R1,A ; save it back 9487 6B =2 3114 XRL A,R3 ; xor them together 9488 FB =2 3115 MOV R3,A ; save back to A 9489 09 =2 3116 INC R1 ; pt to RN2 948A E7 =2 3117 MOV A,@R1 ; get it 948B 2443 =2 3118 ADD A,#67 ; add 67 948D F7 =2 3119 MOV @R1,A ; save it back 948E 6B =2 3120 XRL A,R3 ; xor them together, return with RN in A 948F 22 =2 3121 RET =2 3122 9490 =2 3123 PAUTAB: ; print authentication table 9490 12971E =2 3124 CALL CRLF2 ; do two lines 9493 909503 =2 3125 MOV DPTR,#PAUT91 ; pt to first message 9496 12972E =2 3126 CALL CPUTS ; print it 9499 7A03 =2 3127 MOV R2,#3 ; want to do 3 loops 949B 7828 =2 3128 MOV R0,#PSWD0 ; pt to password 949D E6 =2 3129 PAUT10: MOV A,@R0 ; get a byte 949E 12976E =2 3130 CALL PHXBYTE ; print it 94A1 08 =2 3131 INC R0 ; pt to next 94A2 DAF9 =2 3132 DJNZ R2,PAUT10 ; loop as needed 94A4 90950A =2 3133 MOV DPTR,#PAUT92 ; pt to second message 94A7 12972E =2 3134 CALL CPUTS ; print it 94AA 7A10 =2 3135 MOV R2,#16 ; want to do 16 lables 94AC 7B00 =2 3136 MOV R3,#0 ; clear counter MC2LDEV MC-2 Development 990419-2.00v PAGE 56 94AE EB =2 3137 PAUT20: MOV A,R3 ; get counter 94AF 12976E =2 3138 CALL PHXBYTE ; print as hex byte 94B2 1297B8 =2 3139 CALL SPACE ; print a space 94B5 0B =2 3140 INC R3 ; increment counter 94B6 DAF6 =2 3141 DJNZ R2,PAUT20 ; loop as needed 94B8 129721 =2 3142 CALL CRLF ; print a new line 94BB 1297AF =2 3143 CALL SPACE4 ; print some spaces 94BE 7A10 =2 3144 MOV R2,#16 ; want 16 lines 94C0 742D =2 3145 PAUT25: MOV A,#'-' ; get a line 94C2 5126 =2 3146 CALL PUTCHAR ; print the char 94C4 5126 =2 3147 CALL PUTCHAR ; print the char, again 94C6 1297B8 =2 3148 CALL SPACE ; print a space 94C9 DAF5 =2 3149 DJNZ R2,PAUT25 ; loop as needed 94CB 129721 =2 3150 CALL CRLF ; print new line 94CE E529 =2 3151 MOV A,PSWD1 ; get second password value 94D0 F583 =2 3152 MOV DPH,A ; move to DP high 94D2 E52A =2 3153 MOV A,PSWD2 ; get third passord value 94D4 F582 =2 3154 MOV DPL,A ; move to DP low 94D6 7A00 =2 3155 MOV R2,#0 ; initialize line label counter 94D8 7B10 =2 3156 MOV R3,#16 ; initialize line counter 94DA 7C00 =2 3157 MOV R4,#0 ; clear table index 94DC EA =2 3158 PAUT30: MOV A,R2 ; get line label counter 94DD 12976E =2 3159 CALL PHXBYTE ; print it 94E0 743A =2 3160 MOV A,#':' ; get colon 94E2 5126 =2 3161 CALL PUTCHAR ; print colon 94E4 1297B8 =2 3162 CALL SPACE ; separate by spaces 94E7 EA =2 3163 MOV A,R2 ; get line label counter 94E8 2410 =2 3164 ADD A,#16 ; add offset of 16 94EA FA =2 3165 MOV R2,A ; save back to R5 94EB 7D10 =2 3166 MOV R5,#16 ; initialize byte counter 94ED EC =2 3167 PAUT40: MOV A,R4 ; move index to A 94EE 129511 =2 3168 CALL GAUTHV ; get auth value based on DPTR to A 94F1 0C =2 3169 INC R4 ; increment index, pt to next location 94F2 12976E =2 3170 CALL PHXBYTE ; print the byte 94F5 1297B8 =2 3171 CALL SPACE ; space once 94F8 DDF3 =2 3172 DJNZ R5,PAUT40 ; loop through whole line 94FA 129721 =2 3173 CALL CRLF ; newline 94FD DBDD =2 3174 DJNZ R3,PAUT30 ; loop through all lines 94FF 129721 =2 3175 CALL CRLF ; two new lines 9502 22 =2 3176 RET 9503 53454544 =2 3177 PAUT91: DB 'SEED: ',ANULL 9507 3A2000 950A 0D0A2020 =2 3178 PAUT92: DB ACR,ALF,' ',ANULL 950E 202000 =2 3179 9511 =2 3180 GAUTHV: ; get authentication value based on DPTR 9511 641C =2 3181 XRL A,#01CH ; permute 9513 93 =2 3182 MOVC A,@A+DPTR ; get a char 9514 6583 =2 3183 XRL A,DPH ; xor with DPH 9516 6582 =2 3184 XRL A,DPL ; xor with DPL 9518 2425 =2 3185 ADD A,#37 ; add in an offset just for good measure 951A 6483 =2 3186 XRL A,#83H ; twiddle some bits 951C 22 =2 3187 RET =2 3188 951D =2 3189 ADISCON: ; auto disconnect, get LITIME seconds to login 951D 302C03 =2 3190 JNB ADIS,ADIS10 ; jump if Auto Disconnect NOT wanted (0) 9520 301407 =2 3191 JNB DCD,ADIS20 ; jump if DCD is active (0) 9523 756A00 =2 3192 ADIS10: MOV DCDSEC,#0 ; else, clear DCD seconds counter MC2LDEV MC-2 Development 990419-2.00v PAGE 57 9526 756B00 =2 3193 MOV DCDTRY,#0 ; else, clear DCD try counter 9529 22 =2 3194 RET ; end 952A 20050C =2 3195 ADIS20: JB LGISTAT,ADIS30 ; jump all if logged in 952D E56A =2 3196 MOV A,DCDSEC ; get timer value to A 952F 24C4 =2 3197 ADD A,#256-LITIME ; see if LITIME seconds or more 9531 4007 =2 3198 JC FDISCON ; jump to forced disconnect if so 9533 E56B =2 3199 MOV A,DCDTRY ; get number of times login tried 9535 24FC =2 3200 ADD A,#256-LITRY ; see if LITRY times or more 9537 4001 =2 3201 JC FDISCON ; jump to forced disconnect if so 9539 22 =2 3202 ADIS30: RET ; else, just return =2 3203 953A =2 3204 FDISCON: ; forced disconnect 953A 12986A =2 3205 CALL PSTNADM ; print station address 953D 909578 =2 3206 MOV DPTR,#FDIS95 ; get pointer to user message 9540 12972E =2 3207 CALL CPUTS ; output user message 9543 740A =2 3208 MOV A,#10 ; want to wait 10 seconds for pkt xmisn 9545 1295AA =2 3209 CALL LCKTIME ; lock up for that length of time 9548 90959C =2 3210 MOV DPTR,#FDIS96 ; get ptr to 3 control Cs 954B 12972E =2 3211 CALL CPUTS ; output 3 control Cs 954E 7403 =2 3212 MOV A,#3 ; want to wait 3 seconds to be sure 9550 1295AA =2 3213 CALL LCKTIME ; do the wait 9553 9095A0 =2 3214 MOV DPTR,#FDIS97 ; get disconnect message 9556 12972E =2 3215 CALL CPUTS ; output it 9559 7405 =2 3216 MOV A,#5 ; want to wait 5 seconds 955B 1295AA =2 3217 CALL LCKTIME ; do the wait 955E C2B1 =2 3218 CLR TXD ; send BREAK on serial port 9560 D210 =2 3219 SETB DTR ; set DTR to mark inactive 9562 7405 =2 3220 MOV A,#5 ; want to wait 5 seconds 9564 1295AA =2 3221 CALL LCKTIME ; do the wait 9567 D2B1 =2 3222 SETB TXD ; release BREAK 9569 C210 =2 3223 CLR DTR ; clear DTR to mark active 956B 9095A4 =2 3224 MOV DPTR,#FDIS98 ; get ptr to dummy command (after break) 956E 12972E =2 3225 CALL CPUTS ; output dummy command to clear TNC uart 9571 756A00 =2 3226 MOV DCDSEC,#0 ; clear DCD seconds counter 9574 756B00 =2 3227 MOV DCDTRY,#0 ; clear DCD try counter 9577 22 =2 3228 RET 9578 21212120 =2 3229 FDIS95: DB '!!! TIMED OUT - DISCONNECTING !!!',ACR,ALF,ANULL 957C 54494D45 9580 44204F55 9584 54202D20 9588 44495343 958C 4F4E4E45 9590 4354494E 9594 47202121 9598 210D0A00 959C 03030300 =2 3230 FDIS96: DB ACTLC,ACTLC,ACTLC,ANULL ; ^C^C^C 95A0 0D440D00 =2 3231 FDIS97: DB ACR,'D',ACR,ANULL ; disconnect command 95A4 0D202020 =2 3232 FDIS98: DB ACR,' ',ACR,ANULL ; dummy line 95A8 0D00 =2 3233 95AA =2 3234 LCKTIME: ; lock time for A seconds, use DCDSEC for timer 95AA F4 =2 3235 CPL A ; compliment A 95AB 04 =2 3236 INC A ; add one (i.e., now -A) 95AC F5F0 =2 3237 MOV B,A ; move -A to B 95AE 756A00 =2 3238 MOV DCDSEC,#0 ; clear DCDSEC 95B1 C0F0 =2 3239 LCKT10: PUSH B =2 3240 ;+++ CALL CINC ; update the clock, as needed 95B3 D0F0 =2 3241 POP B MC2LDEV MC-2 Development 990419-2.00v PAGE 58 95B5 E56A =2 3242 MOV A,DCDSEC ; get DCDSEC value 95B7 25F0 =2 3243 ADD A,B ; see if same or more than -A 95B9 50F6 =2 3244 JNC LCKT10 ; loop if not 95BB 22 =2 3245 RET ; else, return =2 3246 $INCLUDE(MAIN.ASM) ; main processing =2 3247 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3248 ; +++ MAIN.ASM =2 3249 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3250 95BC =2 3251 MAIN: 95BC =2 3252 LOOP: ; do the function here 95BC 128F01 =2 3253 CALL CMDPROC ; process command, if ready 95BF 129634 =2 3254 CALL ALI ; mark LOGGED IN if PSWD0=00 or SYSADMN 95C2 B11D =2 3255 CALL ADISCON ; auto disconnect, if wanted/needed =2 3256 ;+++ CALL CINC ; do TOD clock increments 95C4 513E =2 3257 CALL IOUPDAT ; do i/o updates it time 95C6 1295D6 =2 3258 CALL AMAP ; do any auto display function needed 95C9 1295F8 =2 3259 CALL ACHANG ; do any auto change function needed 95CC 12964B =2 3260 CALL SSPEED ; update serial port speed 95CF 1296A0 =2 3261 CALL UDADCON ; update A/D converter channel data 95D2 5191 =2 3262 CALL WDTTOG ; watch dog timer toggle 95D4 80E6 =2 3263 JMP LOOP =2 3264 95D6 =2 3265 AMAP: ; auto map function, do when bit is set 95D6 30041E =2 3266 JNB DAMAP,AMAP99 ; jump if function not wanted 95D9 C204 =2 3267 CLR DAMAP ; clear flag bit 95DB 202B03 =2 3268 JB AONLI,AMAP10 ; jump if want auto even if not logged in 95DE 300516 =2 3269 JNB LGISTAT,AMAP99 ; no auto output if not logged in 95E1 12986A =2 3270 AMAP10: CALL PSTNADM ; print station address marker, if any 95E4 128E1F =2 3271 CALL PDTSTR ; print date string 95E7 909ED1 =2 3272 MOV DPTR,#ADISPM ; print auto display message 95EA 12972E =2 3273 CALL CPUTS ; console put string 95ED 206301 =2 3274 JB AFLU,AMAP20 ; jump if Fast Load Up wanted =2 3275 ;;++ CALL MAPD ; print map dislplay, w/o heading 95F0 22 =2 3276 RET ; that's all 95F1 782C =2 3277 AMAP20: MOV R0,#OSTAT0 ; pt to start of open memory 95F3 7A2B =2 3278 MOV R2,#43 ; want to write all 43 bytes 95F5 1146 =2 3279 CALL FLOA37 ; jump to dump 95F7 22 =2 3280 AMAP99: RET =2 3281 95F8 =2 3282 ACHANG: ; auto change function, print time of any binary input change 95F8 202B03 =2 3283 JB AONLI,ACHG10 ; jump if want auto even if not logged in 95FB 300535 =2 3284 JNB LGISTAT,ACHG99 ; no auto output if not logged in 95FE 783A =2 3285 ACHG10: MOV R0,#PR0CIMG ; pt to input change image, port 0 9600 7935 =2 3286 MOV R1,#PR0IMG ; pt to input data image, port 0 9602 7A05 =2 3287 MOV R2,#5 ; 5 bytes to do 9604 E6 =2 3288 ACHG20: MOV A,@R0 ; get change data 9605 5527 =2 3289 ANL A,ACHGMSK ; AND with CHANGE mask 9607 600A =2 3290 JZ ACHG40 ; jump if nothing to do 9609 7B08 =2 3291 MOV R3,#8 ; eight bits to check 960B 7CFF =2 3292 MOV R4,#-1 ; bit count, backed up one 960D 13 =2 3293 ACHG30: RRC A ; shift change flag into C 960E 0C =2 3294 INC R4 ; inc bit counter 960F 4007 =2 3295 JC ACHG50 ; jump if change found 9611 DBFA =2 3296 DJNZ R3,ACHG30 ; do all 8 bits, if needed 9613 08 =2 3297 ACHG40: INC R0 ; pt to next change image 9614 09 =2 3298 INC R1 ; pt to next input image 9615 DAED =2 3299 DJNZ R2,ACHG20 ; do all bytes MC2LDEV MC-2 Development 990419-2.00v PAGE 59 9617 22 =2 3300 RET 9618 =2 3301 ACHG50: ; change found, now need to clear it, R4 has bit position 9618 C3 =2 3302 CLR C ; clear that bit 9619 13 =2 3303 ACHG60: RRC A ; rotate some more 961A DBFD =2 3304 DJNZ R3,ACHG60 ; until all change byte normal but bit clr 961C F6 =2 3305 MOV @R0,A ; restore byte with bit clear 961D E9 =2 3306 MOV A,R1 ; get input image address to A 961E C3 =2 3307 CLR C ; ensure carry is clear 961F 942C =2 3308 SUBB A,#RIDX ; org at relative index 9621 FE =2 3309 MOV R6,A ; move to R6 9622 12986A =2 3310 CALL PSTNADM ; print station address mark 9625 128E1F =2 3311 CALL PDTSTR ; print date string 9628 909EE3 =2 3312 MOV DPTR,#ACHGM ; pt to auto change message 962B 12972E =2 3313 CALL CPUTS ; print it 962E EC =2 3314 MOV A,R4 ; get bit postion 962F FF =2 3315 MOV R7,A ; and move to R7, R6 has relative address 9630 128A78 =2 3316 CALL BITD20 ; do bit display 9633 22 =2 3317 ACHG99: RET =2 3318 9634 =2 3319 ALI: ; if DCD is gone then LOGGED OUT, else =2 3320 ; automatic login, mark user LOGGED IN if SYSADMN is active =2 3321 ; or 1st 2 chars of PASSWD are ZERO 9634 301405 =2 3322 JNB DCD,ALI10 ; jump if DCD is active (0) 9637 C205 =2 3323 CLR LGISTAT ; if no DCD then LOGGED OUT 9639 02964A =2 3324 JMP ALI99 ; it's all over if DCD inactive 963C 300605 =2 3325 ALI10: JNB SYSADMN,ALI20 ; jump if not system administrator 963F D205 =2 3326 SETB LGISTAT ; logged in automaticically if SYSADMN 9641 02964A =2 3327 JMP ALI99 ; no need to check further 9644 E528 =2 3328 ALI20: MOV A,PSWD0 ; get system password 9646 7002 =2 3329 JNZ ALI99 ; no action if first byte of pswd is !zero 9648 D205 =2 3330 SETB LGISTAT ; mark logged in 964A 22 =2 3331 ALI99: RET ; done =2 3332 =2 3333 964B =2 3334 SSPEED: ; first, update serial port to ensure bit rate follows RSTAT0 bits =2 3335 ; 110.........0F3H....0BBH =2 3336 ; 300 0FBH 080H =2 3337 ; 600.........0FDH....0C0H =2 3338 ; 1200 0FEH 0E0H =2 3339 ; 2400.........0FFH....070H =2 3340 ; 4800 0FFH 0B8H =2 3341 ; 9600.........0FFH....0DCH =2 3342 ; 19200 0FFH 0EEH =2 3343 ; 38400........0FFH....0F7H 964B E525 =2 3344 MOV A,RSTAT0 ; get bit rate info 964D 5407 =2 3345 ANL A,#007H ; look only at 3 LS bits 964F B40007 =2 3346 CJNE A,#00H,SSPE10 ; jump if not zero (not 110) =2 3347 ; here for 110 @ x16 rate @ 11.0592 MHz 9652 75CBF3 =2 3348 MOV RCAP2H,#0F3H ; reload value 110 @ 11.0592 MHz 9655 75CABB =2 3349 MOV RCAP2L,#0BBH ; reload value 110 @ 11.0592 MHz 9658 22 =2 3350 RET 9659 B40107 =2 3351 SSPE10: CJNE A,#01H,SSPE20 ; jump if not one (not 300) =2 3352 ; here for 300 @ x16 rate @ 11.0592 MHz 965C 75CBFB =2 3353 MOV RCAP2H,#0FBH ; reload value 300 @ 11.0592 MHz 965F 75CA80 =2 3354 MOV RCAP2L,#080H ; reload value 300 @ 11.0592 MHz 9662 22 =2 3355 RET 9663 B40207 =2 3356 SSPE20: CJNE A,#02H,SSPE30 ; jump if not two (not 1200) =2 3357 ; here for 1200 @ x16 rate @ 11.0592 MHz MC2LDEV MC-2 Development 990419-2.00v PAGE 60 9666 75CBFE =2 3358 MOV RCAP2H,#0FEH ; reload value 1200 @ 11.0592 MHz 9669 75CAE0 =2 3359 MOV RCAP2L,#0E0H ; reload value 1200 @ 11.0592 MHz 966C 22 =2 3360 RET 966D B40307 =2 3361 SSPE30: CJNE A,#03H,SSPE40 ; jump if not three (not 2400) =2 3362 ; here for 2400 @ x16 rate @ 11.0592 MHz 9670 75CBFF =2 3363 MOV RCAP2H,#0FFH ; reload value 2400 @ 11.0592 MHz 9673 75CA70 =2 3364 MOV RCAP2L,#070H ; reload value 2400 @ 11.0592 MHz 9676 22 =2 3365 RET 9677 B40407 =2 3366 SSPE40: CJNE A,#04H,SSPE50 ; jump if not four (not 4800) =2 3367 ; here for 4800 @ x16 rate @ 11.0592 MHz 967A 75CBFF =2 3368 MOV RCAP2H,#0FFH ; reload value 4800 @ 11.0592 MHz 967D 75CAB8 =2 3369 MOV RCAP2L,#0B8H ; reload value 4800 @ 11.0592 MHz 9680 22 =2 3370 RET 9681 B40507 =2 3371 SSPE50: CJNE A,#05H,SSPE60 ; jump if not five (not 9600) =2 3372 ; here for 9600 @ x16 rate @ 11.0592 MHz 9684 75CBFF =2 3373 MOV RCAP2H,#0FFH ; reload value 9600 @ 11.0592 MHz 9687 75CADC =2 3374 MOV RCAP2L,#0DCH ; reload value 9600 @ 11.0592 MHz 968A 22 =2 3375 RET 968B B40607 =2 3376 SSPE60: CJNE A,#06H,SSPE70 ; jump if not six (not 19200) =2 3377 ; here for 19200 @ x16 rate @ 11.0592 MHz 968E 75CBFF =2 3378 MOV RCAP2H,#0FFH ; reload value 19200 @ 11.0592 MHz 9691 75CAEE =2 3379 MOV RCAP2L,#0EEH ; reload value 19200 @ 11.0592 MHz 9694 22 =2 3380 RET 9695 B40707 =2 3381 SSPE70: CJNE A,#07H,SSPE80 ; jump if not seven (not 38400) =2 3382 ; here for 38400 @ x16 rate @ 11.0592 MHz 9698 75CBFF =2 3383 MOV RCAP2H,#0FFH ; reload value 38400 @ 11.0592 MHz 969B 75CAF7 =2 3384 MOV RCAP2L,#0F7H ; reload value 38400 @ 11.0592 MHz 969E 22 =2 3385 RET =2 3386 ; add more stuff here if needed 969F 22 =2 3387 SSPE80: RET =2 3388 =2 3389 ;SSPEED: ; update serial port to ensure bit rate follows RSTAT0 bits =2 3390 ; MOV A,RSTAT0 ; get bit rate info =2 3391 ; ANL A,#003H ; look only at 2 LS bits =2 3392 ; CJNE A,#00H,SSPE10 ; jump if not zero =2 3393 ; MOV TH1,#256-192 ; for 300 @ x16 rate @ 11.0592 MHz =2 3394 ; RET =2 3395 ;SSPE10: CJNE A,#01H,SSPE20 ; jump if not zero =2 3396 ; MOV TH1,#256-48 ; for 1200 @ x16 rate @ 11.0592 MHz =2 3397 ; RET =2 3398 ;SSPE20: CJNE A,#02H,SSPE30 ; jump if not zero =2 3399 ; MOV TH1,#256-24 ; for 2400 @ x16 rate @ 11.0592 MHz =2 3400 ; RET =2 3401 ;SSPE30: MOV TH1,#256-6 ; for 9600 @ x16 rate @ 11.0592 MHz =2 3402 ; ; add more stuff here =2 3403 ; RET =2 3404 96A0 =2 3405 UDADCON: ; update A/D converter channel data 96A0 051F =2 3406 INC ADCHAN ; increment the channel counter 96A2 E51F =2 3407 MOV A,ADCHAN ; get it 96A4 B40803 =2 3408 CJNE A,#8,UDAD10 ; skip if not overflow value (8) 96A7 751F00 =2 3409 MOV ADCHAN,#0 ; clear it 96AA E51F =2 3410 UDAD10: MOV A,ADCHAN ; get channel again 96AC C3 =2 3411 CLR C ; ensure C is clear 96AD 13 =2 3412 RRC A ; divide by 2 96AE FA =2 3413 MOV R2,A ; save in R2 96AF E52F =2 3414 MOV A,ADCFLG ; get flag values 96B1 CA =2 3415 UDAD20: XCH A,R2 ; get count MC2LDEV MC-2 Development 990419-2.00v PAGE 61 96B2 6006 =2 3416 JZ UDAD30 ; jump if done 96B4 CA =2 3417 XCH A,R2 ; get flags 96B5 1A =2 3418 DEC R2 ; decrement the counter 96B6 03 =2 3419 RR A ; rotate 1st time 96B7 03 =2 3420 RR A ; rotate 2nd time 96B8 80F7 =2 3421 JMP UDAD20 ; loop till done 96BA CA =2 3422 UDAD30: XCH A,R2 ; get flags 96BB 5403 =2 3423 ANL A,#003H ; look only at lowest 2 bits 96BD 20E022 =2 3424 JB ACC.0,UDAD40 ; jump if balanced input wanted 96C0 E51F =2 3425 MOV A,ADCHAN ; get current channel 96C2 251F =2 3426 ADD A,ADCHAN ; double the value for word structure 96C4 244F =2 3427 ADD A,#ADCH0 ; make ptr to memory location 96C6 F8 =2 3428 MOV R0,A ; save in R0 96C7 E51F =2 3429 MOV A,ADCHAN ; get current channel 96C9 A2E1 =2 3430 MOV C,ACC.1 ; get A1 96CB 9200 =2 3431 MOV TMPB0,C ; save in temp location 96CD A2E2 =2 3432 MOV C,ACC.2 ; get A2 96CF 92E1 =2 3433 MOV ACC.1,C ; and put in D2 96D1 A200 =2 3434 MOV C,TMPB0 ; get A1 96D3 92E2 =2 3435 MOV ACC.2,C ; and put in D3 ; bit 2 remains same 96D5 D3 =2 3436 SETB C ; set CY for single ended 96D6 33 =2 3437 RLC A ; rotate left first time 96D7 D3 =2 3438 SETB C ; set CY for start bit 96D8 33 =2 3439 RLC A ; rotate left second time, cmd now in A 96D9 7F05 =2 3440 MOV R7,#5 ; 5 bits in command 96DB 519B =2 3441 CALL ADCONV ; move the value to A 96DD F6 =2 3442 MOV @R0,A ; save low byte in memory 96DE 08 =2 3443 INC R0 ; pt to high byte 96DF 7600 =2 3444 MOV @R0,#0 ; always a zero for 8 bit ADC 96E1 22 =2 3445 RET 96E2 =2 3446 UDAD40: ; Balanced input wanted 96E2 A2E1 =2 3447 MOV C,ACC.1 ; move reverse flag to C 96E4 9201 =2 3448 MOV TMPB1,C ; save in TMPB1 96E6 E51F =2 3449 MOV A,ADCHAN ; get current channel 96E8 251F =2 3450 ADD A,ADCHAN ; double the value for word structure 96EA 244F =2 3451 ADD A,#ADCH0 ; make ptr to memory location 96EC F8 =2 3452 MOV R0,A ; save in R0 96ED E51F =2 3453 MOV A,ADCHAN ; get current channel 96EF C3 =2 3454 CLR C ; clear C 96F0 13 =2 3455 RRC A ; divide by 2 96F1 A2E0 =2 3456 MOV C,ACC.0 ; get lowest address bit 96F3 9200 =2 3457 MOV TMPB0,C ; save in temp location 96F5 A2E1 =2 3458 MOV C,ACC.1 ; get highest address bit 96F7 92E0 =2 3459 MOV ACC.0,C ; and put in bit 1 96F9 A200 =2 3460 MOV C,TMPB0 ; get lowest address bit 96FB 92E1 =2 3461 MOV ACC.1,C ; and put in bit 3 ; bit 2 remains same 96FD A201 =2 3462 MOV C,TMPB1 ; move reverse flag to CY 96FF 33 =2 3463 RLC A ; rotate left first time 9700 C3 =2 3464 CLR C ; clear CY for differential flag 9701 33 =2 3465 RLC A ; rotate left second time 9702 D3 =2 3466 SETB C ; set CY for start bit 9703 33 =2 3467 RLC A ; rotate left third time, cmd now in A 9704 7F05 =2 3468 MOV R7,#5 ; 5 bits in command 9706 519B =2 3469 CALL ADCONV ; move the value to A 9708 F6 =2 3470 MOV @R0,A ; save low byte in memory 9709 08 =2 3471 INC R0 ; pt to high byte 970A 7600 =2 3472 MOV @R0,#0 ; always a zero for 8 bit ADC 970C 08 =2 3473 INC R0 ; balanced so fill both channels w/same MC2LDEV MC-2 Development 990419-2.00v PAGE 62 970D F6 =2 3474 MOV @R0,A ; save low byte in memory 970E 08 =2 3475 INC R0 ; pt to high byte 970F 7600 =2 3476 MOV @R0,#0 ; always a zero for 8 bit ADC 9711 051F =2 3477 INC ADCHAN ; inc channel counter (2 bytes saved) 9713 22 =2 3478 RET =2 3479 =2 3480 $INCLUDE(MISC.ASM) ; misc support functions =2 3481 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3482 ; +++ MISC.ASM =2 3483 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3484 =2 3485 9714 =2 3486 SIGNON: ; output the sign on message 9714 908803 =2 3487 MOV DPTR,#SIGNMSG ; get the text index 9717 12972E =2 3488 CALL CPUTS ; print the message to console 971A 129738 =2 3489 CALL PCKSUM ; print code space checksum 971D 22 =2 3490 RET =2 3491 971E 129721 =2 3492 CRLF2: CALL CRLF ; do it twice 9721 =2 3493 CRLF1: ; do it once 9721 =2 3494 CRLF: ; output a CR/LF to the console 9721 C0E0 =2 3495 PUSH ACC ; save ACC on stack 9723 740D =2 3496 MOV A,#ACR ; get CR 9725 5126 =2 3497 CALL PUTCHAR ; put to console 9727 740A =2 3498 MOV A,#ALF ; get LF 9729 5126 =2 3499 CALL PUTCHAR ; put to console 972B D0E0 =2 3500 POP ACC ; restore ACC from stack 972D 22 =2 3501 RET =2 3502 972E =2 3503 CPUTS: ; output string from code space pointed to by DPTR 972E E4 =2 3504 CLR A ; clear A 972F 93 =2 3505 MOVC A,@A+DPTR ; get a char 9730 7001 =2 3506 JNZ CPUT10 ; jump if not null 9732 22 =2 3507 RET ; else, that's all 9733 5126 =2 3508 CPUT10: CALL PUTCHAR ; output the char 9735 A3 =2 3509 INC DPTR ; increment the data pointer 9736 80F6 =2 3510 JMP CPUTS ; loop till done =2 3511 9738 =2 3512 PCKSUM: ; print checksum over code space to console 9738 908800 =2 3513 MOV DPTR,#PGMBAS ; pt to start of code 973B 7C00 =2 3514 MOV R4,#0 ; cksum low 973D 7D00 =2 3515 MOV R5,#0 ; cksum high 973F E4 =2 3516 PCKS10: CLR A ; clear A 9740 93 =2 3517 MOVC A,@A+DPTR ; get a byte from code space 9741 2C =2 3518 ADD A,R4 ; add to check sum 9742 FC =2 3519 MOV R4,A ; save in R4 9743 5001 =2 3520 JNC PCKS20 ; jump if no carry 9745 0D =2 3521 INC R5 ; if carry then inc ms byte 9746 A3 =2 3522 PCKS20: INC DPTR ; increment the DPTR 9747 E583 =2 3523 MOV A,DPH ; get high DPTR 9749 B49FF3 =2 3524 CJNE A,#HIGH PGMEND,PCKS10 ; see if same as high of 974C E582 =2 3525 MOV A,DPL ; if so then check low byte 974E B4ABEE =2 3526 CJNE A,#LOW PGMEND,PCKS10 ; jump if not same as low 9751 909964 =2 3527 MOV DPTR,#CKSMSG ; else, done so get pt to checksum msg 9754 F12E =2 3528 CALL CPUTS ; put it 9756 ED =2 3529 MOV A,R5 ; get checksum high 9757 12976E =2 3530 CALL PHXBYTE ; print as hex value 975A EC =2 3531 MOV A,R4 ; get checksum low MC2LDEV MC-2 Development 990419-2.00v PAGE 63 975B 12976E =2 3532 CALL PHXBYTE ; print as hex value 975E F121 =2 3533 CALL CRLF ; end the line 9760 F121 =2 3534 CALL CRLF ; skip a line 9762 22 =2 3535 RET =2 3536 9763 =2 3537 PDPTR: ; print value in DPTR as hex 9763 E583 =2 3538 MOV A,DPH ; get high byte 9765 12976E =2 3539 CALL PHXBYTE ; msb first 9768 E582 =2 3540 MOV A,DPL ; get low byte 976A 12976E =2 3541 CALL PHXBYTE ; lsb next 976D 22 =2 3542 RET =2 3543 976E =2 3544 PHXBYTE: ; print A as hex byte 976E C0E0 =2 3545 PUSH ACC ; save the char on stack 9770 C4 =2 3546 SWAP A ; swap nibbles 9771 12977A =2 3547 CALL PHXCHAR ; print the MS byte 9774 D0E0 =2 3548 POP ACC ; restore char LS byte 9776 12977A =2 3549 CALL PHXCHAR ; print the char 9779 22 =2 3550 RET =2 3551 977A =2 3552 PHXCHAR: ; print hex character 977A 540F =2 3553 ANL A,#00FH ; only look at LSB 977C 24F6 =2 3554 ADD A,#256-10 ; CY set if 10 or more 977E 20D705 =2 3555 JB CY,PHXC10 ; jump if 10 or more 9781 243A =2 3556 ADD A,#10+'0' ; adjust and add '0' offset 9783 029788 =2 3557 JMP PHXC20 ; skip whats next 9786 2441 =2 3558 PHXC10: ADD A,#'A' ; adjust for alpha char 9788 5126 =2 3559 PHXC20: CALL PUTCHAR ; put the character 978A 22 =2 3560 RET =2 3561 978B =2 3562 PBYTBIT: ; print a byte as bits with proper spacing =2 3563 ; A has data to be printed, R7 is distroyed 978B 7F04 =2 3564 MOV R7,#4 ; want four bits 978D 33 =2 3565 PBYT10: RLC A ; rotate left into CY 978E 12979F =2 3566 CALL PBINBIT ; print the binary bit 9791 DFFA =2 3567 DJNZ R7,PBYT10 ; loop through 4 bits 9793 1297B8 =2 3568 CALL SPACE1 ; print a space char 9796 7F04 =2 3569 MOV R7,#4 ; want four bits 9798 33 =2 3570 PBYT20: RLC A ; rotate left into CY 9799 12979F =2 3571 CALL PBINBIT ; print the binary bit 979C DFFA =2 3572 DJNZ R7,PBYT20 ; loop through 4 bits 979E 22 =2 3573 RET =2 3574 979F =2 3575 PBINBIT: ; print a binary bit as ascii, data in CY 979F C0E0 =2 3576 PUSH ACC ; save ACC on stack 97A1 4005 =2 3577 JC PBIN10 ; jump if CY set 97A3 7430 =2 3578 MOV A,#'0' ; get zero 97A5 0297AA =2 3579 JMP PBIN20 ; jump to print 97A8 7431 =2 3580 PBIN10: MOV A,#'1' ; get one 97AA 5126 =2 3581 PBIN20: CALL PUTCHAR ; print it 97AC D0E0 =2 3582 POP ACC ; restore ACC from stack 97AE 22 =2 3583 RET =2 3584 =2 3585 ; print a space characters 97AF 1297B8 =2 3586 SPACE4: CALL SPACE1 ; print 4 spaces 97B2 1297B8 =2 3587 SPACE3: CALL SPACE1 ; print 3 spaces 97B5 1297B8 =2 3588 SPACE2: CALL SPACE1 ; print 2 spaces 97B8 =2 3589 SPACE1: MC2LDEV MC-2 Development 990419-2.00v PAGE 64 97B8 C0E0 =2 3590 SPACE: PUSH ACC ; save ACC on stac 97BA 7420 =2 3591 MOV A,#ASP ; get space char 97BC 5126 =2 3592 CALL PUTCHAR ; put to console 97BE D0E0 =2 3593 POP ACC ; restore ACC from stack 97C0 22 =2 3594 RET ; that's all =2 3595 97C1 =2 3596 DPATDP: ; make DPTR = @DPTR, no other regs affected 97C1 C0E0 =2 3597 PUSH ACC ; save regs on stack 97C3 C0F0 =2 3598 PUSH B 97C5 E0 =2 3599 MOVX A,@DPTR ; get high value to A 97C6 F5F0 =2 3600 MOV B,A ; save at B 97C8 A3 =2 3601 INC DPTR ; pt to low value 97C9 E0 =2 3602 MOVX A,@DPTR ; get low value to A 97CA F582 =2 3603 MOV DPL,A ; move to DPL 97CC E5F0 =2 3604 MOV A,B ; get high value 97CE F583 =2 3605 MOV DPH,A ; move to DPH 97D0 D0F0 =2 3606 POP B ; restore regs 97D2 D0E0 =2 3607 POP ACC 97D4 22 =2 3608 RET =2 3609 97D5 =2 3610 INITMEM: ; initialize any memory locations needed =2 3611 ; mark all timers as done =2 3612 ;; MOV CDOW,#1 ; assume it's sunday 97D5 22 =2 3613 RET =2 3614 97D6 =2 3615 CHARHX: ; convert ASCII char to hex, set CY if valid 97D6 F5F0 =2 3616 MOV B,A ; save copy in B 97D8 24D0 =2 3617 ADD A,#256-'0' ; see if '0' or more 97DA 5030 =2 3618 JNC CHAR40 ; jump if not 97DC E5F0 =2 3619 MOV A,B ; restore data 97DE 24C6 =2 3620 ADD A,#255-'9' ; see if more than '9' 97E0 4006 =2 3621 JC CHAR20 ; jump if so 97E2 E5F0 =2 3622 MOV A,B ; restore data 97E4 540F =2 3623 ANL A,#0FH ; look only at low nibble 97E6 D3 =2 3624 SETB C ; mark valid 97E7 22 =2 3625 RET ; return 97E8 E5F0 =2 3626 CHAR20: MOV A,B ; restore data 97EA 24BF =2 3627 ADD A,#256-'A' ; see if 'A' or more 97EC 501E =2 3628 JNC CHAR40 ; jump if not 97EE E5F0 =2 3629 MOV A,B ; restore data 97F0 24B9 =2 3630 ADD A,#255-'F' ; see if more than 'F' 97F2 4006 =2 3631 JC CHAR30 ; jump if so 97F4 E5F0 =2 3632 MOV A,B ; restore data 97F6 24C9 =2 3633 ADD A,#256-'A'+10 ; add offset to make hex 97F8 D3 =2 3634 SETB C ; mark data valid 97F9 22 =2 3635 RET 97FA E5F0 =2 3636 CHAR30: MOV A,B ; restore data 97FC 249F =2 3637 ADD A,#256-'a' ; see if 'a' or more 97FE 500C =2 3638 JNC CHAR40 ; jump if not 9800 E5F0 =2 3639 MOV A,B ; restore data 9802 2499 =2 3640 ADD A,#255-'f' ; see if more than 'f' 9804 4006 =2 3641 JC CHAR40 ; jump if not 9806 E5F0 =2 3642 MOV A,B ; restore data 9808 24A9 =2 3643 ADD A,#256-'a'+10 ; add offset to make hex 980A D3 =2 3644 SETB C ; mark data valid 980B 22 =2 3645 RET 980C 7400 =2 3646 CHAR40: MOV A,#0 ; bad hex is mapped to zero 980E C3 =2 3647 CLR C ; mark not hex MC2LDEV MC-2 Development 990419-2.00v PAGE 65 980F 22 =2 3648 RET =2 3649 9810 =2 3650 EPUTC: ; echo put char, put only if echo is wanted 9810 202D03 =2 3651 JB NECHO,EPUT10 ; jump if no echo wanted 9813 129226 =2 3652 CALL PUTCHAR ; output the character to be echoed 9816 22 =2 3653 EPUT10: RET ; that's all =2 3654 9817 =2 3655 PR6HX: ; print the value in R6 has hex 9817 EE =2 3656 MOV A,R6 9818 12976E =2 3657 CALL PHXBYTE 981B 22 =2 3658 RET =2 3659 981C =2 3660 GHXR0: ; convert 2 ascii chars @R0 to Hex in A and R7 981C E6 =2 3661 MOV A,@R0 ; get 1st char 981D 1297D6 =2 3662 CALL CHARHX ; convert to hex 9820 C4 =2 3663 SWAP A ; move to MS nibble 9821 FF =2 3664 MOV R7,A ; save in R7 9822 08 =2 3665 INC R0 ; pt to 2nd char 9823 E6 =2 3666 MOV A,@R0 ; get 2nd char 9824 1297D6 =2 3667 CALL CHARHX ; convert to hex 9827 4F =2 3668 ORL A,R7 ; or LS and MS chars 9828 FF =2 3669 MOV R7,A ; save in R7 as well 9829 08 =2 3670 INC R0 ; pt to next char 982A 22 =2 3671 RET =2 3672 982B =2 3673 A4TOBIN: ; convert 4 ascii chars to R6/R7 assuming hex inputs =2 3674 ; CY = 0 and A = 1 if out of range 982B E6 =2 3675 MOV A,@R0 ; get 1st char 982C 1297D6 =2 3676 CALL CHARHX ; convert to hex 982F C4 =2 3677 SWAP A ; move to MS nibble 9830 FE =2 3678 MOV R6,A ; save in R6 9831 08 =2 3679 INC R0 ; pt to 2nd char 9832 E6 =2 3680 MOV A,@R0 ; get 2nd char 9833 1297D6 =2 3681 CALL CHARHX ; convert to hex 9836 4E =2 3682 ORL A,R6 ; or LS and MS chars 9837 FE =2 3683 MOV R6,A ; save in R6 9838 08 =2 3684 INC R0 ; pt to 3rd char 9839 E6 =2 3685 MOV A,@R0 ; get 3rd char 983A 1297D6 =2 3686 CALL CHARHX ; convert to hex 983D C4 =2 3687 SWAP A ; move to MS nibble 983E FF =2 3688 MOV R7,A ; save in R7 983F 08 =2 3689 INC R0 ; pt to 4th char 9840 E6 =2 3690 MOV A,@R0 ; get 4th char 9841 1297D6 =2 3691 CALL CHARHX ; convert to hex 9844 4F =2 3692 ORL A,R7 ; or LS and MS chars 9845 FF =2 3693 MOV R7,A ; save in R7 9846 08 =2 3694 INC R0 ; pt to following char 9847 02984A =2 3695 JMP ADRCK ; adr ck, set CY if address in R6 is valid =2 3696 984A =2 3697 ADRCK: ; address check, set CY if address in R6 is valid 984A EE =2 3698 MOV A,R6 ; move address to R6 984B 20E706 =2 3699 JB ACC.7,ADRC20 ; jump if negative 984E 24CD =2 3700 ADD A,#255-MXOADR ; see if beyond max open address 9850 4010 =2 3701 JC ADRC40 ; jump if so 9852 D3 =2 3702 ADRC10: SETB C ; else, set CY 9853 22 =2 3703 RET ; and return 9854 300608 =2 3704 ADRC20: JNB SYSADMN,ADRC30 ; jump if not system administrator 9857 F4 =2 3705 CPL A ; invert data MC2LDEV MC-2 Development 990419-2.00v PAGE 66 9858 04 =2 3706 INC A ; add one for two's compliment 9859 24F8 =2 3707 ADD A,#255-MXRADR ; see if more than max restricted adr 985B 50F5 =2 3708 JNC ADRC10 ; jump if not 985D C3 =2 3709 CLR C ; else, clear CY to show bad 985E 22 =2 3710 RET ; that's all 985F 129923 =2 3711 ADRC30: CALL SYSAERR ; not system administrator error msg 9862 C3 =2 3712 ADRC40: CLR C ; else, clear CY to show bad 9863 22 =2 3713 RET ; that's all =2 3714 9864 =2 3715 SMR7: ; swap and mask R7 for ls nibble 9864 EF =2 3716 MOV A,R7 ; get R7 9865 C4 =2 3717 SWAP A ; move higher nibble to lower 9866 540F =2 3718 ANL A,#0FH ; only consider what's now low nibble 9868 FF =2 3719 MOV R7,A ; and save that in R7 9869 22 =2 3720 RET =2 3721 986A =2 3722 PSTNADM: ; print station address marker with trailing space 986A 742D =2 3723 MOV A,#'-' ; get delimiter 986C 129226 =2 3724 CALL PUTCHAR ; print it 986F E52B =2 3725 MOV A,STNADR ; get station address 9871 129226 =2 3726 CALL PUTCHAR ; print it 9874 742D =2 3727 MOV A,#'-' ; get delimiter 9876 129226 =2 3728 CALL PUTCHAR ; print it 9879 1297B8 =2 3729 CALL SPACE1 ; end with a space =2 3730 ;; CALL PDTSTR ; print date/time string =2 3731 ;; CALL SPACE1 ; end with a space =2 3732 ; MOV A,#':' ; get delimiter =2 3733 ; CALL PUTCHAR ; print it =2 3734 ; CALL PUTCHAR ; print it =2 3735 ; CALL SPACE2 ; end with two spaces 987C 22 =2 3736 PSTN10: RET =2 3737 =2 3738 ;;;;;;;;;;;;;;;;;;;;; =2 3739 ; system message routines =2 3740 ;;;;;;;;;;;;;;;;;;;;; =2 3741 987D =2 3742 CMDOK: ; print address marker and command OK message 987D 116A =2 3743 CALL PSTNADM ; print station I/D 987F 909886 =2 3744 MOV DPTR,#CMDO10 ; pt to message 9882 12972E =2 3745 CALL CPUTS ; put the string 9885 22 =2 3746 RET 9886 434F4D4D =2 3747 CMDO10: DB 'COMMAND OK' 988A 414E4420 988E 4F4B 9890 0D0A =2 3748 DB ACR,ALF 9892 00 =2 3749 DB ANULL =2 3750 9893 =2 3751 CMDERR: ; print address marker and command error message 9893 116A =2 3752 CALL PSTNADM ; print station I/D 9895 90989C =2 3753 MOV DPTR,#CMDE10 ; pt to message 9898 12972E =2 3754 CALL CPUTS ; put the string 989B 22 =2 3755 RET 989C 3F3F3F20 =2 3756 CMDE10: DB '??? COMMAND ERROR ???' 98A0 434F4D4D 98A4 414E4420 98A8 4552524F 98AC 52203F3F 98B0 3F MC2LDEV MC-2 Development 990419-2.00v PAGE 67 98B1 0D0A =2 3757 DB ACR,ALF 98B3 00 =2 3758 DB ANULL =2 3759 98B4 =2 3760 ADRERR: ; print address marker and address error message 98B4 116A =2 3761 CALL PSTNADM ; print station I/D 98B6 9098BD =2 3762 MOV DPTR,#ADRE10 ; pt to message 98B9 12972E =2 3763 CALL CPUTS ; put the string 98BC 22 =2 3764 RET 98BD 3F3F3F20 =2 3765 ADRE10: DB '??? ADDRESS ERROR ???' 98C1 41444452 98C5 45535320 98C9 4552524F 98CD 52203F3F 98D1 3F 98D2 0D0A =2 3766 DB ACR,ALF 98D4 00 =2 3767 DB ANULL =2 3768 98D5 =2 3769 EEPTERR: ; print address marker and eeprom transfer error message 98D5 116A =2 3770 CALL PSTNADM ; print station I/D 98D7 9098DE =2 3771 MOV DPTR,#EEPT10 ; pt to message 98DA 12972E =2 3772 CALL CPUTS ; put the string 98DD 22 =2 3773 RET 98DE 3F3F3F20 =2 3774 EEPT10: DB '??? EEPROM TRANSFER ERROR ???' 98E2 45455052 98E6 4F4D2054 98EA 52414E53 98EE 46455220 98F2 4552524F 98F6 52203F3F 98FA 3F 98FB 0D0A =2 3775 DB ACR,ALF 98FD 00 =2 3776 DB ANULL =2 3777 98FE =2 3778 EEPDERR: ; print address marker and eeprom transfer error message 98FE 116A =2 3779 CALL PSTNADM ; print station I/D 9900 909907 =2 3780 MOV DPTR,#EEPD10 ; pt to message 9903 12972E =2 3781 CALL CPUTS ; put the string 9906 22 =2 3782 RET 9907 3F3F3F20 =2 3783 EEPD10: DB '??? EEPROM DATA ERROR ???' 990B 45455052 990F 4F4D2044 9913 41544120 9917 4552524F 991B 52203F3F 991F 3F 9920 0D0A =2 3784 DB ACR,ALF 9922 00 =2 3785 DB ANULL =2 3786 9923 =2 3787 SYSAERR: ; system administrator error msg 9923 116A =2 3788 CALL PSTNADM ; print station I/D 9925 90992C =2 3789 MOV DPTR,#SYSA10 ; pt to message 9928 12972E =2 3790 CALL CPUTS ; put the string 992B 22 =2 3791 RET 992C 3F3F3F20 =2 3792 SYSA10: DB '??? ONLY FOR SYSTEM ADMINISTRATOR ???' 9930 4F4E4C59 9934 20464F52 9938 20535953 993C 54454D20 MC2LDEV MC-2 Development 990419-2.00v PAGE 68 9940 41444D49 9944 4E495354 9948 5241544F 994C 52203F3F 9950 3F 9951 0D0A =2 3793 DB ACR,ALF 9953 00 =2 3794 DB ANULL =2 3795 9954 =2 3796 CKSTACK: ; print the highset value of stack address that's not zero 9954 787F =2 3797 MOV R0,#07FH ; pt to top of memory 9956 E6 =2 3798 CKST10: MOV A,@R0 ; get byte 9957 7003 =2 3799 JNZ CKST20 ; jump if not zero 9959 18 =2 3800 DEC R0 ; pt to next one down 995A 80FA =2 3801 JMP CKST10 ; loop till found 995C E8 =2 3802 CKST20: MOV A,R0 ; put address in A 995D 12976E =2 3803 CALL PHXBYTE ; print the address 9960 129721 =2 3804 CALL CRLF ; new line 9963 22 =2 3805 RET =2 3806 =2 3807 ;RDUMP ; test code to dump registers =2 3808 ; MOV 07FH,A ; save A in high stack =2 3809 ; MOV A,#';' =2 3810 ; CALL PUTCHAR =2 3811 ; MOV A,07FH =2 3812 ; CALL PHXBYTE =2 3813 ; MOV A,R0 =2 3814 ; CALL PHXBYTE =2 3815 ; MOV A,R1 =2 3816 ; CALL PHXBYTE =2 3817 ; MOV A,R2 =2 3818 ; CALL PHXBYTE =2 3819 ; MOV A,R3 =2 3820 ; CALL PHXBYTE =2 3821 ; MOV A,R4 =2 3822 ; CALL PHXBYTE =2 3823 ; MOV A,R5 =2 3824 ; CALL PHXBYTE =2 3825 ; MOV A,R6 =2 3826 ; CALL PHXBYTE =2 3827 ; MOV A,R7 =2 3828 ; CALL PHXBYTE =2 3829 ; MOV A,#';' =2 3830 ; CALL PUTCHAR =2 3831 ; MOV A,07FH =2 3832 ; RET =2 3833 =2 3834 $INCLUDE(STRING.ASM) ; string definitions =2 3835 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3836 ; +++ STRING.ASM =2 3837 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; =2 3838 =2 3839 9964 =2 3840 CKSMSG: ; checksum header message 9964 43686563 =2 3841 DB 'Checksum: 0x' 9968 6B73756D 996C 3A203078 9970 00 =2 3842 DB ANULL =2 3843 MC2LDEV MC-2 Development 990419-2.00v PAGE 69 9971 =2 3844 HELPMSG: ; help message 9971 0D0A =2 3845 DB ACR,ALF =2 3846 ; DB 'BIT DISPLAY, SET AND CLEAR COMMANDS' =2 3847 ; DB ACR,ALF =2 3848 ; DB '=sDaab DISPLAY STN s, ADDRESS ss, BIT b' =2 3849 ; DB ACR,ALF =2 3850 ; DB '=sSaab SET STN s, ADDRESS ss, BIT b' =2 3851 ; DB ACR,ALF =2 3852 ; DB '=sCaab CLEAR STN s, ADDRESS ss, BIT b',ACR,ALF =2 3853 ; DB ACR,ALF 9973 42495420 =2 3854 DB 'BIT READ AND WRITE COMMANDS' 9977 52454144 997B 20414E44 997F 20575249 9983 54452043 9987 4F4D4D41 998B 4E4453 998E 0D0A =2 3855 DB ACR,ALF 9990 3D735242 =2 3856 DB '=sRBaab READ STN s, ADDRESS ss, BIT b' 9994 61616220 9998 20202052 999C 45414420 99A0 53544E20 99A4 732C2041 99A8 44445245 99AC 53532073 99B0 732C2042 99B4 49542062 99B8 0D0A =2 3857 DB ACR,ALF 99BA 3D735742 =2 3858 DB '=sWBaabd WRITE STN s, ADDRESS ss, BIT b DATA d' 99BE 61616264 99C2 20202020 99C6 57524954 99CA 45205354 99CE 4E20732C 99D2 20414444 99D6 52455353 99DA 2073732C 99DE 20424954 99E2 20622044 99E6 41544120 99EA 64 99EB 0D0A =2 3859 DB ACR,ALF 99ED 0D0A =2 3860 DB ACR,ALF 99EF 42595445 =2 3861 DB 'BYTE READ AND WRITE COMMANDS' 99F3 20524541 99F7 4420414E 99FB 44205752 99FF 49544520 9A03 434F4D4D 9A07 414E4453 9A0B 0D0A =2 3862 DB ACR,ALF 9A0D 3D735259 =2 3863 DB '=sRYaa READ STN s, ADDRESS ss' 9A11 61612020 9A15 20202052 9A19 45414420 9A1D 53544E20 9A21 732C2041 MC2LDEV MC-2 Development 990419-2.00v PAGE 70 9A25 44445245 9A29 53532073 9A2D 73 9A2E 0D0A =2 3864 DB ACR,ALF 9A30 3D735759 =2 3865 DB '=sWYaadd WRITE STN s, ADDRESS ss, DATA BYTE dd' 9A34 61616464 9A38 20202057 9A3C 52495445 9A40 2053544E 9A44 20732C20 9A48 41444452 9A4C 45535320 9A50 73732C20 9A54 44415441 9A58 20425954 9A5C 45206464 9A60 0D0A =2 3866 DB ACR,ALF 9A62 0D0A =2 3867 DB ACR,ALF 9A64 574F5244 =2 3868 DB 'WORD READ COMMAND' 9A68 20524541 9A6C 4420434F 9A70 4D4D414E 9A74 44 9A75 0D0A =2 3869 DB ACR,ALF 9A77 3D735257 =2 3870 DB '=sRWaa READ WORD OF STN s, ADDRESS ss' 9A7B 61612020 9A7F 20202052 9A83 45414420 9A87 574F5244 9A8B 204F4620 9A8F 53544E20 9A93 732C2041 9A97 44445245 9A9B 53532073 9A9F 73 9AA0 0D0A =2 3871 DB ACR,ALF 9AA2 0D0A =2 3872 DB ACR,ALF 9AA4 3D734D45 =2 3873 DB '=sMEMORY SHOW CURRENT MEMORY DISPLAY' 9AA8 4D4F5259 9AAC 20202053 9AB0 484F5720 9AB4 43555252 9AB8 454E5420 9ABC 4D454D4F 9AC0 52592044 9AC4 4953504C 9AC8 4159 9ACA 0D0A =2 3874 DB ACR,ALF 9ACC 3D735645 =2 3875 DB '=sVER SHOW CURRENT VERSION AND SIGNON MESSAGE' 9AD0 52202020 9AD4 20202053 9AD8 484F5720 9ADC 43555252 9AE0 454E5420 9AE4 56455253 9AE8 494F4E20 9AEC 414E4420 9AF0 5349474E MC2LDEV MC-2 Development 990419-2.00v PAGE 71 9AF4 4F4E204D 9AF8 45535341 9AFC 4745 9AFE 0D0A =2 3876 DB ACR,ALF 9B00 3D735A41 =2 3877 DB '=sZAP ZAP ALL CHANGE INPUTS BACK TO ZERO' 9B04 50202020 9B08 2020205A 9B0C 41502041 9B10 4C4C2043 9B14 48414E47 9B18 4520494E 9B1C 50555453 9B20 20424143 9B24 4B20544F 9B28 205A4552 9B2C 4F 9B2D 0D0A =2 3878 DB ACR,ALF 9B2F 3D734552 =2 3879 DB '=sEREAD READ DATA FROM EEPROM' 9B33 45414420 9B37 20202052 9B3B 45414420 9B3F 44415441 9B43 2046524F 9B47 4D204545 9B4B 50524F4D 9B4F 0D0A =2 3880 DB ACR,ALF 9B51 3D734557 =2 3881 DB '=sEWRITE WRITE DATA TO EEPROM' 9B55 52495445 9B59 20202057 9B5D 52495445 9B61 20444154 9B65 4120544F 9B69 20454550 9B6D 524F4D 9B70 0D0A =2 3882 DB ACR,ALF 9B72 3D734544 =2 3883 DB '=sEDEF GET DEFAULT EEPROM DATA' 9B76 45462020 9B7A 20202047 9B7E 45542044 9B82 45464155 9B86 4C542045 9B8A 4550524F 9B8E 4D204441 9B92 5441 9B94 0D0A =2 3884 DB ACR,ALF 9B96 0D0A =2 3885 DB ACR,ALF 9B98 41444452 =2 3886 DB 'ADDRESSES AND BIT POSITIONS ARE ALWAYS IN HEX (16). ' 9B9C 45535345 9BA0 5320414E 9BA4 44204249 9BA8 5420504F 9BAC 53495449 9BB0 4F4E5320 9BB4 41524520 9BB8 414C5741 9BBC 59532049 9BC0 4E204845 9BC4 58202831 MC2LDEV MC-2 Development 990419-2.00v PAGE 72 9BC8 36292E20 9BCC 20 9BCD 4F555450 =2 3887 DB 'OUTPUT IS ALWAYS' 9BD1 55542049 9BD5 5320414C 9BD9 57415953 9BDD 0D0A =2 3888 DB ACR,ALF 9BDF 42415345 =2 3889 DB 'BASE 10 FOLLOWED BY BASE 16 FOLLOWED BY BASE 2.' 9BE3 20313020 9BE7 464F4C4C 9BEB 4F574544 9BEF 20425920 9BF3 42415345 9BF7 20313620 9BFB 464F4C4C 9BFF 4F574544 9C03 20425920 9C07 42415345 9C0B 20322E 9C0E 0D0A =2 3890 DB ACR,ALF 9C10 0D0A =2 3891 DB ACR,ALF 9C12 3D73546E =2 3892 DB '=sTnnnnnn SET TIME yymmdd, hhmm, ss, DOW= 1-7,' 9C16 6E6E6E6E 9C1A 6E202053 9C1E 45542054 9C22 494D4520 9C26 79796D6D 9C2A 64642C20 9C2E 68686D6D 9C32 2C207373 9C36 2C20444F 9C3A 573D2031 9C3E 2D372C 9C41 2061646A =2 3893 DB ' adj/mm= + -, adj/ss= 0' 9C45 2F6D6D3D 9C49 202B202D 9C4D 2C206164 9C51 6A2F7373 9C55 3D2030 9C58 0D0A =2 3894 DB ACR,ALF 9C5A 3D73416E =2 3895 DB '=sAnnnnnn SET ALARM yymmdd, hhmm, ss, DOW= 1-7,' 9C5E 6E6E6E6E 9C62 6E202053 9C66 45542041 9C6A 4C41524D 9C6E 2079796D 9C72 6D64642C 9C76 2068686D 9C7A 6D2C2073 9C7E 732C2044 9C82 4F573D20 9C86 312D372C 9C8A 2061646A =2 3896 DB ' adj/mm= + -, adj/ss= 0' 9C8E 2F6D6D3D 9C92 202B202D 9C96 2C206164 9C9A 6A2F7373 9C9E 3D2030 MC2LDEV MC-2 Development 990419-2.00v PAGE 73 9CA1 0D0A =2 3897 DB ACR,ALF 9CA3 0D0A =2 3898 DB ACR,ALF 9CA5 00 =2 3899 DB ANULL =2 3900 9CA6 =2 3901 MAP0M: ; map display message 0 =2 3902 ;; DB ACR,ALF =2 3903 ;; DB ACR,ALF 9CA6 53544154 =2 3904 DB 'STATUS DISPLAY' 9CAA 55532044 9CAE 4953504C 9CB2 4159 9CB4 0D0A =2 3905 DB ACR,ALF 9CB6 0D0A =2 3906 DB ACR,ALF 9CB8 20202020 =2 3907 DB ' ' 9CBC 20202020 9CC0 2020 9CC2 20414443 =2 3908 DB ' ADC-TYPE ' 9CC6 2D545950 9CCA 4520 9CCC 20202041 =2 3909 DB ' ADC-CFG ' 9CD0 44432D43 9CD4 46472020 9CD8 2050554C =2 3910 DB ' PUL1/FCTR ' 9CDC 312F4643 9CE0 545220 9CE3 20202053 =2 3911 DB ' STAT0' 9CE7 54415430 9CEB 0D0A =2 3912 DB ACR,ALF 9CED 20202020 =2 3913 DB ' ' 9CF1 20202020 9CF5 202020 9CF8 00 =2 3914 DB ANULL =2 3915 9CF9 =2 3916 MAP0MA: ; map display message 0A 9CF9 53595354 =2 3917 DB 'SYSTEM' 9CFD 454D 9CFF 20283033 =2 3918 DB ' (03 02 01 00)' 9D03 20303220 9D07 30312030 9D0B 3029 9D0D 0D0A =2 3919 DB ACR,ALF 9D0F 00 =2 3920 DB ANULL =2 3921 9D10 =2 3922 MAP1M: ; map display message 1 =2 3923 ;; DB ACR,ALF 9D10 0D0A =2 3924 DB ACR,ALF 9D12 20205458 =2 3925 DB ' TX-S3 ' 9D16 2D533320 9D1A 202020 9D1D 20205458 =2 3926 DB ' TX-S2 ' 9D21 2D533220 9D25 202020 9D28 20205458 =2 3927 DB ' TX-S1 ' 9D2C 2D533120 9D30 202020 9D33 20205458 =2 3928 DB ' TX-S0 ' 9D37 2D533020 9D3B 202020 MC2LDEV MC-2 Development 990419-2.00v PAGE 74 9D3E 2054582D =2 3929 DB ' TX-P4/A ' 9D42 50342F41 9D46 2020 9D48 0D0A =2 3930 DB ACR,ALF 9D4A 00 =2 3931 DB ANULL =2 3932 9D4B =2 3933 MAP2M: ; map display message 2 9D4B 5458 =2 3934 DB 'TX' 9D4D 20202020 =2 3935 DB ' (08 07 06 05 04)' 9D51 20283038 9D55 20303720 9D59 30362030 9D5D 35203034 9D61 29 9D62 0D0A =2 3936 DB ACR,ALF 9D64 00 =2 3937 DB ANULL =2 3938 9D65 =2 3939 MAP3MA: ; map display message 3a 9D65 0D0A =2 3940 DB ACR,ALF 9D67 20205258 =2 3941 DB ' RX-S3 ' 9D6B 2D533320 9D6F 202020 9D72 20205258 =2 3942 DB ' RX-S2 ' 9D76 2D533220 9D7A 202020 9D7D 20205258 =2 3943 DB ' RX-S1 ' 9D81 2D533120 9D85 202020 9D88 20205258 =2 3944 DB ' RX-S0 ' 9D8C 2D533020 9D90 202020 9D93 2052582D =2 3945 DB ' RX-P5/B ' 9D97 50352F42 9D9B 2020 9D9D 0D0A =2 3946 DB ACR,ALF 9D9F 00 =2 3947 DB ANULL =2 3948 9DA0 =2 3949 MAP3M: ; map display message 3 9DA0 5258 =2 3950 DB 'RX' 9DA2 20202020 =2 3951 DB ' (0D 0C 0B 0A 09)' 9DA6 20283044 9DAA 20304320 9DAE 30422030 9DB2 41203039 9DB6 29 9DB7 0D0A =2 3952 DB ACR,ALF 9DB9 00 =2 3953 DB ANULL =2 3954 =2 3955 9DBA =2 3956 MAP4M: ; map display message 4 9DBA 52582D43 =2 3957 DB 'RX-CHG' 9DBE 4847 9DC0 20283132 =2 3958 DB ' (12 11 10 0F 0E)' 9DC4 20313120 9DC8 31302030 9DCC 46203045 9DD0 29 9DD1 0D0A =2 3959 DB ACR,ALF MC2LDEV MC-2 Development 990419-2.00v PAGE 75 9DD3 2D2D2D2D =2 3960 DB '---- ---- ' 9DD7 202D2D2D 9DDB 2D2020 9DDE 2D2D2D2D =2 3961 DB '---- ---- ' 9DE2 202D2D2D 9DE6 2D2020 9DE9 2D2D2D2D =2 3962 DB '---- ---- ' 9DED 202D2D2D 9DF1 2D2020 9DF4 2D2D2D2D =2 3963 DB '---- ---- ' 9DF8 202D2D2D 9DFC 2D2020 9DFF 2D2D2D2D =2 3964 DB '---- ---- ' 9E03 202D2D2D 9E07 2D2020 9E0A 0D0A =2 3965 DB ACR,ALF 9E0C 37363534 =2 3966 DB '7654 3210 ' 9E10 20333231 9E14 302020 9E17 37363534 =2 3967 DB '7654 3210 ' 9E1B 20333231 9E1F 302020 9E22 37363534 =2 3968 DB '7654 3210 ' 9E26 20333231 9E2A 302020 9E2D 37363534 =2 3969 DB '7654 3210 ' 9E31 20333231 9E35 302020 9E38 37363534 =2 3970 DB '7654 3210 ' 9E3C 20333231 9E40 302020 9E43 0D0A0D0A =2 3971 DB ACR,ALF,ACR,ALF 9E47 2020 =2 3972 DB ' ' 9E49 37 =2 3973 DB '7' 9E4A 20202020 =2 3974 DB ' ' 9E4E 20 9E4F 36 =2 3975 DB '6' 9E50 20202020 =2 3976 DB ' ' 9E54 20 9E55 35 =2 3977 DB '5' 9E56 20202020 =2 3978 DB ' ' 9E5A 20 9E5B 34 =2 3979 DB '4' 9E5C 20202020 =2 3980 DB ' ' 9E60 20 9E61 33 =2 3981 DB '3' 9E62 20202020 =2 3982 DB ' ' 9E66 20 9E67 32 =2 3983 DB '2' 9E68 20202020 =2 3984 DB ' ' 9E6C 20 9E6D 31 =2 3985 DB '1' 9E6E 20202020 =2 3986 DB ' ' 9E72 20 9E73 30 =2 3987 DB '0' 9E74 0D0A =2 3988 DB ACR,ALF 9E76 00 =2 3989 DB ANULL =2 3990 MC2LDEV MC-2 Development 990419-2.00v PAGE 76 9E77 =2 3991 MAP5M: ; map display message 5 9E77 462F5020 =2 3992 DB 'F/P CTRS (H:L' 9E7B 43545253 9E7F 2028483A 9E83 4C 9E84 20203232 =2 3993 DB ' 22:21--14:13)' 9E88 3A32312D 9E8C 2D31343A 9E90 313329 9E93 0D0A =2 3994 DB ACR,ALF =2 3995 ;; DB ACR,ALF =2 3996 ;; DB ' ' =2 3997 ;; DB '7' =2 3998 ;; DB ' ' =2 3999 ;; DB '6' =2 4000 ;; DB ' ' =2 4001 ;; DB '5' =2 4002 ;; DB ' ' =2 4003 ;; DB '4' =2 4004 ;; DB ' ' =2 4005 ;; DB '3' =2 4006 ;; DB ' ' =2 4007 ;; DB '2' =2 4008 ;; DB ' ' =2 4009 ;; DB '1' =2 4010 ;; DB ' ' =2 4011 ;; DB '0' =2 4012 ;; DB ACR,ALF 9E95 00 =2 4013 DB ANULL =2 4014 9E96 =2 4015 MAP6M: ; map display message 6 9E96 41444320 =2 4016 DB 'ADC REGS (H:L' 9E9A 52454753 9E9E 2028483A 9EA2 4C 9EA3 20203332 =2 4017 DB ' 32:31--24:23)' 9EA7 3A33312D 9EAB 2D32343A 9EAF 323329 9EB2 0D0A =2 4018 DB ACR,ALF 9EB4 0D0A =2 4019 DB ACR,ALF 9EB6 00 =2 4020 DB ANULL =2 4021 9EB7 =2 4022 MAP7M: ; map display message 7 9EB7 4D454D4F =2 4023 DB 'MEMORY DISPLAY COMPLETE' 9EBB 52592044 9EBF 4953504C 9EC3 41592043 9EC7 4F4D504C 9ECB 455445 9ECE 0D0A =2 4024 DB ACR,ALF 9ED0 00 =2 4025 DB ANULL =2 4026 9ED1 =2 4027 ADISPM: ; auto display message 9ED1 4155544F =2 4028 DB 'AUTO TIMEOUT ' 9ED5 2054494D 9ED9 454F5554 9EDD 20 MC2LDEV MC-2 Development 990419-2.00v PAGE 77 9EDE 0D0A =2 4029 DB ACR,ALF 9EE0 0D0A =2 4030 DB ACR,ALF 9EE2 00 =2 4031 DB ANULL =2 4032 9EE3 =2 4033 ACHGM: ; auto change message 9EE3 494E5055 =2 4034 DB 'INPUT STATUS CHANGE: ' 9EE7 54205354 9EEB 41545553 9EEF 20434841 9EF3 4E47453A 9EF7 20 9EF8 00 =2 4035 DB ANULL =2 4036 9EF9 =2 4037 OKM: ; OK msg 9EF9 4F4B =2 4038 DB 'OK' 9EFB 0D0A =2 4039 DB ACR,ALF 9EFD 00 =2 4040 DB ANULL =2 4041 =2 4042 =2 4043 ;;;; diagnostics =2 4044 =2 4045 =2 4046 9EFE =2 4047 RDUMP: ; test code to dump registers =2 4048 ; A, R0 ... R7, B 9EFE C0E0 =2 4049 PUSH ACC ; save A on stack 9F00 743B =2 4050 MOV A,#';' 9F02 129226 =2 4051 CALL PUTCHAR 9F05 D0E0 =2 4052 POP ACC ; restore A from stack 9F07 C0E0 =2 4053 PUSH ACC ; save A on stack 9F09 12976E =2 4054 CALL PHXBYTE 9F0C 1297B8 =2 4055 CALL SPACE1 9F0F E8 =2 4056 MOV A,R0 9F10 12976E =2 4057 CALL PHXBYTE 9F13 1297B8 =2 4058 CALL SPACE1 9F16 E9 =2 4059 MOV A,R1 9F17 12976E =2 4060 CALL PHXBYTE 9F1A 1297B8 =2 4061 CALL SPACE1 9F1D EA =2 4062 MOV A,R2 9F1E 12976E =2 4063 CALL PHXBYTE 9F21 1297B8 =2 4064 CALL SPACE1 9F24 EB =2 4065 MOV A,R3 9F25 12976E =2 4066 CALL PHXBYTE 9F28 1297B8 =2 4067 CALL SPACE1 9F2B EC =2 4068 MOV A,R4 9F2C 12976E =2 4069 CALL PHXBYTE 9F2F 1297B8 =2 4070 CALL SPACE1 9F32 ED =2 4071 MOV A,R5 9F33 12976E =2 4072 CALL PHXBYTE 9F36 1297B8 =2 4073 CALL SPACE1 9F39 EE =2 4074 MOV A,R6 9F3A 12976E =2 4075 CALL PHXBYTE 9F3D 1297B8 =2 4076 CALL SPACE1 9F40 EF =2 4077 MOV A,R7 9F41 12976E =2 4078 CALL PHXBYTE 9F44 1297B8 =2 4079 CALL SPACE1 9F47 E5F0 =2 4080 MOV A,B 9F49 12976E =2 4081 CALL PHXBYTE MC2LDEV MC-2 Development 990419-2.00v PAGE 78 9F4C 1297B8 =2 4082 CALL SPACE1 9F4F 743B =2 4083 MOV A,#';' 9F51 129226 =2 4084 CALL PUTCHAR 9F54 129721 =2 4085 CALL CRLF 9F57 D0E0 =2 4086 POP ACC ; restore A from stack 9F59 22 =2 4087 RET =2 4088 9F5A =2 4089 ADUMP: ; test code to show ACC 9F5A C0E0 =2 4090 PUSH ACC 9F5C 743B =2 4091 MOV A,#';' 9F5E 129226 =2 4092 CALL PUTCHAR 9F61 D0E0 =2 4093 POP ACC 9F63 C0E0 =2 4094 PUSH ACC 9F65 12976E =2 4095 CALL PHXBYTE 9F68 1297B8 =2 4096 CALL SPACE 9F6B D0E0 =2 4097 POP ACC 9F6D 22 =2 4098 RET =2 4099 9F6E =2 4100 CDUMP: ; test code to show CY 9F6E C0E0 =2 4101 PUSH ACC 9F70 C0D0 =2 4102 PUSH PSW ; save flags 9F72 743B =2 4103 MOV A,#';' 9F74 129226 =2 4104 CALL PUTCHAR 9F77 D0D0 =2 4105 POP PSW ; recover CY 9F79 C0D0 =2 4106 PUSH PSW ; save again 9F7B E4 =2 4107 CLR A 9F7C 33 =2 4108 RLC A 9F7D 12977A =2 4109 CALL PHXCHAR ; print as 0/1 9F80 1297B8 =2 4110 CALL SPACE 9F83 D0D0 =2 4111 POP PSW ; restore flags 9F85 D0E0 =2 4112 POP ACC 9F87 22 =2 4113 RET =2 4114 9F88 =2 4115 FDUMP: ; test code to show Flags 9F88 C0E0 =2 4116 PUSH ACC 9F8A 743B =2 4117 MOV A,#';' 9F8C 129226 =2 4118 CALL PUTCHAR 9F8F E5D0 =2 4119 MOV A,PSW 9F91 12976E =2 4120 CALL PHXBYTE 9F94 1297B8 =2 4121 CALL SPACE 9F97 D0E0 =2 4122 POP ACC 9F99 22 =2 4123 RET =2 4124 9F9A =2 4125 R0DUMP: ; test code to show R0 9F9A C0E0 =2 4126 PUSH ACC 9F9C 742D =2 4127 MOV A,#'-' 9F9E 129226 =2 4128 CALL PUTCHAR 9FA1 E8 =2 4129 MOV A,R0 9FA2 12976E =2 4130 CALL PHXBYTE 9FA5 1297B8 =2 4131 CALL SPACE 9FA8 D0E0 =2 4132 POP ACC 9FAA 22 =2 4133 RET =1 4134 9FAB 00 =1 4135 PGMEND: DB 0 ; this byte ISN'T part of signon checksum =1 4136 =1 4137 4138 END VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND MC2LDEV MC-2 Development 990419-2.00v PAGE 79 A4TOBIN. . . . . . . . . . . . . C ADDR 982BH AAPOS. . . . . . . . . . . . . . NUMB 0027H NOT USED ABELL. . . . . . . . . . . . . . NUMB 0007H NOT USED ABSP . . . . . . . . . . . . . . NUMB 0008H ACC. . . . . . . . . . . . . . . D ADDR 00E0H PREDEFINED ACHANG . . . . . . . . . . . . . C ADDR 95F8H ACHG10 . . . . . . . . . . . . . C ADDR 95FEH ACHG20 . . . . . . . . . . . . . C ADDR 9604H ACHG30 . . . . . . . . . . . . . C ADDR 960DH ACHG40 . . . . . . . . . . . . . C ADDR 9613H ACHG50 . . . . . . . . . . . . . C ADDR 9618H ACHG60 . . . . . . . . . . . . . C ADDR 9619H ACHG99 . . . . . . . . . . . . . C ADDR 9633H ACHGM. . . . . . . . . . . . . . C ADDR 9EE3H ACHGMSK. . . . . . . . . . . . . NUMB 0027H ACR. . . . . . . . . . . . . . . NUMB 000DH ACTLC. . . . . . . . . . . . . . NUMB 0003H AD1. . . . . . . . . . . . . . . NUMB 0060H NOT USED AD15 . . . . . . . . . . . . . . NUMB 0061H NOT USED ADC01B . . . . . . . . . . . . . NUMB 0078H NOT USED ADC01R . . . . . . . . . . . . . NUMB 0079H NOT USED ADC23B . . . . . . . . . . . . . NUMB 0078H NOT USED ADC23R . . . . . . . . . . . . . NUMB 0079H NOT USED ADC45B . . . . . . . . . . . . . NUMB 0078H NOT USED ADC45R . . . . . . . . . . . . . NUMB 0079H NOT USED ADC67B . . . . . . . . . . . . . NUMB 0078H NOT USED ADC67R . . . . . . . . . . . . . NUMB 0079H NOT USED ADCFLG . . . . . . . . . . . . . NUMB 002FH ADCH0. . . . . . . . . . . . . . NUMB 004FH ADCH1. . . . . . . . . . . . . . NUMB 0051H NOT USED ADCH2. . . . . . . . . . . . . . NUMB 0053H NOT USED ADCH3. . . . . . . . . . . . . . NUMB 0055H NOT USED ADCH4. . . . . . . . . . . . . . NUMB 0057H NOT USED ADCH5. . . . . . . . . . . . . . NUMB 0059H NOT USED ADCH6. . . . . . . . . . . . . . NUMB 005BH NOT USED ADCH7. . . . . . . . . . . . . . NUMB 005DH ADCHAN . . . . . . . . . . . . . NUMB 001FH ADCO10 . . . . . . . . . . . . . C ADDR 92A0H ADCO20 . . . . . . . . . . . . . C ADDR 92AFH ADCONV . . . . . . . . . . . . . C ADDR 929BH ADCSN. . . . . . . . . . . . . . NUMB 0013H NOT USED ADCTYP . . . . . . . . . . . . . NUMB 002EH NOT USED ADEL . . . . . . . . . . . . . . NUMB 007FH ADI. . . . . . . . . . . . . . . NUMB 00B4H ADIS . . . . . . . . . . . . . . NUMB 002CH ADIS10 . . . . . . . . . . . . . C ADDR 9523H ADIS20 . . . . . . . . . . . . . C ADDR 952AH ADIS30 . . . . . . . . . . . . . C ADDR 9539H ADISCON. . . . . . . . . . . . . C ADDR 951DH ADISPM . . . . . . . . . . . . . C ADDR 9ED1H ADRC10 . . . . . . . . . . . . . C ADDR 9852H ADRC20 . . . . . . . . . . . . . C ADDR 9854H ADRC30 . . . . . . . . . . . . . C ADDR 985FH ADRC40 . . . . . . . . . . . . . C ADDR 9862H ADRCK. . . . . . . . . . . . . . C ADDR 984AH ADRE10 . . . . . . . . . . . . . C ADDR 98BDH ADRERR . . . . . . . . . . . . . C ADDR 98B4H ADUMP. . . . . . . . . . . . . . C ADDR 9F5AH MC2LDEV MC-2 Development 990419-2.00v PAGE 80 AERR . . . . . . . . . . . . . . NUMB 005FH AESC . . . . . . . . . . . . . . NUMB 001BH NOT USED AFLU . . . . . . . . . . . . . . NUMB 0063H ALF. . . . . . . . . . . . . . . NUMB 000AH ALI. . . . . . . . . . . . . . . C ADDR 9634H ALI10. . . . . . . . . . . . . . C ADDR 963CH ALI20. . . . . . . . . . . . . . C ADDR 9644H ALI99. . . . . . . . . . . . . . C ADDR 964AH AMAP . . . . . . . . . . . . . . C ADDR 95D6H AMAP10 . . . . . . . . . . . . . C ADDR 95E1H AMAP20 . . . . . . . . . . . . . C ADDR 95F1H AMAP99 . . . . . . . . . . . . . C ADDR 95F7H ANULL. . . . . . . . . . . . . . NUMB 0000H AONLI. . . . . . . . . . . . . . NUMB 002BH APHEX. . . . . . . . . . . . . . C ADDR 8E09H ASHEX. . . . . . . . . . . . . . C ADDR 8E17H NOT USED ASP. . . . . . . . . . . . . . . NUMB 0020H ATAB . . . . . . . . . . . . . . NUMB 0009H B. . . . . . . . . . . . . . . . D ADDR 00F0H PREDEFINED BITC05 . . . . . . . . . . . . . C ADDR 8ABFH BITC10 . . . . . . . . . . . . . C ADDR 8ACBH BITCLR . . . . . . . . . . . . . C ADDR 8AB7H BITD05 . . . . . . . . . . . . . C ADDR 8A72H BITD10 . . . . . . . . . . . . . C ADDR 8A75H BITD20 . . . . . . . . . . . . . C ADDR 8A78H BITD30 . . . . . . . . . . . . . C ADDR 8A80H BITDSP . . . . . . . . . . . . . C ADDR 8A6AH BITS05 . . . . . . . . . . . . . C ADDR 8AA4H BITS10 . . . . . . . . . . . . . C ADDR 8AB0H BITSET . . . . . . . . . . . . . C ADDR 8A9CH BITW05 . . . . . . . . . . . . . C ADDR 8ADBH BITW10 . . . . . . . . . . . . . C ADDR 8AE9H BITW20 . . . . . . . . . . . . . C ADDR 8AF4H BITWR. . . . . . . . . . . . . . C ADDR 8AD3H BYTD10 . . . . . . . . . . . . . C ADDR 8B00H BYTDSP . . . . . . . . . . . . . C ADDR 8AF8H BYTW10 . . . . . . . . . . . . . C ADDR 8B2FH BYTWR. . . . . . . . . . . . . . C ADDR 8B27H CCHAN0 . . . . . . . . . . . . . NUMB 003FH CCHAN1 . . . . . . . . . . . . . NUMB 0041H NOT USED CCHAN2 . . . . . . . . . . . . . NUMB 0043H NOT USED CCHAN3 . . . . . . . . . . . . . NUMB 0045H NOT USED CCHAN4 . . . . . . . . . . . . . NUMB 0047H NOT USED CCHAN5 . . . . . . . . . . . . . NUMB 0049H NOT USED CCHAN6 . . . . . . . . . . . . . NUMB 004BH NOT USED CCHAN7 . . . . . . . . . . . . . NUMB 004DH CDUMP. . . . . . . . . . . . . . C ADDR 9F6EH CH0. . . . . . . . . . . . . . . NUMB 0067H CH1. . . . . . . . . . . . . . . NUMB 0068H NOT USED CH2. . . . . . . . . . . . . . . NUMB 0069H NOT USED CHAR20 . . . . . . . . . . . . . C ADDR 97E8H CHAR30 . . . . . . . . . . . . . C ADDR 97FAH CHAR40 . . . . . . . . . . . . . C ADDR 980CH CHARHX . . . . . . . . . . . . . C ADDR 97D6H CKSMSG . . . . . . . . . . . . . C ADDR 9964H CKST10 . . . . . . . . . . . . . C ADDR 9956H CKST20 . . . . . . . . . . . . . C ADDR 995CH CKSTACK. . . . . . . . . . . . . C ADDR 9954H MC2LDEV MC-2 Development 990419-2.00v PAGE 81 CLKBUF . . . . . . . . . . . . . NUMB 0070H CMDE10 . . . . . . . . . . . . . C ADDR 989CH CMDERR . . . . . . . . . . . . . C ADDR 9893H CMDMRK . . . . . . . . . . . . . NUMB 003DH CMDO10 . . . . . . . . . . . . . C ADDR 9886H CMDOK. . . . . . . . . . . . . . C ADDR 987DH CMDP05 . . . . . . . . . . . . . C ADDR 8F07H CMDP10 . . . . . . . . . . . . . C ADDR 8F0FH CMDP12 . . . . . . . . . . . . . C ADDR 8F18H CMDP15 . . . . . . . . . . . . . C ADDR 8F21H CMDP20 . . . . . . . . . . . . . C ADDR 8F29H CMDP22 . . . . . . . . . . . . . C ADDR 8F2EH CMDP24 . . . . . . . . . . . . . C ADDR 8F33H CMDP26 . . . . . . . . . . . . . C ADDR 8F39H CMDP28 . . . . . . . . . . . . . C ADDR 8F3FH CMDP30 . . . . . . . . . . . . . C ADDR 8F48H CMDP32 . . . . . . . . . . . . . C ADDR 8F4DH CMDP34 . . . . . . . . . . . . . C ADDR 8F52H CMDP36 . . . . . . . . . . . . . C ADDR 8F58H CMDP38 . . . . . . . . . . . . . C ADDR 8F6BH CMDP40 . . . . . . . . . . . . . C ADDR 8F71H CMDP42 . . . . . . . . . . . . . C ADDR 8F77H CMDP44 . . . . . . . . . . . . . C ADDR 8F7DH CMDP46 . . . . . . . . . . . . . C ADDR 8F83H CMDP48 . . . . . . . . . . . . . C ADDR 8F88H CMDP50 . . . . . . . . . . . . . C ADDR 8F8EH CMDPROC. . . . . . . . . . . . . C ADDR 8F01H CPU8052. . . . . . . . . . . . . NUMB 0001H NOT USED CPUT10 . . . . . . . . . . . . . C ADDR 9733H CPUTS. . . . . . . . . . . . . . C ADDR 972EH CPYRIT . . . . . . . . . . . . . C ADDR 8803H NOT USED CRANKRN. . . . . . . . . . . . . C ADDR 947BH CRLF . . . . . . . . . . . . . . C ADDR 9721H CRLF1. . . . . . . . . . . . . . C ADDR 9721H NOT USED CRLF2. . . . . . . . . . . . . . C ADDR 971EH CTRCHAN. . . . . . . . . . . . . NUMB 001EH CTSRI. . . . . . . . . . . . . . NUMB 0015H NOT USED CY . . . . . . . . . . . . . . . B ADDR 00D7H PREDEFINED DAMAP. . . . . . . . . . . . . . NUMB 0004H DAYPTR . . . . . . . . . . . . . C ADDR 8EE4H DCD. . . . . . . . . . . . . . . NUMB 0014H DCDSEC . . . . . . . . . . . . . NUMB 006AH DCDTRY . . . . . . . . . . . . . NUMB 006BH DEADC. . . . . . . . . . . . . . C ADDR 92C9H DEFA10 . . . . . . . . . . . . . C ADDR 8A51H DEFA20 . . . . . . . . . . . . . C ADDR 8A59H DEFAULT. . . . . . . . . . . . . C ADDR 8A4AH DEV. . . . . . . . . . . . . . . NUMB 0001H DIAGNO . . . . . . . . . . . . . C ADDR 92D4H NOT USED DOFC10 . . . . . . . . . . . . . C ADDR 9181H DOFC20 . . . . . . . . . . . . . C ADDR 9195H DOFC30 . . . . . . . . . . . . . C ADDR 919FH DOFCTR . . . . . . . . . . . . . C ADDR 917CH DPATDP . . . . . . . . . . . . . C ADDR 97C1H NOT USED DPH. . . . . . . . . . . . . . . D ADDR 0083H PREDEFINED DPL. . . . . . . . . . . . . . . D ADDR 0082H PREDEFINED DSR. . . . . . . . . . . . . . . NUMB 0016H NOT USED DTR. . . . . . . . . . . . . . . NUMB 0010H MC2LDEV MC-2 Development 990419-2.00v PAGE 82 EA . . . . . . . . . . . . . . . B ADDR 00AFH PREDEFINED EECO10 . . . . . . . . . . . . . C ADDR 8FC4H EECO20 . . . . . . . . . . . . . C ADDR 8FC7H EECO30 . . . . . . . . . . . . . C ADDR 8FD8H EECO40 . . . . . . . . . . . . . C ADDR 8FE2H EECO45 . . . . . . . . . . . . . C ADDR 8FEBH EECO50 . . . . . . . . . . . . . C ADDR 8FF1H EECO95 . . . . . . . . . . . . . C ADDR 8FF4H EECOMND. . . . . . . . . . . . . C ADDR 8FB4H EEPD10 . . . . . . . . . . . . . C ADDR 9907H EEPDERR. . . . . . . . . . . . . C ADDR 98FEH EEPT10 . . . . . . . . . . . . . C ADDR 98DEH EEPTERR. . . . . . . . . . . . . C ADDR 98D5H EERDB10. . . . . . . . . . . . . C ADDR 894CH EERDBK . . . . . . . . . . . . . C ADDR 892CH EEREA10. . . . . . . . . . . . . C ADDR 8910H EEREA20. . . . . . . . . . . . . C ADDR 891AH EEREAD . . . . . . . . . . . . . C ADDR 8902H EEWR . . . . . . . . . . . . . . C ADDR 8964H EEWR10 . . . . . . . . . . . . . C ADDR 8979H EEWR20 . . . . . . . . . . . . . C ADDR 897CH EEWRB10. . . . . . . . . . . . . C ADDR 8958H EEWRB20. . . . . . . . . . . . . C ADDR 8960H EEWRBK . . . . . . . . . . . . . C ADDR 8950H EEWRI10. . . . . . . . . . . . . C ADDR 8921H NOT USED EEWRITE. . . . . . . . . . . . . C ADDR 891BH NOT USED ENADC. . . . . . . . . . . . . . C ADDR 92BEH EPUT10 . . . . . . . . . . . . . C ADDR 9816H EPUTC. . . . . . . . . . . . . . C ADDR 9810H EXPIN. . . . . . . . . . . . . . NUMB 0017H NOT USED FALSE. . . . . . . . . . . . . . NUMB 0000H FCTR . . . . . . . . . . . . . . NUMB 00B5H NOT USED FDIS95 . . . . . . . . . . . . . C ADDR 9578H FDIS96 . . . . . . . . . . . . . C ADDR 959CH FDIS97 . . . . . . . . . . . . . C ADDR 95A0H FDIS98 . . . . . . . . . . . . . C ADDR 95A4H FDISCON. . . . . . . . . . . . . C ADDR 953AH FDUMP. . . . . . . . . . . . . . C ADDR 9F88H NOT USED FLOA10 . . . . . . . . . . . . . C ADDR 901EH FLOA12 . . . . . . . . . . . . . C ADDR 9028H FLOA15 . . . . . . . . . . . . . C ADDR 9032H FLOA20 . . . . . . . . . . . . . C ADDR 903CH FLOA35 . . . . . . . . . . . . . C ADDR 9043H FLOA37 . . . . . . . . . . . . . C ADDR 9046H FLOA40 . . . . . . . . . . . . . C ADDR 904DH FLOA49 . . . . . . . . . . . . . C ADDR 9065H FLOA50 . . . . . . . . . . . . . C ADDR 9068H FLOA60 . . . . . . . . . . . . . C ADDR 906FH FLOA70 . . . . . . . . . . . . . C ADDR 90B6H FLOA75 . . . . . . . . . . . . . C ADDR 90CAH FLOAD. . . . . . . . . . . . . . C ADDR 900CH FSR. . . . . . . . . . . . . . . NUMB 0062H GAUTHV . . . . . . . . . . . . . C ADDR 9511H GENC10 . . . . . . . . . . . . . C ADDR 944FH GENCHAL. . . . . . . . . . . . . C ADDR 944BH GETCHAR. . . . . . . . . . . . . C ADDR 9219H GETCLK . . . . . . . . . . . . . C ADDR 8DE4H GETG10 . . . . . . . . . . . . . C ADDR 92F3H MC2LDEV MC-2 Development 990419-2.00v PAGE 83 GETG20 . . . . . . . . . . . . . C ADDR 92FCH GETG30 . . . . . . . . . . . . . C ADDR 930AH GETG40 . . . . . . . . . . . . . C ADDR 931DH GETG50 . . . . . . . . . . . . . C ADDR 931FH GETG55 . . . . . . . . . . . . . C ADDR 9322H GETG60 . . . . . . . . . . . . . C ADDR 9333H GETGP. . . . . . . . . . . . . . C ADDR 92EEH GHXR0. . . . . . . . . . . . . . C ADDR 981CH GPCH10 . . . . . . . . . . . . . C ADDR 9466H GPCH20 . . . . . . . . . . . . . C ADDR 9474H GPCHAL . . . . . . . . . . . . . C ADDR 9457H GWORD. . . . . . . . . . . . . . C ADDR 8B6DH HELPMSG. . . . . . . . . . . . . C ADDR 9971H I2C751 . . . . . . . . . . . . . NUMB 0000H I2CADC . . . . . . . . . . . . . NUMB 0090H NOT USED I2CBB. . . . . . . . . . . . . . NUMB 0001H I2CCLK . . . . . . . . . . . . . NUMB 00A0H I2CEEP . . . . . . . . . . . . . NUMB 00A4H I2CEXP . . . . . . . . . . . . . NUMB 0040H NOT USED I2CFLT . . . . . . . . . . . . . NUMB 000DH I2CIP. . . . . . . . . . . . . . NUMB 000BH I2CLK. . . . . . . . . . . . . . NUMB 0096H I2CNACK. . . . . . . . . . . . . NUMB 000EH I2CTON . . . . . . . . . . . . . NUMB 0048H NOT USED I2CUCW . . . . . . . . . . . . . NUMB 000CH I2CX . . . . . . . . . . . . . . NUMB 000FH I2DAT. . . . . . . . . . . . . . NUMB 0097H I2DELAY. . . . . . . . . . . . . C ADDR 8A30H I2HICLK. . . . . . . . . . . . . C ADDR 8A19H I2HIDAT. . . . . . . . . . . . . C ADDR 8A26H I2LOCLK. . . . . . . . . . . . . C ADDR 8A21H I2LODAT. . . . . . . . . . . . . C ADDR 8A2BH I2RBY10. . . . . . . . . . . . . C ADDR 89DEH I2RBY20. . . . . . . . . . . . . C ADDR 89EEH I2RBY30. . . . . . . . . . . . . C ADDR 89F0H I2RBYT . . . . . . . . . . . . . C ADDR 89DCH I2RS10 . . . . . . . . . . . . . C ADDR 8997H I2RS20 . . . . . . . . . . . . . C ADDR 899DH I2RSTR . . . . . . . . . . . . . C ADDR 8992H I2SCW. . . . . . . . . . . . . . C ADDR 89B5H I2ST10 . . . . . . . . . . . . . C ADDR 89D6H I2ST20 . . . . . . . . . . . . . C ADDR 89D7H I2STAR . . . . . . . . . . . . . C ADDR 89BAH I2STOP . . . . . . . . . . . . . C ADDR 8A10H I2TBY10. . . . . . . . . . . . . C ADDR 89F9H I2TBY20. . . . . . . . . . . . . C ADDR 8A0DH I2TBYT . . . . . . . . . . . . . C ADDR 89F7H I2TS10 . . . . . . . . . . . . . C ADDR 89A7H I2TS20 . . . . . . . . . . . . . C ADDR 89B0H I2TSTR . . . . . . . . . . . . . C ADDR 89A2H IE . . . . . . . . . . . . . . . D ADDR 00A8H PREDEFINED ILBUF. . . . . . . . . . . . . . C ADDR 9349H INCR10 . . . . . . . . . . . . . C ADDR 8BB9H INCR123. . . . . . . . . . . . . C ADDR 8BB1H INCR20 . . . . . . . . . . . . . C ADDR 8BC1H INITMEM. . . . . . . . . . . . . C ADDR 97D5H INITPP . . . . . . . . . . . . . C ADDR 91EEH INITSP . . . . . . . . . . . . . C ADDR 91FBH MC2LDEV MC-2 Development 990419-2.00v PAGE 84 INITTI . . . . . . . . . . . . . C ADDR 91D8H INTR20 . . . . . . . . . . . . . C ADDR 9130H NOT USED INTR30 . . . . . . . . . . . . . C ADDR 9147H INTR50 . . . . . . . . . . . . . C ADDR 915DH INTR60 . . . . . . . . . . . . . C ADDR 9167H INTR70 . . . . . . . . . . . . . C ADDR 9173H INTRPT . . . . . . . . . . . . . C ADDR 9125H INVI . . . . . . . . . . . . . . NUMB 0030H IOUP10 . . . . . . . . . . . . . C ADDR 924FH IOUPDAT. . . . . . . . . . . . . C ADDR 923EH IP . . . . . . . . . . . . . . . D ADDR 00B8H PREDEFINED ISEC . . . . . . . . . . . . . . NUMB 001CH LBLE10 . . . . . . . . . . . . . C ADDR 9382H LBLE20 . . . . . . . . . . . . . C ADDR 9389H LBLEN. . . . . . . . . . . . . . C ADDR 937EH LBUF . . . . . . . . . . . . . . NUMB 000EH LBUFC. . . . . . . . . . . . . . NUMB 000CH LBUFP. . . . . . . . . . . . . . NUMB 000DH LBUFSZ . . . . . . . . . . . . . NUMB 000CH LCKT10 . . . . . . . . . . . . . C ADDR 95B1H LCKTIME. . . . . . . . . . . . . C ADDR 95AAH LDPR0. . . . . . . . . . . . . . NUMB 005FH LDPR1. . . . . . . . . . . . . . NUMB 0060H NOT USED LDPR2. . . . . . . . . . . . . . NUMB 0061H NOT USED LDPR3. . . . . . . . . . . . . . NUMB 0062H NOT USED LDPR4. . . . . . . . . . . . . . NUMB 0063H NOT USED LGISTAT. . . . . . . . . . . . . NUMB 0005H LITIME . . . . . . . . . . . . . NUMB 003CH LITRY. . . . . . . . . . . . . . NUMB 0004H LOGI10 . . . . . . . . . . . . . C ADDR 9391H LOGI20 . . . . . . . . . . . . . C ADDR 9399H LOGI50 . . . . . . . . . . . . . C ADDR 93A3H LOGI55 . . . . . . . . . . . . . C ADDR 93A7H LOGI60 . . . . . . . . . . . . . C ADDR 93BCH LOGI63 . . . . . . . . . . . . . C ADDR 93C9H LOGI65 . . . . . . . . . . . . . C ADDR 93CBH LOGI70 . . . . . . . . . . . . . C ADDR 93D8H LOGI75 . . . . . . . . . . . . . C ADDR 93F9H LOGI80 . . . . . . . . . . . . . C ADDR 9418H LOGI85 . . . . . . . . . . . . . C ADDR 9424H LOGI90 . . . . . . . . . . . . . C ADDR 9430H LOGI93 . . . . . . . . . . . . . C ADDR 943CH LOGIN. . . . . . . . . . . . . . C ADDR 938BH LOOP . . . . . . . . . . . . . . C ADDR 95BCH MAIN . . . . . . . . . . . . . . C ADDR 95BCH MAP0M. . . . . . . . . . . . . . C ADDR 9CA6H MAP0MA . . . . . . . . . . . . . C ADDR 9CF9H MAP1M. . . . . . . . . . . . . . C ADDR 9D10H MAP2M. . . . . . . . . . . . . . C ADDR 9D4BH MAP3M. . . . . . . . . . . . . . C ADDR 9DA0H MAP3MA . . . . . . . . . . . . . C ADDR 9D65H MAP4M. . . . . . . . . . . . . . C ADDR 9DBAH MAP5M. . . . . . . . . . . . . . C ADDR 9E77H MAP6M. . . . . . . . . . . . . . C ADDR 9E96H MAP7M. . . . . . . . . . . . . . C ADDR 9EB7H MAPC . . . . . . . . . . . . . . C ADDR 9351H MAPC10 . . . . . . . . . . . . . C ADDR 9357H MAPC20 . . . . . . . . . . . . . C ADDR 935DH MC2LDEV MC-2 Development 990419-2.00v PAGE 85 MAPC30 . . . . . . . . . . . . . C ADDR 9361H MAPC35 . . . . . . . . . . . . . C ADDR 9365H MAPC40 . . . . . . . . . . . . . C ADDR 936CH MAPD20 . . . . . . . . . . . . . C ADDR 8C39H MAPD30 . . . . . . . . . . . . . C ADDR 8C55H MAPDISP. . . . . . . . . . . . . C ADDR 8BEEH MAPU10 . . . . . . . . . . . . . C ADDR 9374H MAPU20 . . . . . . . . . . . . . C ADDR 937AH MAPUC. . . . . . . . . . . . . . C ADDR 936DH MS10CTR. . . . . . . . . . . . . NUMB 001BH MUX0 . . . . . . . . . . . . . . NUMB 0090H NOT USED MUX1 . . . . . . . . . . . . . . NUMB 0091H NOT USED MUX2 . . . . . . . . . . . . . . NUMB 0092H NOT USED MXOADR . . . . . . . . . . . . . NUMB 0032H MXRADR . . . . . . . . . . . . . NUMB 0007H NCSEC. . . . . . . . . . . . . . NUMB 0002H NECHO. . . . . . . . . . . . . . NUMB 002DH NINVO. . . . . . . . . . . . . . NUMB 0031H NLF. . . . . . . . . . . . . . . NUMB 002EH NULL . . . . . . . . . . . . . . C ADDR 8800H NOT USED NVCHKL . . . . . . . . . . . . . NUMB 0011H NVRAM. . . . . . . . . . . . . . NUMB 0024H NVRAML . . . . . . . . . . . . . NUMB 0011H OKM. . . . . . . . . . . . . . . C ADDR 9EF9H OPTI10 . . . . . . . . . . . . . C ADDR 90DAH OPTI30 . . . . . . . . . . . . . C ADDR 90F1H OPTI32 . . . . . . . . . . . . . C ADDR 9103H OPTI34 . . . . . . . . . . . . . C ADDR 910FH OPTI98 . . . . . . . . . . . . . C ADDR 911BH OPTI99 . . . . . . . . . . . . . C ADDR 9122H OPTION . . . . . . . . . . . . . C ADDR 90D2H OSTAT0 . . . . . . . . . . . . . NUMB 002CH P1 . . . . . . . . . . . . . . . D ADDR 0090H PREDEFINED P3 . . . . . . . . . . . . . . . D ADDR 00B0H PREDEFINED PALSTR . . . . . . . . . . . . . C ADDR 8E77H PAUT10 . . . . . . . . . . . . . C ADDR 949DH PAUT20 . . . . . . . . . . . . . C ADDR 94AEH PAUT25 . . . . . . . . . . . . . C ADDR 94C0H PAUT30 . . . . . . . . . . . . . C ADDR 94DCH PAUT40 . . . . . . . . . . . . . C ADDR 94EDH PAUT91 . . . . . . . . . . . . . C ADDR 9503H PAUT92 . . . . . . . . . . . . . C ADDR 950AH PAUTAB . . . . . . . . . . . . . C ADDR 9490H PBIN . . . . . . . . . . . . . . C ADDR 8BC7H PBIN10 . . . . . . . . . . . . . C ADDR 97A8H PBIN20 . . . . . . . . . . . . . C ADDR 97AAH PBINBIT. . . . . . . . . . . . . C ADDR 979FH PBYT10 . . . . . . . . . . . . . C ADDR 978DH PBYT20 . . . . . . . . . . . . . C ADDR 9798H PBYTBIT. . . . . . . . . . . . . C ADDR 978BH PCKS10 . . . . . . . . . . . . . C ADDR 973FH PCKS20 . . . . . . . . . . . . . C ADDR 9746H PCKSUM . . . . . . . . . . . . . C ADDR 9738H PCON . . . . . . . . . . . . . . D ADDR 0087H PREDEFINED PDPTR. . . . . . . . . . . . . . C ADDR 9763H NOT USED PDTSTR . . . . . . . . . . . . . C ADDR 8E1FH PGMBAS . . . . . . . . . . . . . NUMB 8800H PGMEND . . . . . . . . . . . . . C ADDR 9FABH MC2LDEV MC-2 Development 990419-2.00v PAGE 86 PHXBYTE. . . . . . . . . . . . . C ADDR 976EH PHXC10 . . . . . . . . . . . . . C ADDR 9786H PHXC20 . . . . . . . . . . . . . C ADDR 9788H PHXCHAR. . . . . . . . . . . . . C ADDR 977AH PNBBIT . . . . . . . . . . . . . C ADDR 8BE3H PP1A . . . . . . . . . . . . . . NUMB F8FCH PP1B . . . . . . . . . . . . . . NUMB F8FDH PP1BAS . . . . . . . . . . . . . NUMB F8FCH PP1C . . . . . . . . . . . . . . NUMB F8FEH PP1T . . . . . . . . . . . . . . NUMB F8FFH PP2A . . . . . . . . . . . . . . NUMB F8FCH NOT USED PP2B . . . . . . . . . . . . . . NUMB F8FDH NOT USED PP2BAS . . . . . . . . . . . . . NUMB F8FCH PP2C . . . . . . . . . . . . . . NUMB F8FEH NOT USED PP2T . . . . . . . . . . . . . . NUMB F8FFH NOT USED PR0CIMG. . . . . . . . . . . . . NUMB 003AH PR0IMG . . . . . . . . . . . . . NUMB 0035H PR1CIMG. . . . . . . . . . . . . NUMB 003BH PR1IMG . . . . . . . . . . . . . NUMB 0036H NOT USED PR2CIMG. . . . . . . . . . . . . NUMB 003CH PR2IMG . . . . . . . . . . . . . NUMB 0037H NOT USED PR3CIMG. . . . . . . . . . . . . NUMB 003DH PR3IMG . . . . . . . . . . . . . NUMB 0038H NOT USED PR4CIMG. . . . . . . . . . . . . NUMB 003EH PR4IMG . . . . . . . . . . . . . NUMB 0039H PR6HX. . . . . . . . . . . . . . C ADDR 9817H PSTN10 . . . . . . . . . . . . . C ADDR 987CH NOT USED PSTNADM. . . . . . . . . . . . . C ADDR 986AH PSW. . . . . . . . . . . . . . . D ADDR 00D0H PREDEFINED PSWD0. . . . . . . . . . . . . . NUMB 0028H PSWD1. . . . . . . . . . . . . . NUMB 0029H PSWD2. . . . . . . . . . . . . . NUMB 002AH PT0IMG . . . . . . . . . . . . . NUMB 0030H PT1IMG . . . . . . . . . . . . . NUMB 0031H NOT USED PT2IMG . . . . . . . . . . . . . NUMB 0032H NOT USED PT3IMG . . . . . . . . . . . . . NUMB 0033H NOT USED PT4IMG . . . . . . . . . . . . . NUMB 0034H PULC10 . . . . . . . . . . . . . C ADDR 91C1H PULC20 . . . . . . . . . . . . . C ADDR 91D3H PULC30 . . . . . . . . . . . . . C ADDR 91D5H PULC40 . . . . . . . . . . . . . C ADDR 91D7H NOT USED PULCTR . . . . . . . . . . . . . C ADDR 91B0H PULCTR0. . . . . . . . . . . . . NUMB 0068H NOT USED PULCTR1. . . . . . . . . . . . . NUMB 0069H NOT USED PULCTR2. . . . . . . . . . . . . NUMB 006AH NOT USED PULCTR3. . . . . . . . . . . . . NUMB 006BH NOT USED PULCTR4. . . . . . . . . . . . . NUMB 006CH NOT USED PULCTR5. . . . . . . . . . . . . NUMB 006DH NOT USED PULCTR6. . . . . . . . . . . . . NUMB 006EH NOT USED PULCTR7. . . . . . . . . . . . . NUMB 006FH NOT USED PULFLG . . . . . . . . . . . . . NUMB 002DH PULOLD . . . . . . . . . . . . . NUMB 006CH PUTC05 . . . . . . . . . . . . . C ADDR 922FH PUTC10 . . . . . . . . . . . . . C ADDR 9239H PUTC20 . . . . . . . . . . . . . C ADDR 923DH PUTCHAR. . . . . . . . . . . . . C ADDR 9226H PUTCLK . . . . . . . . . . . . . C ADDR 8DF9H PWRD10 . . . . . . . . . . . . . C ADDR 8B93H MC2LDEV MC-2 Development 990419-2.00v PAGE 87 PWRD15 . . . . . . . . . . . . . C ADDR 8B9EH PWRD20 . . . . . . . . . . . . . C ADDR 8BA4H PWRDDEC. . . . . . . . . . . . . C ADDR 8B81H QINT0. . . . . . . . . . . . . . NUMB 00B2H NOT USED QRD. . . . . . . . . . . . . . . NUMB 00B6H NOT USED QRXD . . . . . . . . . . . . . . NUMB 00B0H NOT USED QTXD . . . . . . . . . . . . . . NUMB 00B1H NOT USED QWR. . . . . . . . . . . . . . . NUMB 00B7H NOT USED R0DUMP . . . . . . . . . . . . . C ADDR 9F9AH NOT USED R2ST10 . . . . . . . . . . . . . C ADDR 8EDCH R2STR. . . . . . . . . . . . . . C ADDR 8ED8H RAMV . . . . . . . . . . . . . . C ADDR 8A38H RAMV10 . . . . . . . . . . . . . C ADDR 8A3DH RAMV20 . . . . . . . . . . . . . C ADDR 8A49H RB0. . . . . . . . . . . . . . . NUMB 0000H RB1. . . . . . . . . . . . . . . NUMB 0008H RB2. . . . . . . . . . . . . . . NUMB 0010H NOT USED RB3. . . . . . . . . . . . . . . NUMB 0018H NOT USED RBRDY. . . . . . . . . . . . . . C ADDR 920DH RCAP2H . . . . . . . . . . . . . D ADDR 00CBH PREDEFINED RCAP2L . . . . . . . . . . . . . D ADDR 00CAH PREDEFINED RDCM10 . . . . . . . . . . . . . C ADDR 8F98H RDCM20 . . . . . . . . . . . . . C ADDR 8F9DH RDCM30 . . . . . . . . . . . . . C ADDR 8FA2H RDCMD. . . . . . . . . . . . . . C ADDR 8F91H RDUMP. . . . . . . . . . . . . . C ADDR 9EFEH NOT USED RI . . . . . . . . . . . . . . . B ADDR 0098H PREDEFINED RIDX . . . . . . . . . . . . . . NUMB 002CH RN0. . . . . . . . . . . . . . . NUMB 0064H RN1. . . . . . . . . . . . . . . NUMB 0065H NOT USED RN2. . . . . . . . . . . . . . . NUMB 0066H NOT USED RSTAT0 . . . . . . . . . . . . . NUMB 0025H RSTAT1 . . . . . . . . . . . . . NUMB 0026H RTS. . . . . . . . . . . . . . . NUMB 0011H NOT USED SALARM . . . . . . . . . . . . . C ADDR 8D60H SALM10 . . . . . . . . . . . . . C ADDR 8D6CH NOT USED SALM20 . . . . . . . . . . . . . C ADDR 8D73H SALM30 . . . . . . . . . . . . . C ADDR 8D95H SALM40 . . . . . . . . . . . . . C ADDR 8DADH SALM50 . . . . . . . . . . . . . C ADDR 8DBCH SALM60 . . . . . . . . . . . . . C ADDR 8DCEH SALM98 . . . . . . . . . . . . . C ADDR 8DDAH SALM99 . . . . . . . . . . . . . C ADDR 8DE1H SBUF . . . . . . . . . . . . . . D ADDR 0099H PREDEFINED SCON . . . . . . . . . . . . . . D ADDR 0098H PREDEFINED SF0. . . . . . . . . . . . . . . NUMB 0020H SF1. . . . . . . . . . . . . . . NUMB 0021H SF2. . . . . . . . . . . . . . . NUMB 0022H SIGNMSG. . . . . . . . . . . . . C ADDR 8803H SIGNON . . . . . . . . . . . . . C ADDR 9714H SMR7 . . . . . . . . . . . . . . C ADDR 9864H SP . . . . . . . . . . . . . . . D ADDR 0081H PREDEFINED SPACE. . . . . . . . . . . . . . C ADDR 97B8H SPACE1 . . . . . . . . . . . . . C ADDR 97B8H SPACE2 . . . . . . . . . . . . . C ADDR 97B5H SPACE3 . . . . . . . . . . . . . C ADDR 97B2H NOT USED SPACE4 . . . . . . . . . . . . . C ADDR 97AFH SPS0 . . . . . . . . . . . . . . NUMB 0028H NOT USED MC2LDEV MC-2 Development 990419-2.00v PAGE 88 SPS1 . . . . . . . . . . . . . . NUMB 0029H NOT USED SPS2 . . . . . . . . . . . . . . NUMB 002AH NOT USED SSPE10 . . . . . . . . . . . . . C ADDR 9659H SSPE20 . . . . . . . . . . . . . C ADDR 9663H SSPE30 . . . . . . . . . . . . . C ADDR 966DH SSPE40 . . . . . . . . . . . . . C ADDR 9677H SSPE50 . . . . . . . . . . . . . C ADDR 9681H SSPE60 . . . . . . . . . . . . . C ADDR 968BH SSPE70 . . . . . . . . . . . . . C ADDR 9695H SSPE80 . . . . . . . . . . . . . C ADDR 969FH SSPEED . . . . . . . . . . . . . C ADDR 964BH STAR10 . . . . . . . . . . . . . C ADDR 88ADH STAR20 . . . . . . . . . . . . . C ADDR 88EBH STAR30 . . . . . . . . . . . . . C ADDR 88F9H STAR40 . . . . . . . . . . . . . C ADDR 88FFH START. . . . . . . . . . . . . . C ADDR 88A6H STIM10 . . . . . . . . . . . . . C ADDR 8C86H NOT USED STIM20 . . . . . . . . . . . . . C ADDR 8C90H STIM22 . . . . . . . . . . . . . C ADDR 8C98H STIM24 . . . . . . . . . . . . . C ADDR 8C9BH STIM26 . . . . . . . . . . . . . C ADDR 8CA7H STIM30 . . . . . . . . . . . . . C ADDR 8CD7H STIM40 . . . . . . . . . . . . . C ADDR 8CEFH STIM50 . . . . . . . . . . . . . C ADDR 8D00H STIM52 . . . . . . . . . . . . . C ADDR 8D12H STIM54 . . . . . . . . . . . . . C ADDR 8D19H STIM55 . . . . . . . . . . . . . C ADDR 8D27H STIM57 . . . . . . . . . . . . . C ADDR 8D2EH STIM60 . . . . . . . . . . . . . C ADDR 8D38H STIM61 . . . . . . . . . . . . . C ADDR 8D3BH STIM62 . . . . . . . . . . . . . C ADDR 8D40H STIM98 . . . . . . . . . . . . . C ADDR 8D53H STIM99 . . . . . . . . . . . . . C ADDR 8D5DH STIME. . . . . . . . . . . . . . C ADDR 8C78H STKBAS . . . . . . . . . . . . . NUMB 00B0H STNADR . . . . . . . . . . . . . NUMB 002BH SYSA10 . . . . . . . . . . . . . C ADDR 992CH SYSADMN. . . . . . . . . . . . . NUMB 0006H SYSAERR. . . . . . . . . . . . . C ADDR 9923H T1 . . . . . . . . . . . . . . . B ADDR 00B5H PREDEFINED T2CON. . . . . . . . . . . . . . D ADDR 00C8H PREDEFINED TBRDY. . . . . . . . . . . . . . C ADDR 9213H NOT USED TCTR . . . . . . . . . . . . . . NUMB 001AH TH0. . . . . . . . . . . . . . . D ADDR 008CH PREDEFINED TH1. . . . . . . . . . . . . . . D ADDR 008DH PREDEFINED TI . . . . . . . . . . . . . . . B ADDR 0099H PREDEFINED TL0OVF . . . . . . . . . . . . . NUMB 001DH NOT USED TL1. . . . . . . . . . . . . . . D ADDR 008BH PREDEFINED TMOD . . . . . . . . . . . . . . D ADDR 0089H PREDEFINED TMPB0. . . . . . . . . . . . . . NUMB 0000H TMPB1. . . . . . . . . . . . . . NUMB 0001H TR0. . . . . . . . . . . . . . . B ADDR 008CH PREDEFINED TR1. . . . . . . . . . . . . . . B ADDR 008EH PREDEFINED TRUE . . . . . . . . . . . . . . NUMB 0001H TXD. . . . . . . . . . . . . . . B ADDR 00B1H PREDEFINED UARTINT. . . . . . . . . . . . . NUMB 0001H UCOM . . . . . . . . . . . . . . NUMB 0001H NOT USED UDAD10 . . . . . . . . . . . . . C ADDR 96AAH MC2LDEV MC-2 Development 990419-2.00v PAGE 89 UDAD20 . . . . . . . . . . . . . C ADDR 96B1H UDAD30 . . . . . . . . . . . . . C ADDR 96BAH UDAD40 . . . . . . . . . . . . . C ADDR 96E2H UDADCON. . . . . . . . . . . . . C ADDR 96A0H UDPCX. . . . . . . . . . . . . . C ADDR 926DH UDPR0. . . . . . . . . . . . . . C ADDR 9250H UDPR010. . . . . . . . . . . . . C ADDR 9258H UDPT0. . . . . . . . . . . . . . C ADDR 9262H UDPT010. . . . . . . . . . . . . C ADDR 926BH UDSY10 . . . . . . . . . . . . . C ADDR 9287H UDSY20 . . . . . . . . . . . . . C ADDR 928EH UDSYS. . . . . . . . . . . . . . C ADDR 9281H VALP0. . . . . . . . . . . . . . NUMB 0001H NOT USED VALP2. . . . . . . . . . . . . . NUMB 0001H NOT USED VALP4. . . . . . . . . . . . . . NUMB 0000H NOT USED VALP5. . . . . . . . . . . . . . NUMB 0000H NOT USED VALP6. . . . . . . . . . . . . . NUMB 0000H NOT USED VALRAM . . . . . . . . . . . . . C ADDR 8A33H VERMSG . . . . . . . . . . . . . C ADDR 8803H NOT USED VIE0 . . . . . . . . . . . . . . NUMB EFFDH NOT USED VIE1 . . . . . . . . . . . . . . NUMB EFF7H NOT USED VRITI. . . . . . . . . . . . . . NUMB EFF1H NOT USED VTF0 . . . . . . . . . . . . . . NUMB EFFAH VTF1 . . . . . . . . . . . . . . NUMB EFF4H NOT USED W2US . . . . . . . . . . . . . . C ADDR 8983H NOT USED W30M10 . . . . . . . . . . . . . C ADDR 898BH W30M20 . . . . . . . . . . . . . C ADDR 898DH W30MS. . . . . . . . . . . . . . C ADDR 8989H W60MS. . . . . . . . . . . . . . C ADDR 8986H WDT. . . . . . . . . . . . . . . NUMB 0093H WDTFLG . . . . . . . . . . . . . NUMB 0007H WDTT10 . . . . . . . . . . . . . C ADDR 9295H WDTTOG . . . . . . . . . . . . . C ADDR 9291H WRCM10 . . . . . . . . . . . . . C ADDR 8FACH WRCM20 . . . . . . . . . . . . . C ADDR 8FB1H WRCMD. . . . . . . . . . . . . . C ADDR 8FA5H WRDD10 . . . . . . . . . . . . . C ADDR 8B3FH WRDDSP . . . . . . . . . . . . . C ADDR 8B37H WUDIO. . . . . . . . . . . . . . NUMB 0003H XCLK . . . . . . . . . . . . . . NUMB 0094H XDCD . . . . . . . . . . . . . . NUMB 0012H NOT USED XDOT . . . . . . . . . . . . . . NUMB 0095H XOST . . . . . . . . . . . . . . NUMB 00B3H NOT USED