home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / MODEMS / MODEM7 / NECMDMX.LBR / M7NE-2.ASM next >
Assembly Source File  |  2000-06-30  |  14KB  |  415 lines

  1.  
  2. ; M7NE-2.ASM - NEC PC-8801 computer overlay file for MDM712 - 07/10/84
  3. ;
  4. ; You will want to look this file over carefully. There are a number of
  5. ; options that you can use to configure the program to suit your taste.
  6. ; This file adapts the NEC PC-8801 computer to the modem program.  
  7. ; This file uses the INSTALL8 MODEM7B driver (incl. on this disk) linked
  8. ; to the TTY: device to obtain proper interrupt processing, necessary at
  9. ; higher Baud rates (>300).  Changes cause more efficient operation at
  10. ; Baud rates of 300 and lower also.  To use this overlay, you must set
  11. ; the serial port for 1200 baud (jumper 5), as the program then converts
  12. ; that to 300 baud whenever needed.
  13. ;
  14. ; If you edit this file for your preferences, follow the "TO USE:" example
  15. ; shown below.
  16. ;
  17. ; Use the "SET" command to change the baudrate when desired.  It starts
  18. ; out at 300 baud when the program is first called up.
  19. ;
  20. ;    TO USE: First edit this file filling in answers for your own
  21. ;        equipment.  Then assemble with ASM.COM or equivalent
  22. ;        assembler.  Then use DDT to overlay the the results
  23. ;        of this program to the original .COM file:
  24. ;
  25. ;        A>DDT MDM727.COM
  26. ;        DDT VERS 2.2
  27. ;        NEXT  PC
  28. ;        4994 0100
  29. ;        -IM7NE-2.HEX        (note the "I" command)
  30. ;        -R            ("R" loads in the .HEX file)
  31. ;        NEXT  PC
  32. ;        4994 0000
  33. ;        -G0            (return to CP/M)
  34. ;        A>SAVE 73 NECMDM7.COM    (now have a modified .COM file)
  35. ;
  36. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  37. ;
  38. ; 07/10/84 - Altered for Install8 MODEM7B.DRV drivers
  39. ;          - Renamed to M7NE-2.ASM              - Steven Sarna
  40. ; 11/11/83 - Renamed to M7NE-1.ASM, no changes    - Irv Hoff
  41. ; 07/27/83 - Renamed for use with MDM712    - Irv Hoff
  42. ; 07/01/83 - Revised for use with MDM711    - Irv Hoff
  43. ; 06/22/83 - Revised for use with MDM710    - Irv Hoff
  44. ; 06/22/83 - Altered for use with MDM710    - Irv Hoff
  45. ; 06/22/83 - Altered MDM708DP for the NEC 8001
  46. ;         computer using an external modem    - Irv Hoff
  47. ;
  48. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  49. ;
  50. BELL:        EQU    07H        ;bell
  51. CR:        EQU    0DH        ;carriage return
  52. ESC:        EQU    1BH        ;escape
  53. LF:        EQU    0AH        ;linefeed
  54. ;
  55. YES:        EQU    0FFH
  56. NO:        EQU    0
  57. ;
  58. ;
  59. WBOOT:        EQU    01H        ;CP/M Warm boot location
  60. IOBYTE:        EQU    03H        ;CP/M I/O Byte location
  61. PORT:        EQU    20H        ;NEC PC-8801 serial port
  62. MODCTL1:    EQU    PORT+1        ;Modem status port
  63. MODCTL2:    EQU    PORT+1        ;Modem control port
  64. MODDATP:    EQU    PORT        ;Modem data port
  65. MODRCVB:    EQU    02H        ;Modem recv bit
  66. MODRCVR:    EQU    02H        ;Modem recv ready bit
  67. MODSNDB:    EQU    07H        ;Modem send mask
  68. MODSNDR:    EQU    05H        ;Modem send ready bits
  69.  
  70. ;8251 COMMAND INSTRUCTION FORMAT
  71.  
  72. RES:        EQU    0100$0000B    ; Internal Reset (To mode instruction)
  73. RTS:        EQU    0010$0000B    ; Request to send
  74. ERR:        EQU    0001$0000B    ; Error Reset
  75. BRK:        EQU    0000$1000B    ; Send Break
  76. REN:        EQU    0000$0100B    ; Recieve Enable
  77. DTR:        EQU    0000$0010B    ; Data terminal ready
  78. TEN:        EQU    0000$0001B    ; Transmit Enable
  79.  
  80. ;8251 MODE INTRUCTION FORMAT
  81.  
  82. STOP1:        EQU    0100$0000B    ;Framing Control, 1 Stop bit
  83. STOP1$5:    EQU    1000$0000B    ;1 and 1/2 Stop bits
  84. STOP2:        EQU    1100$0000B    ;2 Stop bits
  85. NO:        EQU      00$0000B    ;No Parity
  86. ODD:        EQU      01$0000B    ;Odd parity
  87. EVN:        EQU      11$0000B    ;Even parity
  88. FIVE:        EQU         0000B    ;Five bit character length
  89. SIX:        EQU         0100B    ;Six bit character length
  90. SEVEN:        EQU         1000B    ;Seven bit character length
  91. EIGHT:        EQU         1100B    ;Eight bit character length
  92. X1:        EQU           01B    ;Asynchronous times one
  93. X16:        EQU           10B    ;Asynchronous times sixteen
  94. X64:        EQU           11B    ;Asynchronous times sixty-four
  95.  
  96. ;BIOS ENTRY POINTS
  97.  
  98. CONST:        EQU    006H    ;Console status
  99. CONIN:        EQU    009H    ;Console in
  100. CONOUT:        EQU    00CH    ;Console out
  101. LISTST:        EQU    02DH    ;List status
  102.  
  103. ;
  104. ;
  105.         ORG    100H
  106. ;
  107.         DS    3    ;(for  "JMP   START" instruction)
  108.  
  109.  
  110. PMMIMODEM:    DB    NO    ;yes=PMMI S-100 Modem            103H
  111. SMARTMODEM:    DB    YES    ;yes=HAYES Smartmodem            104H
  112. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  113. CLOCK:        DB    5    ;clock speed in MHz x10, 25.5 MHz max.    106H
  114.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  115. ;Due to interrupts on the PC-8801A, tick clock must be set to 5
  116. MSPEED:        DB    1    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  117.                 ;6=2400 7=4800 8=9600 9=19200 default
  118. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  119.                 ;default time to send character in ter-
  120.                 ;minal mode file transfer for slow BBS.
  121. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  122.                 ;default time for extra wait after CRLF
  123.                 ;in terminal mode file transfer
  124. NOOFCOL:    DB    5    ;number of DIR columns shown        10AH
  125. SETUPTST:    DB    YES    ;yes=user-added Setup routine        10BH
  126. SCRNTEST:    DB    YES    ;cursor control routine         10CH
  127. ACKNAK:        DB    YES    ;yes=resend a record after any non-ACK    10DH
  128.                 ;no=resend a record after a valid NAK
  129. BAKUPBYTE:    DB    YES    ;yes=change any file same name to .BAK    10EH
  130. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  131. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  132. CONVBKSP:    DB    NO    ;yes=convert backspace to rub        111H
  133. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub      112H
  134. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  135.                 ;terminal mode (added by remote echo)
  136. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  137. TRANLOGON:    DB    NO    ;yes=allow transmission of logon    115H
  138.                 ;write logon sequence at location LOGON
  139. SAVCCP:        DB    YES    ;yes=do not overwrite CCP        116H
  140. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  141.                 ;no=external command if EXTCHR precedes
  142. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  143. LSTTST:        DB    NO    ;no=printer not available (modem)    119H
  144. XOFFTST:    DB    NO    ;yes=chcks for XOFF from remote    while    11AH
  145.                 ;sending a file in terminal mode
  146. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  147.                 ;sending a file in terminal mode
  148. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  149. IGNORCTL:    DB    YES    ;yes=CTL-chars above ^M not displayed    11DH
  150. EXTRA1:        DB    0    ;for future expansion            11EH
  151. EXTRA2:        DB    0    ;for future expansion            11FH
  152. BRKCHR:        DB    '@'-40H    ;^@ = Send a 300 ms. break tone        120H
  153. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  154. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  155. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  156. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  157. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  158. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  159. EXTCHR:        DB    '^'-40H    ;^^ = Send next character        127H
  160. ;
  161. ;
  162.         DS    2        ;                128H
  163. ;
  164. IN$MODCTL1:    IN    MODCTL1        ;In modem control port        12AH
  165.         RET            ;left here for port I.D.
  166. ;                    ;not really used.
  167.         DS    7
  168. OUT$MODDATP:    JMP    TTYOUT        ;Out modem data port        134H
  169.         DS    7        ;replaced by TTY: output. 
  170. IN$MODDATP:    JMP    TTYIN        ;In modem data port        13EH
  171.         DS    7        ;replaced by TTY: input.
  172. ANI$MODRCVB:    RET            ;Logical AND not performed.
  173.         DS    2
  174. CPI$MODRCVR:    JMP TTY$IN$S        ;Compare replaced by TTY:
  175. ;                    ;status routine.
  176. ANI$MODSNDB:    RET            ;Logical AND not performed.
  177.         DS    2
  178. CPI$MODSNDR:    JMP TTY$OT$S        ;Compare replaced by TTY:
  179.         DS    12        ;status routine.
  180. ;
  181. LOGONPTR:    DW    LOGON        ;for user message.        160H
  182.         DS    6        ;                162H
  183. JMP$GOODBYE:    JMP    GOODBYE        ;                168H
  184. JMP$INITMOD:    JMP    INITMOD        ;go to user written routine    16BH
  185.         RET  !    NOP  !    NOP    ;(by-passes PMMI port)        16EH
  186.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    171H
  187.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    174H
  188. JMP$SETUPR:    JMP    SETUPR        ;                177H
  189. JMP$SPCLMENU:    JMP    SPCLMENU    ;                17AH
  190. JMP$SYSVER:    JMP    SYSVER        ;                17DH
  191. JMP$BREAK:    JMP    SENDBRK        ;                180H
  192. ;
  193. ;
  194. ; Do not change the following six lines.
  195. ;
  196. JMP$ILPRT:    DS    3        ;                183H
  197. JMP$INBUF    DS    3        ;                186H
  198. JMP$INLNCOMP:    DS    3        ;                189H
  199. JMP$INMODEM    DS    3        ;                18CH
  200. JMP$NXTSCRN:    DS    3        ;                18FH
  201. JMP$TIMER:    DS    3        ;                192H
  202. ;
  203. ;
  204. ; Clear sequences -- CLREOS is clear to end of screen, CLRSCRN is clear
  205. ; entire screen.  Last entry must be 0.  Any other 0's act as NOP's.
  206. ; The SCRNTST option must be set "YES" for these to work.
  207. ;
  208. CLREOS:        CALL    JMP$ILPRT    ;                195H
  209.         DB    ESC,59H,0,0,0    ;                198H
  210.         RET            ;                19DH
  211. ;
  212. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  213.         DB    1EH,ESC,59H,0,0    ;                1A1H
  214.         RET            ;                1A6H
  215. ;
  216. ;
  217. SYSVER:        CALL    JMP$ILPRT    ;                1A7H
  218.         DB    'Version for NEC PC-8801A computers'
  219.         DB    CR,LF
  220.         DB    'For use with "INSTALL8 MODEM7B TTY:"'
  221.         DB    CR,LF,0
  222.         RET
  223. ;.....
  224. ;
  225. ;
  226. ;-----------------------------------------------------------------------
  227. ;
  228. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  229. ;     end of your last routine should terminate by 0400H (601 bytes
  230. ;     available after start of SYSVER) if using the Hayes Smartmodem
  231. ;     or by address 0C00H (2659 bytes) otherwise.
  232. ;
  233. ;-----------------------------------------------------------------------
  234. ;
  235. ; You can put in a message at this location which can be called up with
  236. ; CTL-L if TRANLOGON has been set YES.    You can put in several lines if
  237. ; desired.  End with a 0.
  238. ;
  239. ;
  240. LOGON:      DB    'This is an NEC PC-8801A computer',CR,LF,0
  241. ;.....
  242. ;
  243. ;
  244. ;=======================================================================
  245. ;
  246. ; This routine allows a 300 ms. break tone to be send to reset some
  247. ; time-share computers.
  248. ;
  249. SENDBRK:  MVI    A,RTS+ERR+BRK+REN+DTR+TEN     ;SEND A BREAK TONE
  250.       JMP    GOODBYE1
  251. ;.....
  252. ;
  253. ;
  254. ; This routine sends a 300 ms. break tone and sets DTR low for the same
  255. ; length of time to disconnect some modems such as the Bell 212A, etc.    
  256. ;
  257. GOODBYE:  MVI    A,ERR+BRK+TEN        ;SEND BREAK, TURN OFF RTS & DTR
  258. ;
  259. GOODBYE1: OUT    MODCTL1        ;SEND TO STATUS PORT
  260.       MVI    B,3        ;WAIT 300 MS.
  261.       CALL    JMP$TIMER
  262.       MVI    A,RTS+ERR+REN+DTR+TEN    ;NORMAL SEND/RECEIVE WITH RTS & DTR
  263.       OUT    MODCTL1        ;SEND TO STATUS PORT
  264.       RET
  265. ;.....
  266. ;
  267. ;
  268. ; NEC PC-8801 initialization -- sets the 8251A for 8 bits, 1 stop pulse,
  269. ; DTR high, requires jumper shunt be set (jumpered @ 5) to 1200 baud then
  270. ; divides by 64 for 300, or by 16 for 1200 baud via "SET" command.  Set
  271. ; at present to default to 300 baud.
  272. ;
  273. INITMOD:  MVI    A,1        ;TRANSFER TIME FOR 300 BAUD
  274.       STA    MSPEED    
  275.       MVI    A,0        ;INSURE OUT OF MODE
  276.       OUT    MODCTL1        ;MODEM STATUS PORT
  277.       OUT    MODCTL1
  278.       OUT    MODCTL1        ;3 TIMES GETS IT TO KNOWN STATUS
  279.       MVI    A,RES        ;INITIALIZE USART
  280.       OUT    MODCTL1        ;MODEM STATUS PORT
  281. ;
  282. INITMOD1: MVI    A,STOP1+NO+EIGHT+X64    ;DEFAULT TO DIVIDE BY 64 FOR 300 BAUD
  283.       OUT    MODCTL1        ;MODEM STATUS PORT
  284.       MVI    A,RTS+ERR+REN+DTR+TEN    ;RTS, DTR, RCV, XMT, ERROR RESET
  285.       OUT    MODCTL1        ;MODEM STATUS PORT
  286.       RET
  287. ;
  288. ; NEC PC-8801 status subroutines.  Alters IOBYTE to make TTY: give input
  289. ; and output status, and send TTY: input and output to CONsole 
  290. ; CP/M device. 
  291. ; Routines Modified to working condition by S. Michael Sarna
  292. ; Thanks to David Schmidt and Andrew Marrinson... R.I.P. June, 1984.
  293. ;
  294. TTY$IN$S:
  295.       CALL SWAP        ; Get the current I/O Byte and switch
  296.       MVI C,CONST        ; Get console status
  297.       CALL BIOS        ; Do the In status
  298.       INR A            ; Set the appropriate flag
  299.       JMP EXIT1        ; Restore the old I/O Byte & leave
  300.  
  301. TTY$OT$S:
  302.       CALL SWAP        ; Go to the correct I/O frame
  303.       MVI C,LISTST        ; BIOS offset to get the list device status
  304.       CALL BIOS        ; Do the Out status
  305.       INR A            ; Set the flag appropiately
  306.       JMP EXIT1        ; Restore the old I/O Byte & leave
  307.  
  308. TTYOUT:
  309.       CALL SWAP        ; One last I/O change
  310.       MVI C,CONOUT        ; BIOS console input
  311.       CALL BIOS        ; Send the character out
  312. ;The following delay is manditory to avoid an "undocumented hardware feature"
  313. ;in the 8251, as it seems you can't poll immediately after Xmt. 
  314.       LXI B,03FFH         ; Wait a little bit after sending
  315. TTYOU1:
  316.       DCX B            ; Count down
  317.       MOV A,B        ; Check if counted down enough
  318.       ORA C
  319.       JNZ TTYOU1        ; If not zero, count down some more
  320.       JMP EXIT1
  321.  
  322. TTYIN:
  323.       CALL SWAP        ; Turn into a TTY: system
  324.           MVI C,CONIN        ; Direct console read
  325.                 ; Exit must follow here:
  326. EXIT:
  327.       CALL BIOS        ; Do the suggested I/O
  328. EXIT1:
  329.       POP B            ; Restore regs to normal
  330.       POP D
  331.       POP H
  332.       PUSH PSW        ; Save the BIOS call status or data
  333.       LDA IO$BYT        ; Get the old I/O Byte
  334.       STA IOBYTE        ; move this to the I/O Byte location for CP/M 
  335.       POP PSW        ; Return the status or data
  336.       RET            ; Go back to the caller
  337.  
  338. BIOS:
  339.       LHLD WBOOT        ; Get the BIOS address   
  340.       MOV L,C        ; Set LSB of BIOS Routine
  341.       MOV C,A        ; Set LSB of Arg
  342.       PCHL            ; Go to the BIOS
  343.  
  344. SWAP:
  345.       XTHL            ; old HL on stack, return address in HL
  346.       PUSH D        ; Save other registers
  347.       PUSH B
  348.       PUSH H        ; Return address back on stack
  349.       LXI H,IOBYTE        ; Point to the current I/O Byte 
  350.       PUSH PSW        ; Save character to send 
  351.       MOV A,M        ; Fetch the current I/O Byte
  352.       MVI M,0         ; Set all devices to TTY:
  353.       STA IO$BYT        ; Save the current I/O Byte
  354.       POP PSW        ; Restore the character to send
  355.       RET 
  356. ;
  357. IO$BYT:
  358.       DS 1            ; 
  359. ;
  360. ;
  361. ;
  362. SETUPR:      LXI    D,BAUDBUF    ;POINT TO NEW INPUT BUFFER
  363.       CALL    JMP$ILPRT
  364.       DB    'Input Baud Rate (300, 1200): ',0
  365.       CALL    JMP$INBUF
  366.       LXI    D,BAUDBUF+2
  367.       CALL    JMP$INLNCOMP    ;COMPARE BAUDBUF+2 WITH CHARACTERS BELOW
  368.       DB    '300',0
  369.       JNC    OK300        ;GO IF GOT MATCH
  370.       CALL    JMP$INLNCOMP
  371.       DB    '1200',0
  372.       JNC    OK1200
  373.       CALL    JMP$ILPRT    ;ALL MATCHES FAILED, TELL OPERATOR
  374.       DB    '++ Incorrect entry ++',CR,LF,BELL,0
  375.       JMP    SETUPR        ;TRY AGAIN
  376. ;
  377. OK300:      MVI    A,1        ;MSPEED 300 BAUD VALUE
  378.       MVI    B,STOP1+NO+EIGHT+X64    ;DIVIDE BY 64 FOR 300 BAUD
  379.       JMP    LOADBD        ;GO LOAD THEM
  380. ;
  381. OK1200:      MVI    A,5
  382.       MVI    B,STOP1+NO+EIGHT+X16    ;DIVIDE BY 16 FOR 1200 BAUD
  383. ;
  384. ;
  385. LOADBD:      STA    INITMOD+1    ;CHANGE TIME-TO-SEND TO MATCH BAUDRATE
  386.       MOV    A,B        ;GET BAUDRATE BYTE
  387.       STA    INITMOD1+1    ;STORE IN INITMOD
  388.       JMP    INITMOD        ;REINITIALIZE TO NEW BAUDRATE, THEN DONE
  389. ;
  390. ;
  391. BAUDBUF:  DB    10,0
  392.       DS    10
  393. ;.....
  394. ;
  395. ;
  396. ;           (END OF INITMOD AND SETUP ROUTINES)
  397. ;=======================================================================
  398. ;        
  399. ;
  400. ; These routines can be used for your equipment.  End with RET.  If
  401. ; using the Hayes Smartmodem this is unavailable without a special ad-
  402. ; dress change.
  403. ;
  404. SPCLMENU: RET
  405. ;        
  406. ;=======================================================================
  407. ;
  408. ;
  409. ; NOTE:  MUST TERMINATE PRIOR TO 0400H (with Smartmodem)
  410. ;                 0C00H (without Smartmodem)
  411. ;
  412.       END
  413. ;
  414.  
  415.