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
/
CPMUG041.ARK
/
TTY.ASM
< prev
next >
Wrap
Assembly Source File
|
1984-04-29
|
8KB
|
350 lines
;SYSTEM EQUATES
UART1 EQU 02400H ;ASCII PORT
UART2 EQU 02B00H ;TTY PORT
;
; BEGINING OF ROUTINE
ORG 0400H
;
LOOP:
LDA UART1+1
ANI 02H
JZ LOOP1
LDA UART1
ANI 7FH
CPI 0DH
CZ CRLF
STA UART1
CALL TTYXMIT
LOOP1:
LDA UART2+1
ANI 02H
JZ LOOP
CALL TTYRCV
STA UART1
JMP LOOP
CRLF:
PUSH PSW
CALL TTYXMIT
MVI A,0DH
CALL TTYXMIT
MVI A,0AH
STA UART1
CALL TTYXMIT
POP PSW
RET
; ASCRCV(4), VER. 2
; BY KEITH PETERSEN, W8SDZ. 10/30/78.
;
; THIS IS A PROGRAM TO CHANGE
; ASCII-CODED-BAUDOT TO ASCII.
; THE ROUTINE RETURNS WITH A 0FFH
; IN THE 'A' REGISTER IF CHARACTER
; IS TO BE IGNORED. OTHERWISE IT
; RETURNS WITH THE ASCII CHARACTER
; IN THE 'A' REGISTER. IT IS ASSUMED
; THAT A STATUS TEST HAS BEEN DONE BEFORE
; CALLING THIS ROUTINE TO DETERMINE THAT
; A BAUDOT CHARACTER IS AVAILABLE.
;
; EQUATES
;
BTTY: EQU 02B00H ;BAUDOT UART DATA PORT
CR: EQU 0DH ;ASCII CARRIAGE RETURN
LF: EQU 0AH ;ASCII LINE FEED
BELL: EQU 07H ;ASCII BELL
LTRS: EQU 1FH ;BAUDOT 'LTRS'
SPACE: EQU 04H ;BAUDOT 'SPACE'
FIGS: EQU 1BH ;BAUDOT 'FIGS'
APOS: EQU 27H ;APOSTROPHE
CNTC: EQU 03H ;CONTROL C
LARW: EQU 5FH ;LEFT ARROW
ASPC: EQU 20H ;ASCII SPACE
ATSN: EQU 40H ;"AT" SIGN
CNTV: EQU 16H ;CONTROL V
CNTO: EQU 0FH ;CONTROL O
RUBT: EQU 7FH ;RUBOUT
CNTE: EQU 05H ;CONTROL E
PCT: EQU 25H ;PERCENT SIGN
EQUL: EQU 3DH ;EQUALS SIGN
GRTH: EQU 3EH ;GREATER-THAN SIGN
CNTH: EQU 08H ;CONTROL H
LETH: EQU 3CH ;LESS-THAN SIGN
CNTB: EQU 02H ;CONTROL B
STAR: EQU 2AH ;ASTERISK
CNTI: EQU 09H ;CONTROL I
CNTZ: EQU 1AH ;CONTROL Z
CNTA: EQU 01H ;CONTROL A
CNTX: EQU 18H ;CONTROL X
UARW: EQU 5EH ;UP-ARROW
PLUS: EQU 2BH ;PLUS SIGN
RESL: EQU 5CH ;REVERSE SLANT
LBKT: EQU 5BH ;LEFT BRACKET
RBKT: EQU 5DH ;RIGHT BRACKET
ESCP: EQU 1BH ;ESCAPE KEY
ALMD: EQU 7DH ;ALTERNATE MODE KEY
BEGIN: EQU $ ;MY ADDRESS FOR THIS PROGRAM
;
; PROGRAM STARTS HERE
;
TTYRCV:
;
ASCRCV: PUSH H ;SAVE HL REGISTERS
LHLD CASAVE ;GET PRESENT CASE
;
START: LDA BTTY ;GET BAUDOT CHARACTER
ANI 1FH ;BAUDOT CHARACTERS ONLY
CPI FIGS
JZ UCASE
CPI LTRS
JZ LCASE
ORA A ;BAUDOT 'BLANK' ?
JZ TCASE
CPI SPACE
JNZ START1
LXI H,LTABLE ;SPACE GIVES LOWER CASE
;
START1: SHLD CASAVE ;SAVE PRESENT CASE
ADD L ;ADD CHAR. TO TABLE ADRS.
MOV L,A ;L POINTS TO ASCII CHAR.
MOV A,H ;GET H FOR CORRECTION
ACI 0 ;SEE IF CORRECTION NEEDED
MOV H,A ;H IS CORRECT NOW
XRA A ;PUT ZERO IN A REG.
STA FLAG ;CLEAR LTRS-FIGS LAST FLAG
MOV A,M ;GET ASCII EQUIVALENT
POP H ;RESTORE HL REGISTERS
ORA A ;IS IT PRINTABLE?
RNZ ;YES, VALID CHAR. RETURN
CMA ;MAKE 0FFH 'IGNORE FLAG'
RET ;RETURN TO CALLING PROGRAM
;
LCASE: LXI H,LTABLE ;LOWER CASE TABLE ADDRESS
JMP SETFLG ;SET LTRS LAST FLAG, EXIT
;
UCASE: LXI H,UTABLE ;UPPER CASE TABLE ADDRESS
JMP SETFLG ;SET FIGS LAST FLAG, EXIT
;
TCASE: LDA FLAG ;GET SHIFT REMINDER FLAG
CPI FIGS
JNZ FCASE
LXI H,TTABLE ;THIRD CASE TABLE ADDRESS
JMP CLRFLG
;
FCASE: CPI LTRS ;CHECK FOR LTRS LAST
JNZ CLRFLG
LXI H,FTABLE ;FOURTH CASE TABLE ADDRESS
;
CLRFLG: XRA A ;READY TO CLEAR FLAG
;
SETFLG: STA FLAG ;LTRS-FIGS LAST FLAG
SHLD CASAVE ;SAVE PRESENT CASE
MVI A,0FFH ;'IGNORE FLAG'
POP H ;RESTORE HL REGS.
RET ;RETURN TO CALLING PROGRAM
;
; THIS IS THE LOWER-CASE TABLE.
;
LTABLE: DB 0,'E',LF,'A SIU',CR,'DRJNFCK'
DB 'TZLWHYPQOBG',FIGS,'MXV'
;
; THIS IS THE UPPER-CASE TABLE.
;
UTABLE: DB 0,'3',LF,'- ',BELL,'87',CR,'$4'
DB APOS,',!:(5")2#6019?&',FIGS,'./;'
;
; THIS IS THE THIRD-CASE TABLE.
; IT IS USED FOR SPECIAL CHARACTERS.
; THE FIRST COLUMN IN THE TABLE
; THE ASCII CHARACTER EQUIVALENT.
; THE SECOND COLUMN IS THE SPECIAL
; CASE BAUDOT CHARACTER FROM WHICH
; THE CONVERSION IS MADE.
;
TTABLE: DB 0,CNTC,LF ;BL 3 LF
DB LARW,ASPC,ATSN ;- SP BELL
DB CNTV,CNTO,CR ;8 7 CR
DB ALMD,CNTE,PCT ;$ 4 '
DB RUBT,EQUL,ESCP ;, ! :
DB LETH,CNTH,LBKT ;( 5 "
DB GRTH,CNTB,STAR ;) 2 #
DB CNTI,CNTZ,CNTA ;6 0 1
DB CNTX,UARW,PLUS ;9 ? &
DB 0,RBKT,RESL ;FIG . /
DB 0 ;;
;
; THIS IS THE FOURTH CASE TABLE
; FOR LOWER-CASE ALPHA CHARACTERS.
;
FTABLE: DB 0,65H,LF,61H,ASPC,73H
DB 69H,75H,CR,64H,72H,6AH
DB 6EH,66H,63H,6BH,74H,7AH
DB 6CH,77H,68H,79H,70H,71H
DB 6FH,62H,67H,FIGS,6DH,78H
DB 76H
;
; TEMPORARY STORAGE AREA
;
;
;
; ASCXMT(4) REV. 2
; BY KEITH PETERSEN, W8SDZ. 10/29/78.
;
; THIS PROGRAM IS FOR TRANSMITTING ASCII
; THROUGH A BAUDOT MEDIUM USE A SPECIAL
; FORMAT OF FIGURES BLANK (X) - WHERE (X)
; IS A SPECIAL BAUDOT CHARACTER USED TO
; CONVEY THE ASCII EQUIVALENT CHARACTER TO THE
; RECEIVING END WHERE IT IS THEN CONVERTED BACK
; TO ASCII AGAIN. LOWER CASE ALPHA CHARACTERS
; ARE TRANSMITTED VIA A 4TH CASE, LTRSX BLANK (X).
;
; EQUATES
;
LTRSX: EQU 1FH
FIGSX: EQU 1BH
CRX: EQU 48H
LFX: EQU 42H
ALTMOD: EQU 7DH ;ALTERNATE MODE KEY
;
; PROGRAM STARTS HERE.
TTYXMIT:
; CALL WITH ASCII CHARACTER IN ACCUMULATOR.
;
;
STARTX: PUSH PSW ;SAVE REGISTERS USED
PUSH B
PUSH H
;
BAUDOT: MVI C,0 ;SET UP COUNTER
ANI 7FH ;STRIP PARITY BIT
CPI ALTMOD ;ALTERNATE MODE KEY?
JNZ BAUD2 ;NO, IGNORE NEXT ROUTINE
MVI A,09H ;BAUDOT '$'
JMP BAUD3
;
BAUD2: CPI 7BH ;ABOVE L.C. 'Z' ?
JNC TTY0 ;IF SO, IGNORE IT
LXI H,BTABLE ;POINT TO TABLE START
ADD L ;ADD CHARACTER VALUE
MOV L,A ;L POINTS TO BAUDOT CHAR.
MOV A,H ;GET H FOR CORRECTION
ACI 0 ;CORRECT IF NECESSARY
MOV H,A ;H IS NOW CORRECT
MOV A,M ;GET BAUDOT CHARACTER
ORA A ;IS IT A NON-PRINTING CHAR?
JZ TTY0 ;IF SO IGNORE IT
CPI CRX ;IS IT A CARRIAGE RETURN?
JZ TTYOUT-1 ;YES, HANDLE WITHOUT CASE TEST
CPI LFX ;IS IT A LINE FEED?
JNZ BAUD3 ;NO, IGNORE NEXT ROUTINE
MVI A,LTRSX
PUSH PSW ;SAVE IT ON STACK
MVI A,LFX
LXI H,SCASE ;POINT TO PRESENT CASE REG.
MVI M,40H ;SET IT TO LOWER CASE
JMP TTYOUT-2 ;SEND LF AND LTRSX
;
BAUD3: PUSH PSW ;SAVE CHARACTER
ANI 0C0H ;STRIP ALL BUT CASE BITS
LXI H,SCASE ;POINT TO PRESENT CASE REG.
CMP M ;SAME CASE AS PREVIOUS CHARACTER?
JZ TTYOUT ;YES NO CHANGE NECESSARY
MOV M,A ;UPDATE CASE REGISTER
ORA A
JZ TCASEX
CPI 80H
JZ UCASEX
CPI 0C0H
JNZ LCASEX
;
FCASEX: XRA A ;GET A BAUDOT 'BLANK'
PUSH PSW ;SAVE IT ON THE STACK
INR C ;INCRXEMENT CHARACTER COUNT
;
LCASEX: MVI A,LTRSX
JMP TTYOUT-2
;
TCASEX: XRA A ;GET A BAUDOT 'BLANK'
PUSH PSW ;SAVE IT ON THE STACK
INR C ;INCRXEMENT CHARACTER COUNT
;
UCASEX: MVI A,FIGSX
INR C ;INCRXEMENT CHARACTER COUNT
PUSH PSW ;SAVE IT ON THE STACK
;
TTYOUT:
LDA UART2+1
ANI 1
JZ TTYOUT
POP PSW ;GET CHARACTER
;
;
;
ORI 0E0H ;MAKE UPPER 3 BITS MARKING
STA UART2 ;SEND TO BAUDOT PORT
DCR C ;MORE TO SEND?
JP TTYOUT ;YES, CONTINUE SENDING
;
TTY0: POP H ;RESTORE REGISTERS
POP B
POP PSW
RET ;RETURN TO CALLING PROGRAM
;
BTABLE: DB 5FH,17H,13H ;NUL SOH STX
DB 1,0,0AH ;ETX EOT ENQ
DB 0,85H,10H ;ACK BEL BS
DB 15H,42H,0C2H ;HT LF VT
DB 2,48H,0 ;FF CRX SO
DB 7,0,0 ;SI DLE DC1
DB 0,0,0 ;DC2 DC3 DC4
DB 0,6,0 ;NAK SYN ETB
DB 18H,0,16H ;CAN EM SUB
DB 0EH,0,0 ;ESC FS GS
DB 0,0,44H ;RS US SPACE
DB 8DH,91H,94H ;! " #
DB 89H,0BH,9AH ;$ PCT &
DB 8BH,8FH,92H ;' ( )
DB 14H,1AH,8CH ;AS PL ,
DB 83H,9CH,9DH ;- . /
DB 96H,97H,93H ;0 1 2
DB 81H,8AH,90H ;3 4 5
DB 95H,87H,86H ;6 7 8
DB 98H,8EH,9EH ;9 : ;
DB 0FH,0DH,12H ;LT EQ GT
DB 99H,5,43H ;? AT A
DB 59H,4EH,49H ;B C D
DB 41H,4DH,5AH ;E F G
DB 54H,46H,4BH ;H I J
DB 4FH,52H,5CH ;K L M
DB 4CH,58H,56H ;N O P
DB 57H,4AH,45H ;Q R S
DB 50H,47H,5EH ;T U V
DB 53H,5DH,55H ;W X Y
DB 51H,11H,1DH ;Z LB LS
DB 1CH,19H,3 ;RB UA LA
;
; THESE ARE THE LOWER CASE ALPHA CHARACTERS
;
DB 0,0C3H,0D9H ;' A B
DB 0CEH,0C9H,0C1H ;C D E
DB 0CDH,0DAH,0D4H ;F G H
DB 0C6H,0CBH,0CFH ;I J K
DB 0D2H,0DCH,0CCH ;L M N
DB 0D8H,0D6H,0D7H ;O P Q
DB 0CAH,0C5H,0D0H ;R S T
DB 0C7H,0DEH,0D3H ;U V W
DB 0DDH,0D5H,0D1H ;X Y Z
;
; TEMPORARY STORAGE AREA
;
RAM EQU 1400H
ORG RAM
SCASE: DB 40H ;PRESENT CASE REGISTER
;
; TEMPORARY STORAGE AREA
;
CASAVE: DW LTABLE ;PRESENT CASE REMINDER
FLAG: DB 0 ;FIGS/LTRS LAST FLAG
;