"Loading MKCLDR" $PRINT CRLF ; MKCLDR - make create loader ; Unlike encoded output of MKLDR, the output of MKCLDR remains in the ; dictionary for further use. Designed to decode transient things like ; bootloaders and other code that needs to be copied to hi-memory. ; Because the words are recorded in octal format it is possible to ; label patch points or otherwise edit the values before copying. ; Usage: "NAME" startadr endadr MKCLDR (with binary in memory) ; Outputs CREATE NAME with copy program and desired code to MS output. ; Edit output as needed. OCTAL DEFINE MKCLDR XP>S XB>S SUB IFZ "Usage: " $PRINT 42 PCHR "NAME" $PRINT 42 PCHR " startadr endadr MKCLDR" $PRINT CRLF "Outputs CREATE definition to MS that recreates binary" $PRINT ELSE OVER OVER SUB IF<0 ;then parms correct, process.... RADIX S>Z OCTAL ;save current radix on Z, switch to octal $DUP "CREATE " MS$OUT MS$OUT MSCRLF ;output CREATE NAME "ZZZ" $CAT ;ensure at least 4 characters in name string #0 3 $SLICE $SWAP $DROP ; leave 4 character string on X to use for labels "Encoding binary to CREATE..." $PRINT CRLF " LDA " MS$OUT $DUP "C" $CAT MS$OUT MSCRLF ; LDA xxxxC " STA TMP1" MS$OUT MSCRLF ; STA TMP1 " LDA " MS$OUT $DUP "D" $CAT MS$OUT MSCRLF ; LDA xxxxD " STA TMP2" MS$OUT MSCRLF ; STA TMP2 $DUP "L" $CAT " LDA TMP1,I" $CAT MS$OUT MSCRLF ;xxxxL LDA TMP1,I " STA TMP2,I" MS$OUT MSCRLF ; STA TMP2,I " ISZ TMP2" MS$OUT MSCRLF ; ISZ TMP2 " LDA TMP1" MS$OUT MSCRLF ; LDA TMP1 " CPA " MS$OUT $DUP "E" $CAT MS$OUT MSCRLF ; CPA xxxxE " JMP END" MS$OUT MSCRLF ; JMP END " ISZ TMP1" MS$OUT MSCRLF ; ISZ TMP1 " JMP " MS$OUT $DUP "L" $CAT MS$OUT MSCRLF ; JMP xxxxL $DUP "D" $CAT " OCT " $CAT OVER $STR $CAT MS$OUT MSCRLF ;xxxxD OCT startadr $DUP "C" $CAT " DEF *+1" $CAT MS$OUT MSCRLF ;xxxxC DEF *+1 "* from " OVER $STR $CAT " to " $CAT DUP $STR $CAT MS$OUT MSCRLF ;* comment ;encode binary as OCT statements... +DO INDEX GET " OCT " $STR $CAT MS$OUT MSCRLF +LOOP "E" $CAT " DEF *-1" $CAT MS$OUT MSCRLF ;xxxxE DEF *-1 "END" MS$OUT MSCRLF ;END ";---" MS$OUT MSCRLF ;;--- "CONSOLE" MS$OUT MSCRLF ;CONSOLE Z>S 12 SUB IFZ DECIMAL ENDIF ;restore radix if was in decimal ELSE $DROP DROP DROP "endadr must be > startadr" $PRINT ENDIF ENDIF END ;------------- "Done." $PRINT CONSOLE