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
/
CONSOLE.ASM
next >
Wrap
Assembly Source File
|
1991-02-02
|
10KB
|
593 lines
;
; CONSOLE.ASM
;
;Console I/O routines for MODEM9.xx.
;
SHOW: CPI LF
JZ CTYPE
CPI CR
JZ CTYPE
CPI 9
JZ CTYPE
CPI ' '
JC SHOWHEX
CPI 7FH
JC CTYPE
SHOWHEX:
PUSH PSW
MVI A,'('
CALL CTYPE
POP PSW
CALL HEXO
MVI A,')'
JMP CTYPE
;
CTYPE: PUSH B
PUSH D
PUSH H
MOV E,A
MVI C,WRCON
CALL BDOS
POP H
POP D
POP B
RET
;
CRLF: PUSH PSW
MVI A,CR
CALL TYPE
MVI A,LF
CALL TYPE
POP PSW
RET
;
TYPE: PUSH PSW
PUSH B
PUSH D
PUSH H
MOV C,A
VTYPE: CALL $-$
POP H
POP D
POP B
POP PSW
RET
;
STAT: PUSH B
PUSH D
PUSH H
VSTAT: CALL $-$
POP H
POP D
POP B
ORA A
RET
;
KEYIN: PUSH B
PUSH D
PUSH H
VKEYIN: CALL $-$
POP H
POP D
POP B
RET
;
LISTER: PUSH B
PUSH D
PUSH H
VLIST: CALL $-$
POP H
POP D
POP B
RET
;
LSTSTAT:
PUSH B
PUSH D
PUSH H
VLSTAT: CALL $-$
POP H
POP D
POP B
ORA A
RET
;
UCASE: CPI 61H ;CHANGES LOWER CASE CHARACTER..
RC ;..IN A-REG TO UPPER CASE.
CPI 7BH
RNC
ANI 5FH
RET
;
DECOUT: PUSH PSW
PUSH B
PUSH D
PUSH H
LXI B,-10
LXI D,-1
DECOU2: DAD B
INX D
JC DECOU2
LXI B,10
DAD B
XCHG
MOV A,H
ORA L
CNZ DECOUT
MOV A,E
ADI '0'
CALL CTYPE
POP H
POP D
POP B
POP PSW
RET
;
;----> DHXOUT: - DOUBLE PRECISION HEX OUTPUT ROUTINE.
;
DHXOUT:
PUSH H
PUSH PSW
MOV A,H ;GET MS BYTE
CALL HEXO ;OUTPUT HIGH ORDER BYTE
MOV A,L ;GET LS BYTE
CALL HEXO ;OUTPUT LOW ORDER BYTE
POP PSW
POP H
RET
;
HEXO: PUSH PSW
RAR
RAR
RAR
RAR
CALL NIBBL
POP PSW
NIBBL: ANI 0FH
CPI 10
JC ISNUM
ADI 7
ISNUM: ADI '0'
JMP TYPE
;
SHFTYPE:
PUSH PSW
CALL ILPRT
DB 'ctrl-',0
POP PSW
ADI 40H
CALL TYPE
;
;WRITE A STRING OF CHARACTERS
;
ILPRT: XTHL
ILPLP: MOV A,M
ORA A
JZ ILPRET
CALL CTYPE
INX H
JMP ILPLP
ILPRET: XTHL
RET
;
;WRITE A STRING OF CHARACTERS EXCEPT IN QUIET MODE
;
ILPRTQ: XTHL
ILPLPQ: MOV A,M
ORA A
JZ ILPRETQ
LDA QFLG
ORA A
MOV A,M
CNZ CTYPE
INX H
JMP ILPLPQ
ILPRETQ:
XTHL
RET
;
;Duplicates 'read buffer' routine same as CP/M function 10,
;but does not use CTL-C (reason for the routine). Does
;allow controls U, R, E and H (backspace). Outputs bell if
;the input is greater than the buffer.
;
INBUFF:
PUSH PSW
PUSH H
PUSH B
PUSH D ;'DE' REGISTERS MUST BE PUSHED LAST
ISTART: CALL CLEAR ;CLEAR THE BUFFER AREA
POP D ;GET ADDRESS OF BUFFER ON RETRIES
PUSH D ;RESTORE STACK
XRA A
INX D ;ADDRESS COUNT FIELD
STAX D ;INITIALIZE WITH A ZERO IN COUNT BYTE
INX D
XCHG ;ADDRESS FIRST BUFFER BYTE WITH 'HL'
INBUFA: CALL CONIN
CPI 0DH ;IS IT A RETURN?
JZ INBUFR ;IF SO, THEN RETURN
CPI 7FH ;IS IT A DELETE?
JZ DELETE
CPI 8 ;CTL-H WILL BACKSPACE..
JZ DELETE ;..OVER DELETED CHAR.
CPI 'U'-40H ;IS IT A CTL-U
JZ INBUFO ;OUTPUT # CR-LF AND START OVER
CPI 'R'-40H ;CTL-R RETYPES LINE
JZ RETYPE
CPI 'E'-40H
JZ PCRLF
CPI 20H ;NO CONTROL CHARACTERS OTHER..
JC INBUFA ;..THAN ABOVE ALLOWED.
MOV B,A ;SAVE INPUTTED CHARACTER
XCHG ;SAVE 'HL' IN 'DE'
POP H ;GET ADDRESS OF BUFFER IN 'HL'
PUSH H ;RESTORE STACK
INX H ;ADDRESS COUNT BYTE
INR M ;INCREASE COUNT BYTE
DCX H ;ADDRESS MAXIMUM
MOV A,M ;PUT MAXIMUM IN 'A'
INX H ;ADDRESS COUNT
CMP M ;COMPARE COUNT TO MAXIMUM
JC ALERT ;IF MAXIMUM, RING BELL AND WAIT FOR CR
XCHG ;RESTORE BUFFER POINTER TO 'HL'
MOV M,B ;PUT INPUTTED CHARACTER IN BUFFER
MOV A,B ;OUTPUT IT
CALL CONOUT
INX H ;BUMP POINTER
JMP INBUFA ;GET NEXT CHARACTER
;
DELETE: XCHG ;SAVE BUFFER POINTER IN 'DE'
POP H ;ADDRESS BEGINNING OF BUFFER
PUSH H ;RESTORE STACK
INX H ;ADDRESS COUNT FIELD
MOV B,A ;SAVE DELETE CHAR - 7FH OR 08H
MOV A,M
SUI 1 ;DECREASE COUNT
MOV M,A
JC NODEL ;DON'T DELETE PAST BEGINING OF BUFFER.
XCHG ;RESTORE BUFFER POINTER TO 'HL'
DCX H ;POINT TO LAST BYTE INPUTTED
MOV A,B ;GET BACK EITHER 7FH OR 08H
MOV B,M ;GET CHARACTER BEING DELETED
MVI M,20H ;RESTORE BLANK
CPI 8
JZ BKSPC
CPI 7FH
JZ BKSPC0
JMP INBUFA ;GET NEXT CHARACTER
;
NODEL: INR M ;DON'T LEAVE COUNT NEGATIVE
XCHG ;RESTORE POINTER TO 'HL'
JMP INBUFA
;
BKSPC0: MVI A,08H
BKSPC: CALL CONOUT ;TRUE ERASE IF 08H
MVI A,20H
CALL CONOUT
MVI A,8
CALL CONOUT
JMP INBUFA
;
INBUFO: MVI A,'#'
CALL CONOUT
MVI A,0DH
CALL CONOUT
MVI A,0AH
CALL CONOUT
JMP START
;
RETYPE: POP D
PUSH D
INX D ;POINT TO CURRENT NUMBER..
LDAX D ;..OF CHARACTERS.
MOV B,A
MVI A,'#'
CALL CONOUT
MVI A,0DH
CALL CONOUT
MVI A,0AH
CALL CONOUT
MOV A,B ;TEST IF ZERO INPUT
ORA A
JZ INBUFA
CTLRLP: INX D
LDAX D
CALL CONOUT
DCR B
JNZ CTLRLP
JMP INBUFA
;
ALERT: MVI A,7
CALL CONOUT
DCR M
XCHG
JMP INBUFA
;
PCRLF: MVI A,0DH
CALL CONOUT
MVI A,0AH
CALL CONOUT
JMP INBUFA
;
INBUFR: MVI A,0DH
CALL CONOUT
MVI A,0AH
CALL CONOUT
POP D
POP B
POP H
POP PSW
RET
;
CLEAR: POP D ;ACCOUNTS FOR CALL
POP H ;ADDRESS BUFFER IN 'HL'
PUSH H ;RESTORE..
PUSH D ;..STACK
MOV B,M ;SAVE MAXIMUM IN 'B'
INX H ;POINT TO FIRST..
INX H ;..BUFFER BYTE.
MVI A,20H
CLEARL: MOV M,A
INX H
DCR B
JNZ CLEARL
RET
;
CONIN: PUSH H
PUSH D
PUSH B
CONINLP:
CALL CONSTAT
ORA A
JZ CONINLP
CALL CONIN1
CPI 61H ;CHANGE TO UPPER..
JC NOUCASE ;..CASE SINCE CP/M..
CPI 7BH ;..DOES THE SAME.
JNC NOUCASE
ANI 5FH
NOUCASE:
POP B
POP D
POP H
RET
;
CONIN1: LHLD 1
LXI D,6
DAD D
PCHL
;
CONSTAT:
PUSH H
PUSH D
PUSH B
CALL CONST1
POP B
POP D
POP H
RET
;
CONST1: LHLD 1
LXI D,3
DAD D
PCHL
;
CONOUT: PUSH H
PUSH D
PUSH B
PUSH PSW
CALL CONOUT1
POP PSW
POP B
POP D
POP H
RET
;
CONOUT1:
LHLD 1
LXI D,9
DAD D
MOV C,A
PCHL
;
;
;Parses a CP/M buffer into format same as CP/M command line.
;
;Loads a command line addressed by 'DE' registers (max # characters in
;line in 'DE', number of characters in the line in 'DE'+1, line starts
;in 'DE'+2) into FCB addressed by 'HL' registers. The FCB should be at
;least 33 bytes in length. The command line buffer must have a maximum
;length of at least one more than the greatest number of characters
;that will be needed.
;
CPMLINE:
PUSH PSW
PUSH B
PUSH D
PUSH H
CALL CINIT ;FILLS FCBS WITH BLANKS AND NULLS
XCHG ;GET START OF COMMAND LINE IN 'HL'
INX H ;ADDRESS # BYTES IN CMD LINE
MOV E,M ;LOAD 'DE' PAIR WITH # BYTES
MVI D,0
INX H
DAD D ;POINT TO BYTE AFTER LAST CHAR..
MVI M,0DH ;..IN CMD LINE AND STORE DELIMITER
POP H ;RESTORE 'HL' AND 'DE'
POP D
PUSH D
PUSH H
INX D ;ADDRESS START OF COMMAND
INX D
CALL DRIVE
NAME1: MVI C,8 ;TRANSFER FIRST FILENAME TO FCB
CALL TRANS
CPI 0DH
JZ CDONE
CPI 20H ;IF SPACE, THEN START OF..
JZ NAME2 ;..SECOND FILENAME.
TYPE1: POP H ;FILETYPE MUST BE AFTER..
PUSH H ;..EIGHTH BYTE OF NAME
LXI B,9
DAD B
MVI C,3 ;TRANSFER TYPE OF FIRST FILE
CALL TRANS
CPI 0DH
JZ CDONE
NAME2: LDAX D ;EAT MULTIPLE SPACES..
CPI 20H ;..BETWEEN NAMES
JNZ NAME2C
INX D
JMP NAME2
LDAX D
CPI 0DH ;TEST IF FIRST NAME..
JZ CDONE ;..ONLY AND THEN SPACE
NAME2C: POP H ;SECOND NAME STARTS IN 16TH BYTE
PUSH H ;POINT 'HL' TO THIS BYTE
LXI B,16
DAD B
CALL DRIVE
MVI C,8
CALL TRANS
CPI 0DH
JZ CDONE
TYPE2: POP H ;SECOND TYPE STARTS IN 25TH BYTE.
PUSH H
LXI B,25
DAD B
MVI C,3
CALL TRANS
CDONE: POP H
PUSH H
INX H ;POINT TO 1ST CHAR OF 1ST NAME IN FCB
CALL CSCAN ;CHECK FOR * (AMBIGUOUS NAMES).
POP H
PUSH H
LXI B,17 ;POINT TO 1ST CHAR OF 2ND NAME IN FCB.
DAD B
CALL CSCAN
POP H
POP D
POP B
POP PSW
RET
;
CINIT: PUSH H ;INITIALIZES FCB WITH 1 NULL (FOR 1ST DRIVE),..
PUSH B ;..11 BLANKS, 4 NULLS, 1 NULL (FOR 2ND DRIVE),.. MVI M,0 ;..11 BLANKS, AND 4 NULLS
INX H
MVI B,11
MVI A,20H
CALL INITFILL
MVI B,5
MVI A,0
CALL INITFILL
MVI B,11
MVI A,20H
CALL INITFILL
MVI B,4
MVI A,0
CALL INITFILL
POP B
POP H
RET
;
INITFILL:
MOV M,A
INX H
DCR B
JNZ INITFILL
RET
;
DRIVE: INX D ;CHECK 2ND BYTE OF FILENAME. IF IT..
LDAX D ;..IS A ":", THEN DRIVE WAS SPECIFIED
DCX D
CPI ':'
JNZ DEFDR ;ELSE ZERO FOR DEFAULT DRIVE ('INIT' PUT ZERO)
LDAX D
ANI 5FH
SUI 40H ;CALCULATE DRIVE (A=1, B=2,...)..
MOV M,A ;..AND PLACE IT IN FCB
INX D ;ADDRESS FIRST BYTE OF..
INX D ;..IN CMD LINE..
DEFDR: INX H ;..AND NAME FIELD IN FCB
RET
;
TRANS: LDAX D ;TRANSFER FROM CMD LINE TO FCB..
INX D ;..UP TO NUMBER OF CHARS SPECIFIED..
CPI 0DH ;..BY 'C' REG. KEEP SCANNING FIELD..
RZ ;..WITHOUT TRANSFER UNTIL A DELIMITING..
CPI '.' ;..FIELD CHAR SUCH AS '.', BLANK, OR..
RZ ;..C/R (FOR END OF CMD LINE)
CPI 20H
RZ
DCR C
JM TRANS ;ONCE 'C' REG IS LESS THAN '0' KEEP READING
MOV M,A ;..CMD LINE BUT DO NOT TRANSFER TO FCB
INX H
JMP TRANS
;
CSCAN: MVI B,8 ;SCAN FILE NAME ADDRESSED BY 'HL'
TSTNAM: MOV A,M
CPI '*' ;IF '*' FOUND, FILL IN REST OF FIELD..
JZ FILL1 ;..WITH '?' FOR AMBIGUOUS NAME
INX H
DCR B
JNZ TSTNAM
JMP TSTTYP
;
FILL1: CALL FILL
TSTTYP: MVI B,3 ;SCAN AND FILL TYPE FIELD FOR NAME..
TSTTYPL:
MOV A,M ;..SPECIFIED ABOVE
CPI '*'
JZ FILL2
INX H
DCR B
RZ
JMP TSTTYPL
;
FILL2: CALL FILL
RET
;
FILL: MVI M,'?' ;ROUTINE TRANSFERS '?'
INX H
DCR B
JNZ FILL
RET
;
;
;In-line compare. Compares string addressed by 'DE' pair to string af-
;the call (ends with '0'). Return with carry set means strings not the
;same. All registers (except 'A') are unaffected.
;
ILCOMP:
XTHL ;POINT 'HL' TO 1ST CHARACTER
PUSH D
ILCOMPL:
MOV A,M ;'HL' POINTS TO IN-LINE STRING
ORA A ;END OF STRING IF ZERO
JZ SAME
LDAX D
CMP M
JNZ NOTSAME
INX H
INX D
JMP ILCOMPL
;
NOTSAME:
MVI A,0 ;IF NOT SAME, FINISH THRU..
NSLP: INX H ;..STRING SO RETURN WILL..
CMP M ;..GO TO INSTRUCTION AFTER..
JNZ NSLP ;..STRING AND NOT REMAINDER OF STRING
STC
SAME: POP D
INX H ;AVOIDS A NOP INSTRUCTION..
XTHL ;..WHEN RETURNING
RET
;
;
LINK TERM
;
X H