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
/
BEEHIVE
/
COMMS
/
MODEM9.ARC
/
TERM.ASM
< prev
Wrap
Assembly Source File
|
1991-02-02
|
14KB
|
814 lines
;
; TERM.ASM
;
;Terminal routines with text file I/O for MODEM9.xx.
;
DSKSAVE:
CALL CKMODM
LDA FCB+1 ;FIRST CHAR OF FILENAME
CPI ' ' ;FILE SPEC'D
JNZ GOODNM ;YES, GOOD NAME
MVI A,TRUE ;0FFH
STA NFILFLG
CMA ;0
STA SAVEFLG
JMP TERM
;
GOODNM: CALL ERASFIL
CALL MOVE2
LXI D,FCB3
MVI C,MAKE
CALL BDOS
LXI D,FCB3
MVI C,OPEN
CALL BDOS
LXI H,BOTTRAM
SHLD HLSAVE
XRA A
STA NFILFLG
STA LISTMOR ;STOP ANY BUFFERED PRINTER OUTPUT
TERM: LDA LISTMOR ;ANY BUFFERED PRINTER OUTPUT?
ORA A
CNZ GOLIST ;GO IF SO
CALL STAT ;KEYPRESS?
JZ TERML ;NO, CHECK LINE
CALL KEYIN ;GET CHAR FROM KBD
CPI ' '
JNC NOTOG ;GO IF NOT CONTROL CHARACTER
MOV B,A ;SAVE
CPI BKSP ;TEST FOR BACKSPACE
JNZ NOBKSP
LDA CONVBKSP ;CONVERT BACKSPACE TO RUB?
ORA A
JZ NOBKSP ;GO IF NO CONVERSION
MVI A,RUB
JMP NOTOG
NOBKSP: LDA EXACFLG
ORA A ;EXACT?
MVI A,0
STA EXACFLG ;CLR FOR NEXT TIME
JZ NOTEXAFLG ;GO OF EXAFLG FALSE
LDA LOCONEXTCHR
ORA A ;SHOULD WE SEND ON EXAFLG?
MOV A,B
JZ NOTOG ;YES, IF LOCONEXTCHR FALSE
LDA EXTCHR ;WE WANT TO SEND EXTCHR IN ANY CASE
CMP B
MOV A,B
JZ NOTOG ;SEND IF EXTCHR
JMP LOCCHK ;OTHERWISE DO LOCAL STUFF
NOTEXAFLG:
LDA EXTCHR ;TREAT NEXT CHARACTER IN SPECIAL WAY?
CMP B
JZ EXTFLG ;YES, SET EXAFLG FOR NEXT CHAR
LDA LOCONEXTCHR
ORA A ;SHOULD WE SEND IF NOT EXAFLG
MOV A,B
JNZ NOTOG ;YES, IF LOCONEXTCHR TRUE
LOCCHK: LDA EXITCHR ;RETURN TO MENU?
CMP B
JZ EXITMEN ;YES, RETURN TO MENU
LDA TRANCHR ;OUTPUT TEXT FILE TO REMOTE?
CMP B
CZ TRANSFER ;SEND-A-FILE (BLIND SEND)
JZ TERM ;LOOP
LDA TRANLOGON
ORA A
JZ SKPLOGON
LDA LOGCHR ;SEND LOGON?
CMP B
JZ SENDLOG
SKPLOGON:
LDA LSTTST
ORA A
JZ NOLST
LDA LSTCHR
CMP B
JNZ NOLST
LDA LISTFLG
CMA
STA LISTFLG
CALL CRLF
CALL CRLF
CALL LSTMSG
CALL CRLF
JMP TERML
NOLST: LDA UNSAVECHR ;CLOSE INPUT BUFFER?
CMP B
JZ S2A ;IF YES, DISABLE COPY
LDA SAVECHR ;OPEN INPUT BUFFER?
CMP B
MOV A,B ;RESTORE CHARACTER TYPED
JNZ NOTOG
LDA NFILFLG ;DO NOT ALLOW SAVE IF..
CPI TRUE ;..THIS FLAG IS SET.
JZ TERML
MVI A,TRUE ;0FFH -- ALLOW COPY INTO FILE
JMP S2B
S2A: MVI A,FALSE ;0 -- STOP COPY INTO FILE
S2B: STA SAVEFLG
CALL BUFMSG
JMP TERML
;
BUFMSG: CALL ILPRT
DB CR,LF,LF,'** Memory buffer ',0
LDA SAVEFLG
ORA A
JZ BUFMSG2
CALL ILPRT
DB 'open **',CR,LF,LF,':',BELL,0
RET
;
BUFMSG2:
CALL ILPRT
DB 'closed **',CR,LF,LF,BELL,0
RET
;
EXITMEN:
CALL CRLF
CALL CLREOS ;CLEAR TO END OF SCREEN TO CLEAN UP ANY MESS
JMP MENU0
;
SENDREADY:
CALL IN$MODCTLP
CALL ANI$MODSNDB
CALL CPI$MODSNDR
RET
;
SENDLF: CALL SENDREADY
JNZ NOLFYET ;GO IF NOT READY FOR OUTPUT YET
MVI A,LF
JMP NOTOG ;SEND LF
NOLFYET:
CALL EXITTEST
JNC EXITMEN ;GO IF SO, SO DON'T GET HUNG UP
JMP SENDLF ;ELSE KEEP TRYING TO SEND LF
;
SENDLOG:
PUSH H
SNDLG2: CALL STAT
JZ SNDLG2
CALL KEYIN
CALL UCASE
CPI 'L' ;TEST IF LIST OF STRINGS REQUESTED
JZ GIVESTRS
SUI '0'
CPI 10
JNC ENDLOG
ADD A ;X2
ADD A ;X4
ADD A ;X8
ADD A ;X16
MOV E,A
MVI D,0
PUSH D
POP H
DAD D ;X32 IN HL
LXI D,STRINGS ;DE POINTS TO START OF STRINGS
DAD D
LOGLP: CALL SENDREADY
JNZ NOSENDLOG ;GO IF NOT READY
MOV A,M ;GET LOGON BYTE
INX H
CPI 0 ;IS IT THE END?
JZ ENDLOG ;GO IF SO
CALL OUT$MODDATP
JMP LOGLP
NOSENDLOG:
CALL EXITTEST ;TEST SO DON'T GET HUNG UP
JNC EXITLOG ;GO IF OPERATOR WANTS EXIT
JMP LOGLP
;
ENDLOG: POP H
JMP TERML
;
EXITLOG:
POP H
JMP EXITMEN
;
EXITTEST:
CALL STAT ;KEYPRESS?
JZ NOKEY
CALL KEYIN
MOV B,A
LDA EXITCHR ;SEE IF OPERATOR WANTS EXIT
CMP B
JNZ NOKEY ;GO IF WRONG KEY
STC
CMC ;RESET FOR EXIT
RET
NOKEY: STC ;SET FOR NO KEY OR WRONG KEY
RET
;
GIVESTRS:
CALL ILPRT
DB CR,LF,' List of Strings',CR,LF,LF,LF,0
LXI H,STRINGS
SHLD STRSAVE
MVI B,'0'
GVSTRS1:
MOV A,B
CALL TYPE
CALL ILPRT
DB ' = ',0
LHLD STRSAVE
MOV A,M
CPI 0
JNZ NONULL
CALL ILPRT
DB '* null string *',0
JMP GVSTRS2
NONULL: LHLD STRSAVE
NONUL2: MOV A,M
CPI 0
JZ GVSTRS2
CPI CR
CNZ TYPE
JNZ NOTACR
PUSH H
CALL ILPRT
DB '<CR>',0
POP H
NOTACR: INX H
JMP NONUL2
;
GVSTRS2:
MVI A,'9'
CMP B
JZ GVSTRS3
INR B
LHLD STRSAVE
LXI D,32
DAD D
SHLD STRSAVE
CALL CRLF
JMP GVSTRS1
;
GVSTRS3:
CALL ILPRT
DB CR,LF,LF,'Enter number to transmit string',CR,LF,0
POP H
JMP SENDLOG
;
EXTFLG: MVI A,TRUE
STA EXACFLG
JMP TERML
;
RCVREADY:
CALL IN$MODCTLP
CALL ANI$MODRCVB
CALL CPI$MODRCVR
RET
;
LSTMSG: LDA LISTFLG
ORA A
JZ LSTMSG2
CALL ILPRT
DB 'Printer is on',CR,LF,0
RET
LSTMSG2:
CALL ILPRT
DB 'Printer is off',CR,LF,0
RET
;
NOTOG: CALL OUT$MODDATP
MOV B,A
LDA LOCFLG
ORA A
JNZ LTYPE
LDA ECHOFLG
ORA A
JZ CHKCR
LTYPE: MOV A,B
CALL TYPE
CALL CHKSAVE ;TO STORE LOCAL IF BUFFER OPEN
CALL CHKPRNT
CHKCR: MVI A,CR
CMP B
JNZ TERML
LDA ADDLF
ORA A
JZ TERML
JMP SENDLF
;
TERML: CALL RCVREADY ;TEST FOR RECEIVED CHARACTER
JNZ TERM
CALL IN$MODDATP
ANI 7FH ;STRIP PARITY
JZ TERM
GIVLF: CALL TYPE
MOV B,A
CALL CHKSAVE
CALL CHKPRNT
LDA ECHOFLG
ORA A
JZ NOECHO
MOV A,B
CALL OUT$MODDATP
NOECHO: MVI A,CR
CMP B
JNZ TERM
LDA ADDLF
JZ TERM
LDA ECHOFLG
ORA A
JNZ SENDLF
MVI A,LF
JMP GIVLF
;
CHKSAVE:
LDA SAVEFLG
ORA A
RZ
MOV M,B
INX H
SHLD HLSAVE ;MENU COMMAND DESTROYS HL-REG..
MVI A,LF
CMP B
JNZ NOCOLON ;..TYPE ":" AFTER EACH LINE FEED..
MVI A,':' ;..WHEN MEMORY SAVE ACTIVE.
CALL TYPE
NOCOLON:
CALL GETMAX
CMP H
PUSH B
CZ INTDSKSV
POP B
RET
;
GETMAX: LDA SAVCCP
ORA A
LDA 7
JZ SUB1
SBI 8 ;..PAGE BELOW CCP ..
SUB1: DCR A ;..OR BDOS HAS BEEN..
RET ;..REACHED AND DISKSAVE IS NEEDED.
;
CHKPRNT:
LDA LISTFLG ;OUT TO PRINTER?
ORA A
RZ ;RETURN IF NOT
LDA NFILFLG ;IS BUFFER USED FOR FILE?
ORA A
JZ NOBUFF ;DON'T BUFFER PRINTER IF SO, HOWEVER CHARACTERS
;WILL BE LOST IF PRINTER IS SLOWER THAN MODEM
CALL GETMAX ;GET MAXIMUM FOR BUFFER
LHLD HLSAVE1
CMP H ;ARE WE THERE?
JNZ NOTMAX ;GO IF NOT
LXI H,BOTTRAM ;FLUSH BUFFER
SHLD HLSAVE1
SHLD HLSAVE2
NOTMAX:
MOV M,B ;SAVE CHARACTER IN BUFFER
INX H ;INCREMENT END OF BUFFER
SHLD HLSAVE1
MVI A,TRUE ;SET FLAG FOR PRINTER OUTPUT
STA LISTMOR
RET
;
NOBUFF:
CALL LSTSTAT
RZ ;RETURN IF PRINTER BUSY
MOV C,B ;ELSE PRINT CHARACTER
CALL LISTER
RET
;
GOLIST:
CALL LSTSTAT
RZ ;RETURN IF PRINTER BUSY
LHLD HLSAVE2 ;GET LOCATION OF NEXT CHARACTER TO PRINT
MOV C,M ;GET CHARACTER
INX H ;INCREMENT POINTER
SHLD HLSAVE2
CALL CMPBUFF ;CHECK FOR END OF BUFFER
CALL LISTER ;PRINT
RET
;
;ROUTINE CHECKS FOR END OF BUFFER, RESETS BUFFER IF SO AND STOPS
;PRINTER OUTPUT
;
CMPBUFF:
LHLD HLSAVE2
XCHG
LHLD HLSAVE1
MOV A,L
SUB E
MOV L,A
MOV A,H
SBB D
ORA L
RNZ
LXI H,BOTTRAM
SHLD HLSAVE1
SHLD HLSAVE2
XRA A
STA LISTMOR
RET
;
INTDSKSV:
MVI A,XOFF ;SEND A CTRL-S TO STOP..
CALL OUT$MODDATP ;..REMOTE COMPUTER OUTPUT.
MVI D,0 ;D IS THE BUFFER COUNT
CALL INMODEM ;GET LAST BYTES SENT..
STA LASTBYT1 ;..AFTER CTRL-S.
CALL INMODEM ;ADD MORE CALLS TO INMODEM..
STA LASTBYT2 ;..AND STA LASTBYT# IF YOU ARE..
PUSH D
CALL NUMREC1
CALL WRTDSK ;WRITE THE RECORDS
POP D
LXI H,BOTTRAM
INR D
DCR D ;TEST BUFFER COUNT FOR ZERO
JZ CTRLQ
LDA LASTBYT1 ;GET THE LAST BYTES THAT WERE..
MOV M,A ;..SAVED AND PUT THEM IN..
INX H ;..BOTTRAM.
CALL TYPE
DCR D
JZ CTRLQ
LDA LASTBYT2
MOV M,A
INX H
CALL TYPE
CTRLQ:
MVI A,XON ;SEND START CHARACTER..
CALL OUT$MODDATP ;..TO REMOTE COMPUTER.
RET
;
;THIS SUBROUTINE WILL LOOP UNTIL THE MODEM RECEIVES A CHARACTER
;OR 100 MILLISECONDS. IF A CHARACTER IS RECEIVED, A FLAG IS SET
;TO STORE THE CHARACTER. A MAXIMUM OF TWO CHARACTERS ARE STORED,
;BUT MORE MAY BE STORED IF DESIRED (SEE COMMENT IN "INTDSKSV"
;ABOVE).
;
INMODEM:
PUSH H
LXI H,625
CALL FIXCNT
PUSH H
POP B
POP H
TIMERL:
CALL RCVREADY
JZ GETBYTE
DCX B
MOV A,B
ORA C
JNZ TIMERL
RET
;
GETBYTE:
CALL IN$MODDATP
INR D
RET
;
NUMRECS:
MVI M,EOFCHAR
INX H
LXI D,127
DAD D
NUMREC1:
LXI D,-(BOTTRAM)
DAD D
MOV A,L ;DIVIDE HL BY 128..
ORA A
RAL ;..TO GET THE..
MOV L,H ;..NUMBER OF SECTORS
MVI H,0
PUSH PSW
DAD H
POP PSW
MVI A,0
ADC L
MOV L,A ;RETURNS WITH NUMBER OF..
RET ;..128 BYTE RECORDS IN HL.
;
WRTDSK: LXI D,BOTTRAM
NEXTWRT:
MVI C,STDMA
CALL BDOSRT
PUSH D
LXI D,FCB3
MVI C,WRITE
CALL BDOSRT
POP D
XCHG
PUSH D
LXI D,128
DAD D
POP D
XCHG
DCX H
MOV A,H
ORA L
JNZ NEXTWRT
RET
;
CLOSE3: LXI D,FCB3
MVI C,CLOSE
CALL BDOS
RET
;
BDOSRT:
PUSH B
PUSH D
PUSH H
PUSH PSW
CALL BDOS
POP PSW
POP H
POP D
POP B
RET
;
MOVE2:
LXI H,FCB3
CALL INITFCBS
LXI H,FCB
LXI D,FCB3
MVI B,12
CALL MOVE
RET
;
;FILE TRANSFER ROUTINE - CALLED WITH
;CONTROL-T FROM TERMINAL ROUTINE.
;TRANSFER MAY BE CANCELLED WHILE SENDING BY USING CONTROL-X.
;
TRANSFER:
PUSH H
PUSH D
PUSH B
PUSH PSW
LXI H,FCB4
CALL INITFCBS ;INITIALIZES FCBS POINTED..
LXI H,FCB+16 ;..TO BY HL REG.
CALL INITFCBS
GET:
CALL GETNAME
LDA CMDBUF+2 ;WAS FILE ENTERED
CPI 20H
JZ TRANSL2
CALL MOVE4
CALL OPEN4
CPI 0FFH ;RETURN WITH 0FFH MEANS
JNZ CONTIN ;FILE DOES NOT EXIST
TRANSL1:
CALL ILPRT
DB CR,LF,'++ File does not exist ++',CR,LF,0
TRANSL2:
CALL ILPRT
DB 'Type "R" to return to modem',CR,LF
DB 'Type "A" to re-enter name: ',BELL,0
CALL KEYIN
CALL UCASE
CALL TYPE ;ECHO RESPONSE
CALL CRLF
CPI 'A'
JZ GET
CPI 'R'
JZ RETURN
JMP TRANSL2
;
CONTIN:
LXI D,80H
MVI C,STDMA
CALL BDOS
READMR:
CALL READ80
CPI 1 ;END OF FILE
JZ RETURNS
CPI 2 ;BAD READ
JZ RETURNU
CALL SEND80C
CPI EOFCHAR ;END OF FILE - OMIT IF OBJECT..
JZ RETURNS ;..CODE IS TO BE SENT.
CPI CAN ;CANCELLATION?
JZ TRANCAN
JMP READMR
;
RETURNS:
CALL ILPRT
DB CR,LF,'File transfer completed',CR,LF,BELL,0
JMP RETURN
;
RETURNU:
CALL ILPRT
DB CR,LF,'++ File transfer unsuccessful ++',CR,LF,BELL,0
JMP RETURN
;
TRANCAN:
CALL ILPRT
DB CR,LF,LF,'++ Transfer cancelled ++',CR,LF,BELL,0
RETURN:
POP PSW
POP B
POP D
POP H
RET
;
INITFCBS: ;ENTRY AT +2 WILL LEAVE..
MVI M,0 ;..DRIVE NO. INTACT.
INX H ;WILL INITIALIZE AN FCB..
MVI B,11 ;..POINTED TO BY HL-REG. FILLS 1ST POS
LOOP10:
MVI M,' ' ;..WITH 0, NEXT 11 WITH..
INX H ;..WITH BLANKS, AND LAST..
DCR B ;..21 WITH NULLS.
JNZ LOOP10
MVI B,21
LOOP11:
MVI M,0
INX H
DCR B
JNZ LOOP11
RET
;
GETNAME:
CALL ILPRT
DB CR,LF,'Enter file name to be transferred - <CR> TO QUIT: ',0
LXI D,CMDBUF
CALL INBUFF
CALL CRLF
RET
;
MOVE4:
LXI D,CMDBUF
LXI H,FCB4
CALL CPMLINE
RET
;
OPEN4:
LXI D,FCB4
MVI C,OPEN
CALL BDOS
RET
;
READ80:
LXI D,FCB4
MVI C,READ
CALL BDOS
RET
;
SEND80C:
MVI B,80H
LXI H,80H
SENDCH1:
PUSH D
CALL SPEED
POP D
MOV A,M
CPI EOFCHAR
JNZ SENDCH2
LDA EOFSEND
ORA A
RZ
MOV A,M
SENDCH2:
CALL MODOUT
CPI EOFCHAR
RZ
CALL STAT ;TEST TO SEE IF
ORA A ;CANCELLATION REQUESTED
JZ SKIP12
CALL KEYIN
CPI CAN
RZ
SKIP12: INX H
DCR B
JNZ SENDCH1
RET
;
MODOUT: PUSH PSW
MODOUTL:
LDA XOFFTST
ORA A
CNZ TXOFF
CALL SENDREADY
JNZ MODOUTL
LDA STRLF
ORA A
JZ NOLFTST
POP PSW
PUSH PSW
CPI LF
JZ NOTMOUT
NOLFTST:
POP PSW
PUSH PSW
STA SAVEOUT ;SAVE OUTPUT FOR POSSIBLE ECHO TEST
CALL OUT$MODDATP
LDA ECHWAIT ;DO WE WANT TO TEST FOR ECHOED CHARACTER?
ORA A
CNZ WAITECHO ;GO IF SO
NOTMOUT:
POP PSW
CALL TYPE
CPI CR
JZ DLYCR
RET
;
DLYCR: LDA XONWAIT ;WAIT FOR XON AFTER CR?
ORA A
JNZ WAITXON
LDA CRDLY ;EXTRA DELAY AFTER CR
JMP DLYCR2
;
SPEED: LDA BYTDLY ;GET SPEED VALUE (0-9)
;DELAY IS FROM 0.02 SEC FOR SPDVAL = 1
;TO 0.18 SEC FOR SPDVAL = 9
DLYCR2: ORA A
RZ ;RETURN IF 0
MOV C,A
SPDLP: CALL SPD1 ;OUTER LOOP
DCR C
RZ
JMP SPDLP
;
SPD1: PUSH H
LXI H,357 ;ABOUT 0.02 SEC
LDA XOFFTST
ORA A
JZ SPD2
LXI H,102 ;ADJUST FOR XOFF TESTING
LDA ECHOFLG
ORA A
JZ SPD2
LDA LOCFLG
ORA A
JZ SPD2
LXI H,76 ;ADJUST AGAIN FOR REMOTE ECHO
SPD2: CALL FIXCNT
PUSH H
POP D
POP H
SPDLP1: DCX D ;INNER LOOP
LDA XOFFTST
ORA A
CNZ TXOFF
MOV A,E
ORA D
RZ
JMP SPDLP1
;
TXOFF: CALL RCVREADY
RNZ
CALL IN$MODDATP
ANI 7FH
CPI XOFF
CZ WAITXON
RET
;
WAITXON:
CALL RCVREADY
JNZ WTXON2
CALL IN$MODDATP
ANI 7FH
CPI XON
RZ
WTXON2: CALL STAT ;TEST TO SEE IF
ORA A ;CANCELLATION REQUESTED
JZ WAITXON ;SO DON'T GET HUNG UP
CALL KEYIN
CPI CAN
RZ
JMP WAITXON
;
WAITECHO:
MVI A,50 ;1 SECOND MAXIMUM DELAY WAITING FOR ECHO
STA MECHDLY
WTECH1: CALL RCVREADY ;IS THERE INPUT?
JNZ WTECH2 ;GO IF NOT
CALL IN$MODDATP ;GET INPUT
ANI 7FH
MOV C,A ;SAVE INPUT
LDA SAVEOUT ;GET OUTPUT
CMP C ;ARE THEY THE SAME?
RZ ;RETURN IF SO
LDA SAVEOUT ;GET OUTPUT
CPI TAB ;CHECK IF TAB
JNZ WTECH2 ;GO IF NOT
MVI A,SPACE ;MAYBE REMOTE CONVERTS TABS TO SPACES
CMP C
RZ ;RETURN IF SPACE ECHOED ON TAB OUTPUT
WTECH2: LDA MECHDLY ;LOOP FOR 1 SECOND
DCR A
STA MECHDLY
RZ
MVI A,1 ;0.02 SECOND
CALL DLYCR2
JMP WTECH1
;
; Check for any garbage characters on line.
;
CKMODM: CALL RCVREADY ;ANY CHARACTERS READY TO RECEIVE?
RNZ ;IF NOT, RETURN
CALL IN$MODDATP ;OTHERWISE GET THE CHARACTER AND IGNORE
JMP CKMODM ;CHECK FOR ANY ADDITIONAL CHARACTERS
;
;
LINK SENDRECV
;
NI 7FH
CPI XON