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
/
TTYR.ASM
< prev
next >
Wrap
Assembly Source File
|
1984-04-29
|
5KB
|
182 lines
;
; 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 0BH ;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 0FB00H ;MY ADDRESS FOR THIS PROGRAM
;
; PROGRAM STARTS HERE
;
ORG BEGIN ;PUT DESIRED ADDRESS HERE
;
ASCRCV: PUSH H ;SAVE HL REGISTERS
LHLD CASAVE ;GET PRESENT CASE
;
START: IN 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
;
CASAVE: DW LTABLE ;PRESENT CASE REMINDER
FLAG: DB 0 ;FIGS/LTRS LAST FLAG
;
END
; THIS IS A SAMPLE OF THE POLLING ROUTINE
; USED TO ALLOW INPUT FROM EITHER THE ASCII
; OR BAUDOT KEYBOARD INPUT PORTS. IT CAN
; BE LINKED TO ANY PROGRAM WHICH USES A
; NORMAL INPUT ROUTINE WHICH RETURNS WITH
; THE ASCII CHARACTER IN THE ACCUMULATOR.
;
POLL: IN BSTATUS ;BAUDOT UART STATUS PORT
ANI RDA ;TEST FOR RCVE DATA AVAIL FLAG
JZ POLL2 ;NO CHAR. TEST ASCII (MAY NEED JNZ HERE)
CALL ASCRCV4 ;CHARACTER THERE, GET AND CONVERT
CPI 0FFH ;IGNORE FLAG THERE?
RNZ ;NO, RETURN WITH ASCII CHARACTER
;
POLL2: IN ASTATUS ;GET ASCII UART STATUS
ANI RDA ;TEST DATA AVAIL. FLAG
JZ POLL ;NO CHAR., RESUME POLLING (MAY NEED JNZ HERE)
IN ADATA ;GET ASCII UART DATA
ANI 7FH ;STRIP PARITY BIT
RET ;ASCII CHAR. IN ACCUMULATOR
;
; END OF SAMPLE POLLING ROUTINE.