"Loading MKLDR" $PRINT CRLF ; ; fromaddress toaddress MKLDR ; Outputs an ipl file (to MS) that loads an area of memory ; when executed. Each word encoded as 3 asci characters ; plus decoding overhead. When reloading defines a small ; decoder then decodes 20 words at a time in immediate mode, ; then removes the decoder, very little free dict space is needed. ; OCTAL DEFINE MKLDR ;errorcheck parms.. OVER EOD SWAP SUB IF<0 ;if start >= eod OVER OVER SUB IF<0 ;if end >= start "Encoding..." $PRINT CRLF ;output temp decode definition... ;what this does is use top of stack as mem pointer, parses through ;the string and decodes 3 characters at a time into each location, ;leaving updated pointer on stack. 1st char is bottom 6 bits, next ;bits 6-11 and next bits 12-15. Offset is 60 for chars < to {. ;called by.. (num on stack) "ABCDEFGHIJKL" D to decode 4 words, ;stack incremented by 4 - string can be any length divisable by 3. "DEFINE D" MS$OUT MSCRLF "$LEN 3 DIV DUP S>Z DEC #0 SWAP +DO $HEAD 74 SUB $HEAD" MS$OUT MSCRLF "74 SUB 100 MUL ADD $HEAD 74 SUB 10000 MUL ADD OVER" MS$OUT MSCRLF "INDEX ADD SWAP PUT +LOOP $DROP Z>S ADD END" MS$OUT MSCRLF ;swap output for endadr, dup & output start address... SWAP DUP $STR MS$OUT MSCRLF ;encode memory to strings and D calls... ;pointer on stack, endadr over that DO 42 MSBOUT ;output quote character OVER OVER SUB INC ;calculate remaining size DUP CASE > 24 DROP 24 ENDCASE ;max 20 words if not at end #1 SWAP +DO ;loop the indicated number of words ;now pointer back at top of stack ;output word as three characters... DUP GET DUP 77 AND 74 ADD MSBOUT ASR ASR ASR ASR ASR ASR DUP 77 AND 74 ADD MSBOUT ASR ASR ASR ASR ASR ASR 17 AND 74 ADD MSBOUT INC ;inc mem pointer +LOOP ;until string is 60 chars long (or remaining) 42 MSBOUT " D" MS$OUT MSCRLF ;output quote, D call and eol ;pointer on stack, endadr over that.. exit if pointer > endadr OVER OVER SUB IF<0 #1 ELSE #0 ENDIF UNTIL ;done ;output code to clean up and delete decoder... "DROP " MS$OUT 42 MSBOUT "D" MS$OUT 42 MSBOUT " $DEFADR 4 SUB #0 PUT" MS$OUT MSCRLF "CONSOLE" MS$OUT MSCRLF ;finish the ipl load module #0 ;push 0 to indicate no error ELSE #1 ;error if startadr > endadr ENDIF ELSE #1 ;error if startadr < eod ENDIF IFNZ "Error" $PRINT ENDIF DROP DROP ;drop pointer and endadr END ;--------------------------------------------------- CONSOLE