****************************************************************************** CP/M 2.2 routines for AUX device (device #14, prototype Coleco serial board). Disassembly and comments (c) 1992 by Richard F. Drushel 9208.12 ****************************************************************************** AUX device init data. These encode the baud rate, data bits, stop bits, parity, and protocol. 56651 0F ;19200 baud 56652 03 ;8 data bits 56653 02 ;no parity 56654 00 ;1 stop bit 56655 02 ;no transfer protocol 56656 00 ;clear receive buffer ****************************************************************************** Aux_Write. On entry, C=character to send. 58320 060E LD B,14 ;14=serial board 58322 216DF0 LD HL,61549 ;AUX buffer ;fall through to Write Character Device ****************************************************************************** Write Character Device. On entry, C=character to send, HL=buffer. On exit, if write was successful, CF=1 else CF=0, ZF=0 and A=low nibble of ADAMnet status byte from DCB+0. 58325 71 LD (HL),C ;put character in buffer 58326 E5 PUSH HL ;save position 58327 C5 PUSH BC ;save character/device 58328 78 LD A,B ;A=device 58329 010100 LD BC,1 ;writecount=1 58332 CDA0E4 CALL 58528 ;Write to Device 58335 C1 POP BC 58336 E1 POP HL 58337 D8 RET C ;OK, so exit 58338 FE06 CP 6 ;was it busy? 58340 28F0 JR Z,-16 (58326) ;YES, so keep trying 58342 C9 RET ;FAILED error exit ****************************************************************************** Aux read buffer status. 61062 DS 1 ;# of unread buffered characters 61063 DS 2 ;address of next character in buffer ****************************************************************************** Aux_In_Status. Checks if prototype serial port is ready to send a character. On exit, if a character is pending, A=255 else A=0. 61065 3A86EE LD A,(61062) ;get # of unread buffered characters 61068 B7 OR A ;are there any? 61069 200B JR NZ,+11 (61082) ;YES, so exit saying a char is pending 61071 CD02EF CALL 61186 ;reset serial port and get node type byte ;CF=1 is ok, CF=0 is failed ;if ok, bits 5-0 of A have # chars pending 61074 3F CCF ;was it ok? 61075 3805 JR C,+5 (61082) ;NO 61077 E63F AND 63 ;check # of characters pending 61079 2001 JR NZ,+1 (61082) ;we have characters! CF=0 61081 37 SCF ;no characters! CF=1 61082 3EFF LD A,255 ;base for char ready code 61084 CE00 ADC A,0 ;add the CF 61086 C9 RET ; ****************************************************************************** Aux_Out_Status. Checks if prototype serial port is ready to receive a character. On exit, if it's ok to send a character, A=255 else A=0. 61087 CD02EF CALL 61186 ;reset serial port and get node type byte ;CF=1 is ok, CF=0 is failed 61090 3F CCF ;was it ok? (new CF=0) 61091 38F5 JR C,-11 (61082) ;NO 61093 07 RLCA ;YES, so rotate bit 7 into CF ;bit 7 set=not ready, bit 7 clear=ready 61094 18F2 JR -14 (61082) ;make an error code ****************************************************************************** Aux_Read. Reads the prototype serial port and stores up to 63 characters in a buffer at 64546. This routine checks the receive buffer and returns one character in A, updating the buffer pointer and the unread but buffered character count. 61096 3A86EE LD A,(61062) ;get # of unread buffered characters 61099 B7 OR A ;are there any? 61100 201C JR NZ,+28 (61130) ;YES, so get one and skip physical port I/O 61102 CD02EF CALL 61186 ;reset serial port and get node type byte ;this must pass the number of characters ;available to read in bits 5-0 of A! 61105 30E6 JR NC,-26 (61081) ;failed 61107 E63F AND 63 ;00111111 any characters available? 61109 28F7 JR Z,-9 (61102) ;no, so wait for some characters 61111 4F LD C,A ;characters waiting! 61112 0600 LD B,0 ;get # of bytes to read 61114 C5 PUSH BC ;save char count 61115 2122FC LD HL,64546 ;buffer to read to 61118 2287EE LD (61063),HL ;save it 61121 3E0E LD A,14 ;14=serial board 61123 CD9CE4 CALL 58524 ;Read from device 61126 C1 POP BC ;restore count 61127 30F1 JR NC,-15 (61114) ;failed 61129 79 LD A,C ;get original count 61130 3D DEC A ;1 less 61131 3286EE LD (61062),A ;save new # of unread buffered characters 61134 2A87EE LD HL,(61063) ;get start of read buffer 61137 7E LD A,(HL) ;get 1st character 61138 23 INC HL ;point to next slot in buffer 61139 2287EE LD (61063),HL ;save new buffer offset 61142 C9 RET ****************************************************************************** Init_Aux_Device. Initializess the serial port of the prototype serial/ parallel board. On entry, HL=address of 6-byte init data table. On exit, if the init was successful, A=0 and ZF=1, else ZF=0 and A=index of data at which the init error occurred. 61143 0606 LD B,6 ;loop count 61145 7E LD A,(HL) ;get parameter in A 61146 C5 PUSH BC ;save count 61147 E5 PUSH HL ;save table offset 61148 215EFC LD HL,64606 ;point to init data to send buffer 61151 77 LD (HL),A ;save parameter 61152 2B DEC HL ;back up 61153 3E06 LD A,6 ; 61155 90 SUB B ;get parameter number ;converts 6-1 to 0-5 61156 77 LD (HL),A ;save it 61157 010200 LD BC,2 ;# bytes to send 61160 3E0E LD A,14 ;device 14=prototype RS-232 61162 CDA0E4 CALL 58528 ;Write to Device 61165 380B JR C,+11 (61178) ;ok, so keep sending 61167 FE06 CP 6 ;failed, but was the ADAMnet error ;"device not ready to receive"? 86hex ;write routine clears bit 7 of error 61169 215DFC LD HL,64605 ;point to data start just in case 61172 28EF JR Z,-17 (61157) ;YES, so send it again 61174 E1 POP HL ;NO, so clear stack and error exit 61175 C1 POP BC 61176 1805 JR +5 (61183) ****************************************************************************** 61178 E1 POP HL ;restore offset 61179 C1 POP BC ;restore count 61180 23 INC HL ;next offset 61181 10DA DJNZ -38 (61145) ;keep going 'til done 61183 78 LD A,B ;loop counter in A (so we know where it ;stopped) 61184 B7 OR A ;adjust ZF for exit status 61185 C9 RET ****************************************************************************** Reset serial port and get node type byte. On exit, if successful, HL=DCB start, CF=1 and A=node type byte, otherwise CF=0. The data in the node type byte appears to decode as follows: bit 7: 0=ready to accept character from you, 1=not ready bit 6: ??? maybe flags receive buffer overrun? not used here bits 5-0: number of characters waiting for you to read (max 63) 61186 3E0E LD A,14 ;14=serial board 61188 CDECE3 CALL 58348 ;get DCB address in HL 61191 D0 RET NC ;no DCB error 61192 7E LD A,(HL) ;get status from DCB+0 61193 07 RLCA ;check bit 7 61194 30FC JR NC,-4 (61192) ;not ready, keep trying 61196 0E21 LD C,33 ;ok, so set retry count 61198 0D DEC C ;are we done? 61199 28EF JR Z,-17 (61184) ;YES, so error exit 61201 3601 LD (HL),1 ;no, so request status 61203 7E LD A,(HL) ;get status 61204 EE80 XOR 128 ;is it ready? 61206 FA13EF JP M,61203 ;NO, but keep trying 61209 20F3 JR NZ,-13 (61198) ;NO, so retry 61211 54 LD D,H ;YES 61212 5D LD E,L ;DE=DCB start 61213 011400 LD BC,20 61216 09 ADD HL,BC ;offset to node type byte 61217 7E LD A,(HL) ;get it 61218 EB EX DE,HL ;restore HL=DCB start 61219 37 SCF ;CF=1 for ok exit 61220 C9 RET ****************************************************************************** AUX (serial port) read buffer. Probably 63 bytes long (spills into parameter passing area for AUX init. 64546 DS 61 ****************************************************************************** Parameter passing for AUX init. 64605 DS 1 ;index of data (0-5) 64606 DS 1 ;data to send ****************************************************************************** AUX init parameter mapping. From CONFIG.COM program. baud rate data bits parity stop bits protocol 0 50 8 1800 0 5 0 odd 0 1 0 RTS/CTS 1 75 9 2000 1 6 1 even 1 2 1 XON/XOFF 2 110 A 2400 2 7 2 none 2 none 3 134.5 B 3600 3 8 other 4 150 C 4800 5 300 D 7200 0 clear receive buffer 6 600 E 9600 1 DTR on 7 1200 F 19200 2 DTR off ******************************************************************************