home *** CD-ROM | disk | FTP | other *** search
- PAGE ,132
- ;
- ; MODEM DIGIBOARD INC. 07-07-86
- ;
- ; this code is supplied in source form with the device drivers
- ; for the Com-4/Com-8 boards from DIGIBOARD INC. . It is included
- ; not so much as a utility but as an example of using com
- ; ports to save other users time.
- ;
- ; conditional assembly
- ;
- HALF EQU 1 ; 0=full duplex 1=half duplex
- INIT EQU 0 ; initialisation 1=1200 baud,0=leave
- CRLF EQU 0 ; 1=convert CR keys to CR+LF sequence
- ;
- ; constants
- ;
- CR EQU 0DH ; carrage return
- LF EQU 0AH ;line feed
- ESC EQU 1BH ; escape character
- ;
- .SALL
- ;
- CODE SEGMENT
- ASSUME CS:CODE,DS:CODE
- ;
- ; a simple com port driver: key to line/line to screen
- ;
- MODEM PROC FAR
- STI
- MOV AX,CS ; set up
- MOV DS,AX
- MOV AH,15
- INT 10H
- MOV V_PAGE,BH ; save the current vidio page
- ;
- ; find out what port they want to use
- ; 2 digits or 1 digit+carrage return
- ;
- MOV DX,OFFSET MSG ; sign on + port request
- MOV AH,9 ; print a string
- INT 21H
- ;
- MOV AH,1 ; get and echo a key
- INT 21H
- CMP AL,'1' ; first port
- JL L6 ; to small
- CMP AL,'9' ; max
- JG L6
- SUB AL,'0'
- MOV DL,AL
- XOR DH,DH
- MOV AH,1 ; get and echo a second key
- INT 21H
- CMP AL,CR ; if carrage return use DX
- JE L1
- CMP AL,'9' ; test that we have a digit
- JG L6
- SUB AL,'0'
- JL L6
- XOR AH,AH ;P.P
- XCHG AX,DX ; get tens in AX
- MOV CL,10
- MUL CL
- ADD DX,AX
- L1: CMP DX,34 ;10 current maximum
- JG L6
- DEC DX
- MOV COM,DX ; set this as the port to use
- MOV AL,CR ; do a CR/LF
- CALL CH_OUT
- ;
- ; if initialisation set the port up
- ;
- IF INIT EQ 1
- MOV DX,COM
- MOV AH,0
- MOV AL,083H ; 1200 baud,8 bit,no-parity
- INT 14H
- ENDIF
- ;
- ; hunt for keys and data from the line
- ;
- L2: MOV AH,1 ; keyboard status
- INT 16H
- JZ L4 ; no character
- MOV AH,0 ; get the character
- INT 16H
- CMP AL,ESC ; if it's ESC we exit
- JZ L6
- ;
- IF HALF EQ 1 ; assemble for half duplex
- OR AL,AL
- JZ L3
- PUSH AX
- CALL CH_OUT
- POP AX
- ENDIF
- ;
- L3: MOV AH,1 ; send a character
- MOV DX,COM ; com?:
- INT 14H
- JMP SHORT L2
- ;
- L4: MOV AH,3 ; get serial port status
- MOV DX,COM ; com:
- INT 14H
- TEST AH,80H ; now IBM and I never set this
- JNZ L5 ; this bit for status but some
- ; compatables do and they then
- ; scramble the other bits
- TEST AH,1 ; DAV ?
- JZ L2 ; no
- MOV AH,2
- INT 14H ; recieve a char
- CALL CH_OUT
- JMP SHORT L2
- ;
- L5: MOV AH,2 ; unscramble a compatable but
- INT 14H ; why are you running MODEM
- JMP SHORT L2 ; without the COM-4/8 driver?
- ;
- L6: MOV DX,OFFSET MSG1 ; sign off
- MOV AH,9 ; print a string
- INT 21H
- MOV AH,4CH
- MOV AL,0 ; return code
- INT 21H
- ;
- MODEM ENDP
- ;
- CH_OUT PROC NEAR ; output a character
- IF CRLF EQ 1 ; assemble if CR=CR+LF option
- CMP AL,CR ; convert a CR to CR/LF
- JNZ CH_OX ; to prevent problems
- MOV AL,LF
- MOV AH,14
- MOV BH,V_PAGE
- INT 10H ; vidio as TTY
- MOV AX,CR
- ENDIF
- CH_OX: MOV AH,14
- MOV BH,V_PAGE
- INT 10H ; vidio as TTY
- RET
- CH_OUT ENDP
- ;
- V_PAGE DB ? ; current video page
- COM DW ? ; com device to use
- ;
- MSG DB CR,LF,'Modem : the simple com port driver'
- DB CR,LF,'by DIGIBOARD INC. ver 2.10'
- DB CR,LF,LF,'Key ESC to terminate session'
- IF INIT EQ 1
- DB CR,LF,'Port is initialised to 1200 baud,'
- DB '8 bit no parity'
- ELSE
- DB CR,LF,'Port is expected to be previously'
- DB ' initialised'
- ENDIF
- DB CR,LF,LF,'Which com port do you wish '
- DB 'to use? (1-34) $'
- ;
- MSG1 DB CR,LF,LF,'Modem Terminating$'
- ;
- CODE ENDS
- ;
- SSEG SEGMENT PARA STACK 'STACK'
- DB 20 DUP (?)
- SSEG ENDS
- ;
- END MODEM ;execution address
- ;
-