home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
pub
/
rt11pascal
/
rtload.mac
< prev
next >
Wrap
Text File
|
2020-01-01
|
3KB
|
144 lines
.TITLE LOAD
;
; LOAD 'SAV' FILE FROM 'HEX'
;
; ENTER FILES BELOW:
;
; *<sav-file>=<hex-file>
;
ERRWD=52 ;ERROR WORD
INCH=3 ;INPUT CHANNEL NO.
OUTCH=0 ;OUTPUT CHANNEL NO.
CR=15 ;CARRAGE RETURN
LF=12 ;LINE FEED
;*****************************************************
.MCALL .PRINT,.EXIT,.INTEN,.SYNCH
.MCALL .CSIGEN,.READ,.WRITE
.MCALL .WAIT,.WRITW,.CLOSE,.READW
;********************************************************
LOAD: .PRINT #MSG0
MOV SP,R1 ;SAVE STACK
.CSIGEN #FREE,#DEFEXT,#0 ;OPEN FILE
MOV R1,SP ;RESTORE STACK
.WAIT #INCH ;CHECK CORRECT CHAN
BCC 12$
JMP FLERR ;OPEN ERROR
12$: .WAIT #OUTCH ;CORRECT CHANNEL ?
BCC 11$ ;ERROR ?
JMP FLERR ;YES, OPEN ERROR
11$: CLR R2 ;BLOCK NO
JSR PC,OPEN
1$: .READW #AREA,#INCH,#BUFA,#256.,R2 ;READ A BLOCK
BCS 4$ ;READ ERROR OR EOF ?
MOV #512.,R4 ;NO, CHAR COUNT
MOV #BUFA,R5 ;POINT TO BUFFER
2$: MOVB (R5)+,R0 ;GET CHAR
CMPB R0,#'0 ;VS '0
BLT 3$
JSR PC,CVT ;CONVERT
3$: DEC R4 ;DEC CHAR COUNT
BNE 2$ ;BLOCK DONE ?
INC R2 ;YES, NEXT BLOCK
BR 1$ ;AGAIN
4$: TSTB @#ERRWD ;EOF ?
BEQ 9$ ;YES, DONE
JSR PC,RDERR ;READ ERROR
9$: .CLOSE #INCH ;CLOSE FILE
JSR PC,CLOSE ;CLOSE OTHER FILE
.EXIT
;*****************************************************
;OPEN OUTPUT FILE
OPEN: MOV #BUFB,OPNT ;BUFFER POINTER
CLR OBLK ;BLOCK COUNT
MOV #512.,OCHR ;CHARACTER COUNT
RTS PC
;*****************************************************
CLOSE: CMP OCHR,#512. ;ANY WORDS
BEQ 2$
MOVB #0,@OPNT ;PAD BUFFER WITH NULLS
INC OPNT
DEC OCHR
BNE CLOSE
MOV OBLK,R3
.WRITW #AREA,#OUTCH,#BUFB,#256.,R3
BCC 2$ ;ERROR ?
JMP WRTERR ;WRITE ERROR
2$: .CLOSE #OUTCH ;CLOSE FILE
9$: RTS PC
;*****************************************************
CVT: TST FLAG ;2ND NIBBLE ?
BNE 10$
JSR PC,CVT1 ;CONVERT
ASL R0 ;SHIFT UP
ASL R0
ASL R0
ASL R0
MOV R0,R1 ;SAVE IN R1
INC FLAG ;SET ON
RTS PC ;RETURN
;
10$: JSR PC,CVT1
BISB R1,R0 ;OR TOGETHER
CLR FLAG
TST FLAGS
BNE 20$
MOV R0,SVWORD
INC FLAGS
RTS PC
;
20$: SWAB SVWORD
BISB R0,SVWORD
MOV SVWORD,@OPNT ;MOVE WORD TO IN BUFFER
CLR FLAGS
INC OPNT ;ADVANCE POINTER
INC OPNT
DEC OCHR ;BLOCK FULL?
DEC OCHR
BNE 3$ ;NO, SKIP
MOV OBLK,R3
.WRITW #AREA,#OUTCH,#BUFB,#256.,R3
BCC 2$
JMP WRTERR ;WRITE ERROR
2$: INC OBLK ;RESET POINTERS
MOV #512.,OCHR
MOV #BUFB,OPNT
3$: RTS PC
;*****************************************************
CVT1: BITB #100,R0
BNE 10$
BIC #177760,R0 ;KEEP BOTTOM 4 BITS
RTS PC
10$: BIC #177770,R0 ;KEEP BOTTOM 3 BITS
ADD #9.,R0 ;ADD 9
RTS PC
;*****************************************************
;FATAL ERRORS - ABNORMAL TERMINATION
FLERR: .PRINT #MSG2 ;OPEN FILE ERROR
.EXIT
WRTERR: .PRINT #MSG5 ;WRITE ERROR
.EXIT
RDERR: .PRINT #MSG3 ;READ ERROR
.EXIT
;*****************************************************
DEFEXT: .RAD50 "HEX" ;DEFAULTS
.RAD50 "SAV"
.WORD 0
.WORD 0
.EVEN
FLAG: .WORD 0 ;ON IF 2ND NIBBLE
FLAGS: .WORD 0 ;ON IF 2ND BYTE
SVWORD: .WORD 0
OPNT: .WORD 0 ;OUTPUT BUFFER POINTER
OBLK: .WORD 0 ;OUTPUT BLOCK COUNT
OCHR: .WORD 0 ;OUTPUT CHAR COUNT
AREA: .BLKW 10
MSG0: .ASCIZ <CR><LF>"# ENTER FILES BELOW:"
MSG2: .ASCIZ <CR><LF>"# FILE OPEN ERROR"
MSG3: .ASCIZ <CR><LF>"# FILE READ ERROR"
MSG5: .ASCIZ <CR><LF>"# FILE WRITE ERROR"
.EVEN
BUFA: .BLKW 256. ;INPUT BUFFER
BUFB: .BLKW 256. ;OUTPUT BUFFER
FREE: .+2 ;START OF FREE CORE
.END LOAD