home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / COMM1_34.ZIP / MODEM.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-07-22  |  3.5 KB  |  174 lines

  1.     PAGE    ,132
  2. ;
  3. ; MODEM     DIGIBOARD INC.        07-07-86
  4. ;
  5. ; this code is supplied in source form with the device drivers
  6. ; for the Com-4/Com-8 boards from DIGIBOARD INC. . It is included
  7. ; not so much as a utility but as an example of using com
  8. ; ports to save other users time.
  9. ;
  10. ; conditional assembly
  11. ;
  12. HALF    EQU    1    ; 0=full duplex 1=half duplex
  13. INIT    EQU    0    ; initialisation 1=1200 baud,0=leave
  14. CRLF    EQU    0    ; 1=convert CR keys to CR+LF sequence
  15. ;
  16. ; constants
  17. ;
  18. CR    EQU    0DH    ; carrage return
  19. LF    EQU    0AH    ;line feed
  20. ESC    EQU    1BH    ; escape character
  21. ;
  22.     .SALL
  23. ;
  24. CODE    SEGMENT
  25. ASSUME    CS:CODE,DS:CODE
  26. ;
  27. ; a simple com port driver: key to line/line to screen
  28. ;
  29. MODEM    PROC    FAR
  30.     STI
  31.     MOV    AX,CS        ; set up
  32.     MOV    DS,AX
  33.     MOV    AH,15
  34.     INT    10H
  35.     MOV    V_PAGE,BH    ; save the current vidio page
  36. ;
  37. ; find out what port they want to use
  38. ; 2 digits or 1 digit+carrage return
  39. ;
  40.     MOV    DX,OFFSET MSG    ; sign on + port request
  41.     MOV    AH,9        ; print a string
  42.     INT    21H
  43. ;
  44.     MOV    AH,1        ; get and echo a key
  45.     INT    21H
  46.     CMP    AL,'1'        ; first port
  47.     JL    L6        ; to small
  48.     CMP    AL,'9'        ; max
  49.     JG    L6
  50.     SUB    AL,'0'
  51.     MOV    DL,AL
  52.     XOR    DH,DH
  53.     MOV    AH,1        ; get and echo a second key
  54.     INT    21H
  55.     CMP    AL,CR        ; if carrage return use DX
  56.     JE    L1
  57.     CMP    AL,'9'        ; test that we have a digit
  58.     JG    L6
  59.     SUB    AL,'0'
  60.     JL    L6
  61.     XOR    AH,AH        ;P.P
  62.     XCHG    AX,DX        ; get tens in AX
  63.     MOV    CL,10
  64.     MUL    CL
  65.     ADD    DX,AX
  66. L1:    CMP    DX,34        ;10 current maximum
  67.     JG    L6
  68.     DEC    DX
  69.     MOV    COM,DX        ; set this as the port to use
  70.     MOV    AL,CR        ; do a CR/LF
  71.     CALL    CH_OUT
  72. ;
  73. ; if initialisation set the port up
  74. ;
  75.     IF    INIT EQ 1
  76.     MOV    DX,COM
  77.     MOV    AH,0
  78.     MOV    AL,083H        ; 1200 baud,8 bit,no-parity
  79.     INT    14H
  80.     ENDIF
  81. ;
  82. ; hunt for keys and data from the line
  83. ;
  84. L2:    MOV    AH,1        ; keyboard status
  85.     INT    16H
  86.     JZ    L4        ; no character
  87.     MOV    AH,0        ; get the character
  88.     INT    16H
  89.     CMP    AL,ESC        ; if it's ESC we exit
  90.     JZ    L6
  91. ;
  92.     IF    HALF EQ 1    ; assemble for half duplex
  93.     OR    AL,AL
  94.     JZ    L3
  95.     PUSH    AX
  96.     CALL    CH_OUT
  97.     POP    AX
  98.     ENDIF
  99. ;
  100. L3:    MOV    AH,1        ; send a character
  101.     MOV    DX,COM        ; com?:
  102.     INT    14H
  103.     JMP    SHORT L2
  104. ;
  105. L4:     MOV    AH,3        ; get serial port status
  106.     MOV    DX,COM        ; com:
  107.     INT    14H
  108.     TEST    AH,80H        ; now IBM and I never set this
  109.     JNZ    L5        ; this bit for status but some
  110.                 ; compatables do and they then
  111.                 ; scramble the other bits
  112.     TEST    AH,1        ; DAV ?
  113.     JZ    L2        ; no
  114.     MOV    AH,2
  115.     INT    14H        ; recieve a char
  116.     CALL    CH_OUT
  117.     JMP    SHORT L2
  118. ;
  119. L5:    MOV    AH,2        ; unscramble a compatable but
  120.     INT    14H        ; why are you running MODEM
  121.     JMP    SHORT L2    ; without the COM-4/8 driver?
  122. ;
  123. L6:    MOV    DX,OFFSET MSG1    ; sign off
  124.     MOV    AH,9        ; print a string
  125.     INT    21H
  126.     MOV    AH,4CH
  127.     MOV    AL,0        ; return code
  128.     INT    21H
  129. ;
  130. MODEM    ENDP
  131. ;
  132. CH_OUT    PROC    NEAR        ; output a character
  133.     IF    CRLF EQ 1    ; assemble if CR=CR+LF option
  134.     CMP    AL,CR        ; convert a CR to CR/LF
  135.     JNZ    CH_OX        ; to prevent problems
  136.     MOV    AL,LF
  137.     MOV    AH,14
  138.     MOV    BH,V_PAGE
  139.     INT    10H        ; vidio as TTY
  140.     MOV    AX,CR
  141.     ENDIF
  142. CH_OX:    MOV    AH,14
  143.     MOV    BH,V_PAGE
  144.     INT    10H        ; vidio as TTY
  145.     RET
  146. CH_OUT    ENDP
  147. ;
  148. V_PAGE    DB    ?        ; current video page
  149. COM    DW    ?        ; com device to use
  150. ;
  151. MSG    DB    CR,LF,'Modem : the simple com port driver'
  152.     DB    CR,LF,'by DIGIBOARD INC.   ver  2.10'
  153.     DB    CR,LF,LF,'Key ESC to terminate session'
  154.     IF    INIT EQ 1
  155.     DB    CR,LF,'Port is initialised to 1200 baud,'
  156.     DB    '8 bit no parity'
  157.     ELSE
  158.     DB    CR,LF,'Port is expected to be previously'
  159.     DB    ' initialised'
  160.     ENDIF
  161.     DB    CR,LF,LF,'Which com port do you wish '
  162.     DB    'to use? (1-34) $'
  163. ;
  164. MSG1    DB    CR,LF,LF,'Modem Terminating$'
  165. ;
  166. CODE    ENDS
  167. ;
  168. SSEG    SEGMENT    PARA STACK 'STACK'
  169.     DB    20 DUP (?)
  170. SSEG    ENDS
  171. ;
  172.     END    MODEM        ;execution address
  173. ;
  174.