|
.TITLE K1.MAC
;
;-- READ A LINE FROM TERMINAL AND OUTPUT TO PUNCHED TAPE
; IN A LEGIBLE FORM
;
;-----------------------------------------------------------------------
;
; KEVIN MURRELL with sections from a DECUS listing.
; FOR RETROBEEP.COM
; AT BLETCHLEY PARK COMPUTER MUSEUM
;
;------------------------------------------------------------------------
.MCALL .GTLIN,.PRINT,.EXIT,.SRESET
.MCALL .FETCH,.ENTER,.CLOSE,.WRITW
;
START: .PRINT #TITLE
;
RSTART: ;-- GET DEVICES
.SRESET ; RESET DRIVERS
.FETCH #HSPACE,#PCNAME ; FETCH PUNCH HANDLER
BCS FERR
.ENTER #EMT,#0,#PCNAME,#0 ; CREATE O/P FILE
BCS ENERR
.GTLIN #BUF,#PROMPT ; GET SOURCE LINE
MOVB BUF,R0 ; IF BLANK,
BEQ EXIT ; THEN EXIT
CLR R2
MOV #BUF,R0 ; COUNT CHARS IN LINE
5$: MOVB (R0)+,R1 ; GET CHAR
BEQ 10$ ; QUIT IF IT IS NULL
INC R2
BR 5$ ; ROUND AGAIN
10$: MOV R2,LC ; SAVE LINE CHAR COUNT
ADD R2,LC ; MULTIPLIED BY THREE
ADD R2,LC ; TO END UP WITH SIX CHARS
; PER SOURCE CHAR IN O/P BUFFER
;JSR PC,LEADER ; PUNCH READER
MOV #BUF,%4 ; COPY BUFFER POINTER
JSR PC,DISPLA ; CONVERT TO LEGIBLE
JSR PC,PUNCH ; AND PUNCH
;JSR PC,LEADER ; PUNCH TRAILER
.CLOSE #0 ; CLOSE PUNCH
BR RSTART ; AND ROUND AGAIN
EXIT: .EXIT
; CONVERT STRING ADDRESSED BY %4 TO A LEGIBLE TAPE HEADER IN BUFFER.
; SET UP COUNT FOR PUNCHING.
DISPLA: MOV #BUFFER,%3 ; %3->DESTINATION
DSPLP: MOVB (%4)+,%0 ; GET CHAR
BEQ DSPEX ; NULL IS TERMINATOR
JSR PC,DSPCHR ; CONVERT CHAR
BR DSPLP ; LOOP FOR MORE
DSPEX: MOV %3,COUNT ; AT END, COMPUTE COUNT
SUB #BUFFER,COUNT ; OF BYTES
RTS PC ; CONVERT DONE
; CONVERT CHARACTER TO A LEGIBLE CHARACTER OF 5 BYTES
; + A NULL SPACER
DSPCHR: CMPB %0,#' ; ; <' '?
BGE 10$ ; MUST TEST FOR CONTROLS
MOVB #' ,%0 ; CHANGING TO SPACES
BR 20$
10$: CMPB %0,#'_ ; '_' IS HIGHEST CATERED FOR
BLE 20$ ; BRANCH IF IN RANGE
BICB #40,%0 ; ELSE CHANGE LC->UC
20$: BIC #177600,%0 ; STRIP PARITY & UPPER BYTE
MOV %0,-(SP) ; MPY BY 5
ASL %0
ASL %0
ADD (SP)+,%0 ; BY SHIFT & ADD
ADD #CHRTAB-160.,%0 ; AS POINTER TO TABLE
.REPT 5 ; COPY 5 BYTES FROM TABLE
MOVB (%0)+,(%3)+ ; TO OUTPUT BUFFER
.ENDR
CLRB (%3)+ ; FINISH WITH NULL SPACER
RTS PC ; AND EXIT
LEADER: MOV #20.,%0 ; 20 NULLS FOR CLEAR TAPE
CLR %1
MOV %0, COUNT
MOV #BUFFER,%3
LDR1: MOVB %1,(%3)+
SOB %0, LDR1
.WRITW #EMT,#0,#BUFFER,#COUNT,#0
RTS PC
;-- PUNCH BUFFER
PUNCH: .WRITW #EMT,#0,#BUFFER,LC,#0
BCS WTERR
RTS PC
;
;-- ERROR MESSAGES
FERR: .PRINT #FMSG
.EXIT
WTERR: .PRINT #WTMSG
.EXIT
ENERR: .PRINT #ENMSG
.EXIT
;-- LITERALS
ENMSG: .ASCIZ /ENTER ERROR/
FMSG: .ASCIZ /FETCH ERROR/
WTMSG: .ASCIZ /PUNCH ERROR/
PCNAME: .RAD50 /PC /
.WORD 0
TITLE: .ASCII /BLETCHLEY PARK COMPUTER MUSEUM - TAPE DEMO V1.1 (KRM)/<0>
PROMPT: .ASCII /Enter text --> /<0>
;
; TABLE TO FORM 5X8 CHARACTERS:
.NLIST BEX
CHRTAB: .BYTE 0,0,0,0,0 ; SPACE
.BYTE 0,337,337,0,0 ; !
.BYTE 0,7,0,7,0 ; "
.BYTE 44,377,44,377,44 ; #
.BYTE 206,211,377,211,161 ; $
.BYTE 203,143,30,304,303 ; %
.BYTE 140,226,231,216,340 ; &
.BYTE 0,0,7,0,0 ; '
.BYTE 0,74,102,201,0 ; (
.BYTE 0,201,102,74,0 ; )
.BYTE 211,112,377,112,211 ; *
.BYTE 10,10,176,10,10 ; +
.BYTE 260,160,0,0,0 ; ,
.BYTE 0,10,10,10,0 ; -
.BYTE 140,140,0,0,0 ; .
.BYTE 200,140,30,4,3 ; \
.BYTE 176,241,211,205,176 ; 0
.BYTE 0,202,377,200,0 ; 1
.BYTE 302,241,221,211,206 ; 2
.BYTE 102,211,211,211,166 ; 3
.BYTE 37,20,374,20,20 ; 4
.BYTE 117,211,211,211,161 ; 5
.BYTE 176,211,211,211,160 ; 6
.BYTE 301,41,21,11,7 ; 7
.BYTE 166,211,211,211,166 ; 8
.BYTE 106,211,211,211,176 ; 9
.BYTE 146,146,0,0,0 ; :
.BYTE 266,166,0,0,0 ; ;
.BYTE 10,20,14,102,101 ; <
.BYTE 0,44,44,44,0 ; =
.BYTE 201,102,44,200,10 ; >
.BYTE 2,271,11,11,6 ; ?
.BYTE 176,201,235,223,116 ; @
.BYTE 374,22,21,22,374 ; A
.BYTE 377,211,211,211,166 ; B
.BYTE 176,201,201,201,102 ; C
.BYTE 377,201,201,201,176 ; D
.BYTE 377,211,211,211,201 ; E
.BYTE 377,11,11,11,1 ; F
.BYTE 176,201,261,221,162 ; G
.BYTE 377,10,10,10,377 ; H
.BYTE 0,201,377,201,0 ; I
.BYTE 100,200,201,177,1 ; J
.BYTE 377,10,34,42,301 ; K
.BYTE 377,200,200,200,200 ; L
.BYTE 377,2,4,2,377 ; M
.BYTE 377,4,10,40,377 ; N
.BYTE 176,201,201,201,176 ; O
.BYTE 377,11,11,11,6 ; P
.BYTE 176,201,241,101,276 ; Q
.BYTE 377,11,31,51,306 ; R
.BYTE 206,211,211,211,161 ; S
.BYTE 1,1,377,1,1 ; T
.BYTE 177,200,200,200,177 ; U
.BYTE 37,140,200,140,37 ; V
.BYTE 377,100,40,100,377 ; W
.BYTE 343,34,10,34,343 ; X
.BYTE 3,4,370,4,3 ; Y
.BYTE 301,241,221,211,207 ; Z
.BYTE 0,377,201,201,0 ; [
.BYTE 3,4,30,140,200 ; /
.BYTE 0,201,201,377,0 ; ]
.BYTE 4,2,377,2,4 ; ^
.BYTE 40,160,250,40,40 ; <-
;-- MISC STORAGE
.EVEN
COUNT: 0
LC: 0
EMT: .BLKW 10
BUF: .BLKB 134
BUFFER: .BLKB 1024
;-- DEVICE HANDLER SPACE
HSPACE=.
.END START
|