Quick Links: [Home] [Menu] [BASIC] [TEXT] [TELCOM] [Diff] [Tech Ref] [Files] [Links] [Y2K]
In my desire to create a VT100 emulator for the NEC, I realized that I would need detailed knowledge of how the machine handles RS232 communications. This is the beginnings of my foray into the RS232 routines.
;------------------------------------------------------------------------- ;NEC PC-8201A Technical Notes Revised: 10 Apr 1998 ;------------------------------------------------------------------------- ; INIT RS232 SERIAL COMMUNICATIONS ;Additions and comments welcome. If you add any information, please ;document the source. Do not remove the name and address information of ;the original post. Add a comment underneath with your name, e-mail ;address, and revision date. ;Originally compiled from various documented sources by: ;David J. Firth djfirth@freenet.columbus.oh.us ;198 E. Home Street djfirth@ibm.net ;Westerville, OH 43081 ;------------------------------------------------------------------------- ;The following source resulted from examination of disassembled ROM ;code, chip data sheets, and the NEC PC-8201A memory map compiled ;by Gary Weber (avail from Club 100 library). ;Additional information gathered from "Model 100 System Map" c1985 rev ;9/30/85 compiled by Robert D. Covington. Downloaded from CIS. The exact ;application of the M100 data to the NEC is unverified. ;------------------------------------------------------------------------- ; INIT_RS232 : Initialize the serial port for use ; NEC PC-8201A ; According to Gary Weber's memory map, the calling conventions for ; this routine are: ; ; B = RTS/DTR status ; C = Mask, FFh ; H = Baud rate code ; L = Data size/parity/stop bits ; ; No registers destroyed 6F58 MVI A,03 ;Entry point. Set marker for use later 6F5A PUSH H ;Save initial conditions of regs 6F5B PUSH D 6F5C PUSH B 6F5D PUSH PSW 6F5E CPI 03 ;Force execution of INIT_RS232 to 6F60 JZ 6F6C ;bypass code at 6F63-6F69 ;For a straight-forward RS232 initialization, the code at 6F63-6F69 ;is not called. Dead code? ; Interrupts must be disabled while the NEC sets up the serial port, ; since the serial port can have an interrupt handler tied to it. 6F6C DI ;Disable interrupts ; The following section of code deals with the serial port input ; mask. The mask is stored in the NEC's upper memory working space ; at location FE4C. 6F6D MOV A,C ;Move mask to accumulator 6F6E STA FE4C ;Store mask in holding location in RAM 6F71 POP PSW ;Restore accumulator from stack 6F72 PUSH PSW ;Restore stack copy of accumulator ; The NEC, like the M100, dispatches many tasks via the 8085 software ; interrupt system. This centralizes a table of call dispatch hooks. ; Instead of CALLing subroutines every place in the code where a routine ; needs these frequently-used hooks (requiring a 3-byte CALL), the ; ROM programmers substitute a one-byte RST 7 instruction followed ; immediately by a one-byte hook table offset. This saves 1 byte per ; CALL through the hook table. 6F73 CALL 6FB2 ;Unknown result at this time. The ;routine calls the master hook table ;via RST 7. Investigating. 6F76 CALL 6F21 ;Call set baud rate routine ; Subroutine called once by INIT_RS232, so the subroutine ; is inserted here for easy reference. I have not commented ; every line of the routine. I am still working through it ; and don't have all applicable data sheets handy. 6F21 PUSH H ;Save baud rate to stack 6F22 MOV A,H ;Move baud rate to accumulator 6F23 RLC 6F24 LXI H,6F3E 6F27 MVI D,0 6F29 MOV E,A 6F2A DAD D 6F2B SHLD FE4A ;Baud rate table entry 6F2E POP H ;Restore baud rate reg 6F2F PUSH H ;Save baud rate to stack 6F30 LHLD FE4A 6F33 MOV A,M 6F34 OUT BC ;Port 188, low byte of timer 6F36 INX H 6F37 MOV A,M 6F38 OUT BD ;Port 189, hi byte of timer 6F3A MVI A,C3 ;11000011b 6F3C OUT B8 ;Port 184, 8155 command port 6F3E POP H ;Restore stack to init condition 6F3F RET ; The following code sets up the RTS/DTR status of the serial port 6F79 IN BA ; Port 186, a multi-purpose I/O port ; where: ; ; 7 6 5 4 3 2 1 0 ; | | | ; | | -- Carrier (0), Ring (1) ; | -------- DTR on ; ---------- RTS on 6F7B ANI 3F ;Mask out RTS status 6F7D ORA B ;Set RTS/DTR status in accumulator 6F7E OUT BA ;Set RTS/DTR for serial port ;The following code sets up the command register of the 6402 UART ;for the requested # data bits, parity, and # stop bits. The 6402's ;control word is 5 bits wide. The NEC uses the lower 5 bits of the ;byte. The order of the individual signals is based on the Model 100 ;so the validity on the NEC is unverified. ;The 6402 employs a command register load (CRL) signal. The NEC code ;reviewed thus far does not seem to do anything special to assert ;this signal. Harris Semiconductor CDP6402 documentation says the ;signal may be hard wired high. ;The reason for the IN is uncertain, since it does not seem to serve ;any particular purpose. Investigating. 6F80 IN D8 ;Port 216, 6402 UART command/status. ;According to Covington, the M100's port ;for the 6402 UART command/status input: ;MSB 76543210 LSB ;Bit 0: data on telephone line (CD?) ;Bit 1: UART overrun ;Bit 2: UART framing error ;Bit 3: UART parity error ;Bit 4: UART xmit buffer empty ;Bit 5: Modem ring indicate ;Bit 6: n/a ;Bit 7: Low power signal (active low) 6F82 MOV A,L ;Move data/par/stop to accumulator. ;According to Covington, the M100's port ;for the 6402 UART command/status output: ;MSB 76543210 LSB ;Bit 7-5: n/a ;Bit 4-3: data bits 00 = 5 bits ; 01 = 6 bits ; 10 = 7 bits ; 11 = 8 bits ;Bit 2: parity? 0 = no parity ; 1 = use parity ;Bit 1: parity 0 = even ; 1 = odd ;Bit 0: stop bits 0 = 2 ; 1 = 1, 1.5 6F83 ANI 1F ;Mask out upper 3 bits 6F85 OUT D8 ;Output data to 6402 command reg ; The following routine is a clean up routine. 6F87 CALL 6F95 ; Subroutine called once, so it is included here for ; easy reference. 6F95 XRA A ;Zero out the accumulator 6F96 MOV L,A ;Zero out L 6F97 MOV H,A ;Zero out H 6F98 SHLD FE40 ;Zero out XOF not received 6F9B SHLD FE45 ;Zero out char count in COM1 queue 6F9E SHLD FE47 ;Zero out write pointer 6FA1 SHLD F9B7 ;Zero out shift in/out send status 6FA4 STA FE49 ;Zero out XOF has been sent 6FA7 RET 6F8A JMP 7266h ;Unconditional jump to exit code 7266 POP PSW ;Restore registers to init conditions 7267 POP B 7268 POP D 7269 POP H 726A EI ;Reenable interrupts 726B RET ;Exit INIT_RS232
Original author of this page: David Firth.
This page best viewed on ANY browser. This author strongly supports access by persons with limited-capability and text-only browsers. Content is better than flash & dazzle.