.title ccx ; This program is designed to load ; the DECUS C compiler cc.sav. The ; program is allocated 32K words of virtual ; memory. A search for the compiler program ; cc.sav is made on DK:, SY:, and then C:. .mcall .settop, .print, .addr, .rctrlo, .serr .mcall .lookup, .readw, .close, .exit .asect . = 42 .word 001000 ; stack pointer .word 002000 ; virtual job ; loader is copied to this area . = 500 ; beginning of block #1 . = 1000 buff: .blkw 256. start: .serr ; soft errors mov #load,r0 ; relocate loader mov #500,r1 ; to very low memory mov #ldlen,r2 ; i.e. - below the stack 1$: mov (r0)+,(r1)+ dec r2 bne 1$ .settop #-2 ; try to allocate a total of 32K words mov #^rDK,inspc ; try DK: ; .lookup #larea,#17,#inspc mov #larea,r0 ; lookup file emt 375 bcc 2$ mov #^rSY,inspc ; try SY: ; .lookup #larea,#17,#inspc mov #larea,r0 ; lookup file emt 375 bcc 2$ mov #^rC,inspc ; try C: ; .lookup #larea,#17,#inspc mov #larea,r0 ; lookup file emt 375 bcs 3$ ; .readw #rarea,#17,#buff,#256.,#0 2$: mov #rarea,r0 ; read first block of image emt 375 bcs 3$ mov @#buff+50,r2 ; reallocate memory add #77,r2 ; for this load image bic #77,r2 sub #2,r2 .settop r2 cmp r0,r2 bne 3$ mov #buff+40,r0 ; copy in relevent parameters mov #40,r1 mov (r0)+,(r1)+ ;40 start address mov (r0)+,(r1)+ ;42 Stack pointer bis (r0)+,(r1)+ ;44 JSW mov (r0)+,(r1)+ ;46 USR load address add #14,r0 ;50 - add #14,r1 ;62 skip mov (r0)+,(r1)+ ;64 /O information mov (r0)+,(r1)+ ;66 /V information cmp @#42,#1000 ; check stack location blo 3$ jmp load - load + 500 3$: jmp exit - load + 500 larea: .byte 17,1 ; .lookup .word inspc .word 0 inspc: .rad50 "DK CC SAV" . = 4000 ; This section loads the complete ; program beginning with block #1 ; ; This section is relocated to address 500 load: .addr #rarea,r0 ; readw control block mov @#buff+50,r1 ; use the high limit to clc ; find the number of words ror r1 ; that need to be read br 3$ 1$: cmp r1,6(r0) ; read one block (256. words) bhis 2$ ; at a time until words left mov r1,6(r0) ; is smaller than 256. ; .readw #rarea,chan=#17,buf=4(r0),wcnt=6(r0),blk=2(r0) 2$: emt 375 ; read a block bcs exit ; abort on any error .addr #rarea,r0 ; .readw control block add #1000,4(r0) ; update buffer address 3$: add #1,2(r0) ; update block number sub #256.,r1 ; update words remaining bhi 1$ ; for an overlayed program leave ; the overlay channel open bit #1000,@#44 ; overlayed ? bne 4$ ; yes - skip .close #17 ; no - close channel 4$: .rctrlo ; note changes in JSW ; start loaded program mov @#42,sp ; load stack pointer mov @#40,pc ; start program ; on any error come here exit: .close #17 ; close channel .settop #0 .addr #ccxerr,r0 .print ; note failure .exit rarea: .byte 17,10 ; .readw .word 0 ; blk .word buff ; buf .word 256. ; wcnt .word 0 ; .____w ccxerr: .asciz "?CCX-F-Failed To Start Program" .even ldlen = <.-load>/2 . = 17776 .word start .end start