home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3ov-2.ins < prev    next >
Text File  |  1994-07-13  |  10KB  |  327 lines

  1. ; B3OV-1.INS - Osborne Vixen insert for BYE3 - 07/17/85
  2. ;
  3. ;         8251A with BIOS routines setting baud rate
  4. ;
  5. ;
  6. ; This version is for an 8251A I/O with extended BIOS jump for setting
  7. ; baudrate.  Note:  This is an insert, not an overlay.
  8. ;
  9. ; This version is for the Osborne Vixen which uses an extended BIOS
  10. ; function call to set the baudrate.  The normal serial input interrupt
  11. ; driver in BIOS is disabled while BYE3 is used.
  12. ;
  13. ;
  14. ; *  *    *  *  *  *  *  *  *  *    *  *  *  *  *  *  *  *    *  *  *  *  *  *
  15. ;
  16. ;  07/30/85  Restored to original format    - pst
  17. ;  06/15/85  Written for use with BYE3        - Roy Robinson
  18. ;
  19. ; *  *    *  *  *  *  *  *  *  *    *  *  *  *  *  *  *  *    *  *  *  *  *  *
  20. ;
  21. ;-----------------------------------------------------------------------
  22. ; PATCH #1 -------------------------------------------------------------
  23. ;-----------------------------------------------------------------------
  24. ;
  25. ; Listed below is a patch for disabling the serial input interrupt
  26. ; driver in the Vixen BIOS.  This patch goes AFTER the label
  27. ; "START1" and immediately AFTER the line of code, CALL MDCARCK
  28. ; This patch is in the BYE source code.
  29. ;
  30. ; ---->  beginning of patch:
  31. ;
  32. ;    JNZ    BYPASS
  33. ;  INITMOD:
  34. ;    PUSH    PSW
  35. ;    MVI    C,7    ; Use BDOS to obrain current IOBYTE
  36. ;    CALL    BDOS    ;
  37. ;    STA    OLDIOB    ; Save old IOBYTE
  38. ;    ANI    3fH    ;
  39. ;    ORI    80H    ; Make CEN: PORT new LST: DEVICE
  40. ;    MOV    E,A
  41. ;    MVI    C,8
  42. ;    CALL    BDOS    ; Use BDOS to place new IOBYTE in first page of memory
  43. ;    DI        ;
  44. ;    LHLD    INTVEC    ; Get serial port interrupt processor address
  45. ;    SHLD    OLDVEC    ; Save serial port interrupt processor address
  46. ;    DCX    H
  47. ;    DCX    H
  48. ;    DCX    H    ; HL has next interrupt processor address
  49. ;    SHLD    INTVEC    ; This is now first interrupt processor rather
  50. ;            ;   than second
  51. ;
  52. ;INITSIO:
  53. ;    LHLD    BIOS    ; Find start ofF BIOS
  54. ;    MVI    L,3CH    ; Displacement of baudrate byte from start of BIOS
  55. ;    MOV    A,M
  56. ;    STA    OLDBAUD ; Save original baudrate byte
  57. ;    MVI    L,3BH    ; Displacement of 8251 mode byte from start of BIOS
  58. ;    MOV    A,M    ; Old mode byte set by ROM is 2SB, NP, 8DB, X16 clock
  59. ;    STA    OLDMODE ; Save original 8251 mode byte
  60. ;    MOV    B,L
  61. ;    MVI    A,6EH    ; 1 SB, NP, 8 DB, X16 clock modem byte
  62. ;    CALL    IORESET ; Use extended BIOS jump to reset 8251
  63. ;    MVI    A,37H    ; 8251 command byte RTS/DTR active, TXD and RXD active
  64. ;    OUT    31H    ; Send it to 8251 control port
  65. ;    MVI    A,3    ; Select 8155 port C
  66. ;    OUT    21h    ;
  67. ;    IN    28h    ; Get miscellaneous byte
  68. ;    STA    OLDMSC    ; Save misdellaneous info byte
  69. ;    ORI    00001111B
  70. ;            ; Disable ring detect interrupt, RXD interrupt, XMIT
  71. ;            ;   interrupt, emab;e omterma; clock
  72. ;    MOV    E,A
  73. ;    MVI    A,3
  74. ;    OUT    21h    ; Select 8155 port C
  75. ;    MOV    A,E
  76. ;    OUT    28h    ; Send new control byte to 8155 port C
  77. ;    EI
  78. ;    POP    PSW
  79. ;    ORA    A
  80. ;
  81. ;BYPASS:
  82. ;    JNZ    GOODBY
  83. ;    original code continues here
  84. ;
  85. ;=======================================================================
  86. ;
  87. ;-----------------------------------------------------------------------
  88. ; PATCH #2 -------------------------------------------------------------
  89. ;-----------------------------------------------------------------------
  90. ;
  91. ;
  92. ; Listed below is a patch for re-enabling the serial input interrupt
  93. ; driver in the Vixen.    Place this patch before the instruction line
  94. ; "JMP    0000H" in the EXCPM routine in the BYE source code.
  95. ;
  96. ;--> Patch starts here
  97. ;
  98. ;RSTINT:
  99. ;    LDA    OLDIOB    ; Get original IOBYTE
  100. ;    MVI    C,8
  101. ;    MOV    E,A    ; Use BDOS to restore original IOBYTE
  102. ;    CALL    BDOS
  103. ;    DI
  104. ;    XRA    A
  105. ;    OUT    STPORT    ; Disable 8251 DTR/RTS lines
  106. ;    LHLD    OLDVEC    ; Get original interrupt service address
  107. ;    SHLD    INTVEC    ; Restore original interrupt service address
  108. ;    MVI    A,3    ; Select 8155 port C
  109. ;    OUT    21H
  110. ;    IN    28H    ; Get misc. info byte for controlling interrupt lines
  111. ;    ANI    030H    ; Zero the least significant four bits, keep the
  112. ;            ;   remainining two most significant bits
  113. ;    MOV    E,A
  114. ;    LDA    OLDMSC    ; Get original misc. 8155 control byte
  115. ;    ANI    0FH    ; Keep least significant four bits
  116. ;    ORA    E    ; Combine everything
  117. ;    MOV    E,A
  118. ;    MVI    A,3
  119. ;    OUT    21H    ; Select 8155 port C
  120. ;    MOV    A,E
  121. ;    OUT    28H    ; Restore original 8155 control byte
  122. ;    EI
  123. ;    MVI    B,3CH
  124. ;    LDA    OLDBAUD ; Restore original baudrate byte
  125. ;    CALL    IORESET ; Do an 8251 reset
  126. ;    MVI    B,3BH
  127. ;    LDA    OLDMODE ; Restore original mode byte
  128. ;    CALL    IORESET ; Do an 8251 reset
  129. ;
  130. ;--> Original code starts again with the following instruction:
  131. ;
  132. ;    JMP    0000H
  133. ;
  134. ;-----------------------------------------------------------------------
  135. ;
  136. ;
  137. ; E Q U A T E S
  138. ;
  139. ;
  140. INTVEC    EQU    0EFFEH        ; Address of interrupt vector to first
  141.                 ; interrupt service routine
  142. BDOS    EQU    0005H        ; Address of bdos in first page of RAM
  143. BIOS    EQU    0001H        ; Address of warm boot jump in BIOS
  144. AJUMP    EQU    0C3H        ; JUMP instruction opcode
  145. ;
  146. ;
  147. PORT:    EQU    030H
  148. DATPORT:EQU    PORT        ; Modem data port
  149. STPORT:    EQU    PORT+1        ; Modem status port
  150. ;
  151. ; Modem status port equates
  152. ;
  153. ; The following are STPORT AND TSTPORT commands
  154. ;
  155. OFFINS    EQU    00010000B    ; Drop DTR and disable RCV/XMT
  156. ONINS    EQU    00010111B    ; Reset flags, send DTR, enable RX and TX
  157. RSTINS    EQU    00010111B    ; Reset USART and send DTR
  158.  
  159.  
  160. ;
  161. ; The following are STPORT status masks
  162. ;
  163. DAV:    EQU    00000010B    ; Data available - rda
  164. TRDY:    EQU    00000100B    ; Transmit buffer empty - tbe
  165. DSR:    EQU    10000000B    ; Data carrier detect - use DSR
  166. PE:    EQU    00001000B    ; Parity error - register 1
  167. OE:    EQU    00010000B    ; Overrun error - register 1
  168. FE:    EQU    00100000B    ; Framing error - register 1
  169. ERR:    EQU    PE+OE+FE    ; Parity, overrun and framing errors
  170. ;
  171. ;-----------------------------------------------------------------------
  172. ;
  173. ; The following is a routine that will check to make sure we still have
  174. ; carrier.  If there is no carrier, it will return with the Zero flag
  175. ; set.
  176. ;
  177. MDCARCK:MVI    A,ONINS        ; Reset status
  178.     OUT    STPORT
  179.     IN    STPORT        ; Get status
  180.     ANI    DSR        ; Check for carrier detect
  181.     RET
  182. ;
  183. ; This routine should turn off everything on the modem, and get it ready
  184. ; to wait for a ring.  (Also hang it up.)
  185. ;
  186. MDINIT:    MVI    A,OFFINS    ; Clear DTR
  187.     OUT    STPORT        ; Causing modem to hangup
  188.     PUSH    B        ; Preserve in case we need it
  189.     MVI    B,20        ; 2 seconds to drop DTR
  190.  
  191. OFFTI:    CALL    DELAY        ; 0.1 second delay
  192.     DCR    B
  193.     JNZ    OFFTI        ; Keep waiting until carrier drops
  194.     POP    B        ; Restore BC
  195.     MVI    A,ONINS        ; Raise DTR so that modem can answer the phone
  196.     OUT    STPORT
  197. ;
  198.      IF    IMODEM
  199.     CALL    IMINIT        ; Initialize smartmodem
  200.      ENDIF            ; IMODEM
  201. ;
  202.     RET
  203. ;
  204. ; The following is a routine that will input one character from the
  205. ; modem port.  If there is nothing there, it will return garbage... so
  206. ; use the MDINST routine first.
  207. ;
  208. MDINP:    IN    DATPORT        ; Get character
  209.     RET
  210. ;
  211. ; The following is a routine to determine if there is a character wait-
  212. ; ing to be received.  If there are none, the Zero flag will be set,
  213. ; otherwise, 0FFH will be returned in register A.  Remember that the
  214. ; system will like you a little more if you also mask out framing,
  215. ; parity, and overrun errors.
  216. ;
  217. MDINST:    IN    STPORT        ; Get status
  218.     ANI    DAV        ; Got a character?
  219.     RZ            ; Return if none
  220.     IN    STPORT        ; Get status again
  221.     ANI    ERR        ; Check for framing and overrun
  222.     JZ    MDINST1        ; No errors
  223.     MVI    A,ONINS        ; Reset error flags
  224.     OUT    STPORT
  225.     XRA    A        ; Return false
  226.     RET
  227. ;
  228. MDINST1:ORI    0FFH        ; We have a character
  229.     RET            ; And return
  230. ;
  231. ; The following is a routine to determine if the transmit buffer is
  232. ; empty.  If it is empty, it will return with the Zero flag clear.  If
  233. ; the transmitter is busy, then it will return with the Zero flag set.
  234. ;
  235. MDOUTST:IN    STPORT        ; Read port
  236.     ANI    TRDY        ; Mask crap
  237.     RZ
  238.     ORI    0FFH
  239.     RET
  240. ;
  241. ; The following is a routine that will output one character in register
  242. ; A to the modem.  REMEMBER, that is register A, not register C.
  243. ;
  244. ; **** Use MDOUTST first to see if buffer is empty ****
  245. ;
  246. MDOUTP:    OUT    DATPORT        ; Send it
  247.     RET
  248. ;
  249. ; Re-initialize modem and hang up phone by dropping DTR and leaving
  250. ; modem inactive
  251. ;
  252. MDQUIT:     IF    IMODEM
  253.     CALL    IMQUIT
  254.      ENDIF            ; IMODEM
  255. ;
  256. ; Called by main BYE program after caller types BYE
  257. ;
  258. MDSTOP:    XRA    A        ; Turn off rts/dtr, rx/tx
  259.     OUT    STPORT        ; Command byte to 8251 control port
  260.     RET
  261. ;
  262. ; These next routines set the proper baud rates for the modem.    If you
  263. ; do not support the particular rate, then simply put in a JMP to SETINV.
  264. ; If the baud rate change was successful, make SURE the zero flag is set.
  265. ;
  266. ; The following routine returns a 255 because we were not able to set to
  267. ; the proper baud rate because either the serial port or the modem can
  268. ; not handle it.
  269. ;
  270. SETINV:    MVI    A,0FFH
  271.     ORI    A        ; Make sure the Zero flag is not set
  272.     RET
  273. ;
  274. SET300:    MVI    A,06H        ; Store baud rate parameter (300 baud)
  275.     MVI    B,3CH
  276.     JMP    SETBAUD
  277. ;
  278. SET1200:MVI    A,08H        ; Store baud rate parameter (1200 baud)
  279.     MVI    B,3CH
  280.     JMP    SETBAUD
  281. ;
  282. SET2400:MVI    A,0BH        ; Store baud rate parameter (2400 baud)
  283.     MVI    B,3CH
  284.  
  285. SETBAUD:CALL    IORESET        ; Use extended BIOS function to reset baudrate
  286.     XRA    A        ; Say baudrate change was satisfactory
  287.     RET
  288. ;
  289. IORESET:
  290. ;
  291. ; Subroutine which executes a master reset for 8251.  8251 reset is a
  292. ; BIOS function in VIXEN extended BIOS
  293. ;
  294. ;    ENTRY:
  295. ;    A    =    byte value to be replaced in BIOS
  296. ;            (mode byte or baudrate byte)
  297. ;
  298. ;    B    =    hex displacement from base of BIOS
  299. ;            for mode byte or baudrate byte
  300. ;            (mode byte = 3BH)
  301. ;            (baudrate byte = 3CH)
  302. ;
  303. ;    EXIT:
  304. ;    NONE
  305. ;
  306.     LHLD    BIOS        ; Find base of BIOS
  307.     MOV    L,B
  308.     MOV    M,A
  309.     MVI    L,36H        ; Displacement in BIOS for 8251 reset function
  310.     SHLD    EXTFUN
  311.     CALL    BIOSFUNC    ; Subroutine call of BIOS 8251 reset function
  312.     RET
  313. ;
  314. OLDIOB:    DS    1        ; Original  IOBYTE
  315. OLDMSC:    DS    1        ; Original misc. control byte for 8155 port C
  316. OLDVEC:    DS    2        ; Original interrupt service vector
  317. OLDMODE:DB    1        ; Original 8251 mode byte from BIOS
  318. OLDBAUD:DB    1        ; Original baudrate byte for 8251 from BIOS
  319. BIOSFUNC: DB    AJUMP        ; Absolute jump to the following memory address
  320. EXTFUN:    DS    2        ; BIOS extended function address
  321. ;                   end
  322. ;-----------------------------------------------------------------------
  323. ~~~
  324. ;  06/15/85  Written for use with BYE3        - Roy Robinson
  325. ;                          FOG RCPM #4
  326. ;                          (415) 591-6259
  327.