home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- ;
- ; RX by DIGIBOARD INC. 07-07-86
- ;
- ; RX is the "bare-bones" of a utility to copy files or other
- ; serial data from one system to a file on this system. You call
- ; RX with a valid file name (not however a full path name) as
- ; a parameter and answer the what port question and all the data
- ; read from the serial port is coppied to a 64k buffer. When
- ; the ESC key is pressed the data collection is ended and the
- ; buffer contents are written to the named file.
- ;
- ; conditional assembly
- ;
- INIT EQU 0 ; 1= initialise port / 0 = do not
- ;
- ; constants
- ;
- CR EQU 0DH ; carrage return
- LF EQU 0AH ; line feed
- ESC EQU 1BH ; escape character
- FCB EQU 5CH ; start of input FCB
- ;
- .SALL
- ;
- CODE SEGMENT
- ASSUME CS:CODE,DS:CODE
- ;
- ;
- ;
- RX PROC FAR
- STI
- PUSH DS ; pointer to FCBs segment
- MOV AX,CS ; set up
- MOV DS,AX
- ;
- ; get the extra memory (see end for P_SIZE generation)
- ;
- POP ES
- PUSH ES
- MOV BX,4096+P_SIZE ; ask for 64k in paragraphs
- MOV AH,4AH ; grow some more memory
- INT 21H
- JC K2 ; error return
- MOV AX,ES ; move ES to the new segment
- ADD AX,P_SIZE
- MOV ES,AX ; AX is the paragraph number
- ;
- ; 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 K2 ; to small
- CMP AL,'9' ; max
- JG K2
- 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 then use DX
- JE K1
- CMP AL,'9' ; test that we have a digit
- JG K2
- SUB AL,'0'
- JL K2
- XOR AH,AH ;P.P
- XCHG AX,DX ; get tens in AX
- MOV CL,10
- MUL CL
- ADD DX,AX
- K1: CMP DX,34 ;10 current maximum
- JG K2
- DEC DX
- MOV COM,DX ; set this as the port to use
- JMP SHORT K3
- K2: JMP K7 ; help out the relative jumps
- K3:
- ;
- ; 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
- ;
- MOV DI,1 ; offset (ES: is segment)
- ;
- ; hunt for keys and data from the line
- ;
- K4: MOV AH,1 ; keyboard status
- INT 16H
- JZ K5 ; no character
- MOV AH,0 ; read the character
- INT 16H
- CMP AL,ESC ; if it's ESC we exit
- JZ K6
- JMP SHORT K4 ; keep looking
- ;
- K5: MOV AH,3
- MOV DX,COM ; com:
- INT 14H ; serial status
- TEST AH,80H ; this may be a nasty
- JNZ K8 ; sort it out
- TEST AH,1 ; DAV ?
- JZ K4 ; no
- MOV AH,2
- INT 14H ; recieve a char
- MOV ES:-1[DI],AL ; save the character
- INC DI ; next space
- OR DI,DI ; test DI
- JNZ K4
- ;
- ; save the data to a file
- ;
- K6: MOV AX,ES
- MOV DS,AX ; buffer segment
- MOV DX,0 ; buffer offset
- MOV AH,1AH ; set DMA address
- INT 21H ; to DS:DX
- ;
- POP DS
- DEC DI ; convert DI to count
- OR DI,DI
- JZ K7 ; nothing to do
- MOV DX,OFFSET FCB ; point to the FCB
- MOV AH,13H ; delete file
- INT 21H
- ;
- MOV AH,16H ; create and open a new file
- INT 21H
- MOV AX,DI
- MOV WORD PTR DS:FCB+14,AX ; set the record size
- MOV AH,15H ; write to file
- INT 21H
- ;
- MOV AH,10H ; close file
- INT 21H
- ;
- K7: MOV AX,CS ; get DS back
- MOV DS,AX
- MOV DX,OFFSET MSG1 ; sign off
- MOV AH,9 ; print a string
- INT 21H
- ;
- MOV AH,4CH ; return to DOS
- MOV AL,0 ; return code
- INT 21H
- ;
- ; sort out scrambled compatables
- ; ( this problem does not occur on IBM PCs or with
- ; the Com-4/Com-8 drivers )
- ;
- K8: MOV AH,2
- INT 14H ; recieve a char
- JMP K4
- ;
- RX ENDP
- ;
- COM DW ? ; com device to use
- ;
- MSG DB CR,LF,'RX : copies from a com port to a file'
- 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 to '
- DB 'use? (1-34) $'
- ;
- MSG1 DB CR,LF,LF,'RX Terminating$'
- ;
- FINISH EQU $
- ;
- ; P_SIZE is the total program size in paragraphs
- ; (FINISH-RX)/16 = size of CODE segment
- ; 1 = margin for up to 15 bytes lost in integer division
- ; 10H = 100H bytes of PSP
- ; 5 = 40 words of SSEG
- ;
- P_SIZE EQU (FINISH-RX)/16+1+10H+5
- ;
- CODE ENDS
- ;
- SSEG SEGMENT PARA STACK 'STACK'
- DB 40 DUP (?)
- SSEG ENDS
- ;
- END RX ;execution address
- ;
-