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
/
SIMTEL
/
CPMUG
/
CPMUG025.ARK
/
TTYDRV.MAC
< prev
next >
Wrap
Text File
|
1984-04-29
|
2KB
|
106 lines
; ====================
; : T T Y D R V :
; ====================
;
; DISASSEMBLED AND ANNOTATED TELETYPE DRIVER FROM THE
; MICROSOFT FORTRAN PACKAGE.
; R.C. Minnick - Box 306 - Ouray, CO 81427
;
;
; VERSION 1.0 6/22/78
;
ENTRY $DRV3
EXT $IOERR,$BL,$BF,$ERR,$TTYIN,$TTYOT
;
; INDEX TABLE
;
$DRV3: DW FREAD ;FORMATTED READ
DW FWRITE ;FORMATTED WRITE
DW IOERR ;BINARY READ
DW IOERR ;BINARY WRITE
DW EOF ;REWIND
DW EOF ;BACKSPACE
DW EOF ;ENDFILE
;
; EOF DETECTED - RETURN CY=0, ZF=0
;
EOF: XRA A
RET
;
; I/O ERROR DETECTED
;
IOERR: JMP $IOERR
;
; FORMATTED READ
;
FREAD: XRA A
STA $BL ;SET BUF LENGTH=0
FILL: CALL $TTYIN ;GET DATUM
ANI X'7F' ;MASK
CPI X'0A' ;BUFFER EMPTY?
JZ FILL ;YES, TRY AGAIN
PUSH PSW ;SAVE DATUM
LHLD $BL ;BUFFER LENGTH
MVI H,0 ;HL=BUF LENGTH AS 16 BITS
XCHG
LHLD $BF ;BUFFER PTR
DAD D ;HL=INDEXED BUF PTR, DE=LENGTH
POP PSW ;DATUM
MOV M,A ;PUT IT IN BUF
INX D
XCHG ;DE=BUF PTR, HL=NEW LENGTH
SHLD $BL ;SAVE NEW LENGTH
CPI X'0D' ;CRET?
RZ ;YES - BUFFER FULL
MOV A,L
CPI X'80' ;TOO MANY DATA IN BUF?
JC FILL ;NO
CALL $ERR ;YES - ERROR & RETURN
STAX D
XRA A
RET
;
; FORMATTED WRITE
;
FWRITE: LDA $BL ;BUFFER LENGTH
ORA A
RZ ;RETURN IF BUF EMPTY
LHLD $BF ;BUFFER BASE POINTER
DCR A ;DECREMENT LENGTH
PUSH PSW ;SAVE LENGTH
MVI A,X'0D'
CALL $TTYOT ;SEND CRET TO CON:
MOV A,M ;1ST BUF DATUM (CARR CONTROL)
CPI "+" ;CONTROL FOR NO LINE FEED
JZ CONFW2
CPI "1" ;CONTROL FOR FORM FEED
JNZ CONFW1 ;1 OR 2 LINE FEEDS
MVI A,X'0C'
CALL $TTYOT ;DO FORM FEED
JMP CONFW2
; 1 OR 2 LINE FEEDS
CONFW1: MVI A,X'0A' ;FIRST LINE FEED
CALL $TTYOT
MOV A,M
CPI " " ;CARR CONTROL=SPACE?
JZ CONFW2 ;YES, SKIP 2ND LINE FEED
CPI "0" ;0 IS 2 LINE FEEDS
JNZ CONFW2
MVI A,X'0A'
CALL $TTYOT ;SECOND LINE FEED
; NO LINE FEED
CONFW2: POP PSW ;CURRENT BUF LENGTH
INX H ;BUF PTR
; LOOP THROUGH BUFFER
CONLOP: RZ ;IF BUF LENGTH=0
PUSH PSW ;SAVE LENGTH
MOV A,M ;DATUM
INX H
CALL $TTYOT
POP PSW
DCR A
JMP CONLOP
;
;
END