; alt mem utility words... 8/26/07 10/5/07 12/13/07 6/13/11 ; requires PRESET (v1.11 create.ipl) and dms.ipl ; ; ZAM - Zero Alternate Memory ; HLT - halts the computer for attaching, swapping, etc ; ALTRUN - Swaps and executes altmem from loc 2 ; RUNABS - Load and run an ABS attached to MS input (PTR) ; PTHEADER - Writes 8 zeros to MS output (PTP) (used by ALTABS) ; from to AAOUT - Writes alt mem to MS out in ABS format ; ALTABS - Saves alt mem to ABS file attached to MS out ; ALTDUMP - Dumps alt mem to terminal ; CLRHALT - Saves system to alt mem, halts with empty system ; ALTHALT - Swaps system with system in alt mem then halts ; ;----------------------------------------------------------------------- ; ; ZAM - zero alt mem, similar to the TDOS word but this ; version saves and restores MS vectors for usage from the prompt ; 10/5/07 added load code to delete if exists ; If using w/TDOS (unlikely..) rename its ZAM first ; "ZAM" $DEFADR ;push non-zero if exists ; OCTAL DEFINE ZAM MS_SAVE ;added because ZEROBLOCK redirects MS #0 ZEROBLOCK #0 37 +DO @BLK GET INDEX 2000 MUL DUP IFZ DROP 2 ENDIF 2000 C>ACOPY +LOOP MS_RESTORE ;added END ; DEFINE TEMP ;if dup detected prompt to delete IFZ ;if no dup "TEMP" $DEFADR 4 SUB #0 PUT ;delete self ELSE ;dup detected "Forgetting dup ZAM" $PRINT CRLF "ZAM" $DEFADR 4 SUB #0 PUT ;delete new dup ZAM ENDIF END TEMP ;do it, will delete self ; ;----------------------------------------------------------------------- ; ; HLT - halts with code 7 ; 10/5/07 - added load code to delete if exists ; "HLT" $DEFADR ;push non-zero if exists ; OCTAL CREATE HLT HLT 7 END ; DEFINE TEMP ;if dup detected prompt to delete IFZ ;if no dup "TEMP" $DEFADR 4 SUB #0 PUT ;delete self ELSE ;dup detected "Forgetting dup HLT" $PRINT CRLF "HLT" $DEFADR 4 SUB #0 PUT ;delete new dup HLT ENDIF END TEMP ;do it, will delete self ;----------------------------------------------------------------------- ; ; ALTRUN - execute program in alt memory 10/4/07 ; This code was in RUNABS but handy as a separate word ; ; If location 2 is defined, just runs it from 2. ; If papertape basic detected (loc 100/105=124201/002200), ; then adds a jump to 100 at 2/3 and a jump to 77000 at 76/77 ; to permit returning to HP-IPL/OS upon entering "BYE". ; Otherwise if not papertape basic and loc 2 undefined, prompts for RA. ; Uses locations 150/151 octal for temp use. ; OCTAL DEFINE ALTRUN 77000 GET 105734 SUB IFNZ "ALTSAVE not run " $PRINT ELSE PRESET ;disable TBG and interrupts 2 150 #1 A>CCOPY ;copy alt loc 2 to loc 150 150 GET IFZ ;if loc 2 not defined then... 100 150 6 A>CCOPY ;get locs 100-105 2 ;#matches needed 150 GET 124201 SUB IFZ DEC ENDIF 155 GET 002200 SUB IFZ DEC ENDIF IFZ ;if (unpatched) HP BASIC detected... "Patching HP BASIC RA/BYE" $PRINT CRLF 150 124003 PUT 151 100 PUT 150 2 2 C>ACOPY ;patch run address 150 77000 PUT 151 124076 PUT 150 76 2 C>ACOPY ;patch BYE exit to hpiplos 77000 RUN ;save HP-IPL/OS and execute basic ELSE ;prompt for run address... "Enter Run Address (0 to halt): " $PRINT $IN 40 $APPEND $VAL CRLF DUP IFNZ ;if not zero then... 150 124003 PUT 151 SWAP PUT 150 2 2 C>ACOPY ;set run address to whatever entered 77000 RUN ;execute it ELSE ;DROP ;save a word don't worry about dropping 0 150 102003 PUT ;a halt with code 3 150 2 #1 C>ACOPY ;copy to alt loc 2 77000 RUN ;execute halt ENDIF ENDIF ELSE ;loc 2 is already defined 77000 RUN ;just do it ENDIF ENDIF END ;----------------------------------------------------------------------- ; ; RUNABS - saves current system along with program at 77000 that ; swaps it back, loads and runs ABS file attached to PTR. ; Uses RUNALT to execute, see above. ; Uses loc 150 for temp use. ; Started 7/6/07 last mod 9/29/07 OCTAL DEFINE RUNABS ALTSAVE ;saves system (redundant), puts swap code at 77000 ZAM ;wipe out saved hpiplos copy, makes debugging easier.. "Halt for cable swap? " $PRINT CHRIN CRLF 131 SUB IFZ #1 ELSE #0 ENDIF 150 SWAP PUT ;set halt flag 150 GET IFNZ HLT ENDIF ABSLOAD ;loads ABS file into alt 150 GET IFNZ HLT ENDIF CRLF CRLF ;space past load indicator dots ALTRUN ;execute it END ;----------------------------------------------------------------------- ; ; ALTABS - copies alt mem to ABS file attached to PTP ; Presents a menu with save options, attach to PTP first. ; Uses locations 150-155. 9/29/07 ; from to AAOUT - modified version of ABSOUT that takes ; input from alt mem instead. Uses locations 152/153. 7/6/07 ; from to ALTDUMP - lists alt mem to terminal. 7/10/07 ; PTHEADER - writes 8 zero's to MS out (def.PTP). 7/11/07 ; OCTAL DEFINE PTHEADER #0 7 +DO #0 MSBOUT +LOOP END ; OCTAL DEFINE AAOUT #0 S>Z ;record counter on Z DUP S>Y ;copy end address to Y to check for last block #0 S>X ;checksum on X MS_SAVE ;added - save current MS pointers 152 351 GET PUT ;added - save current MS out pointer OVER MSUSER ;added - set MS to alt, starting from from 351 152 GET PUT ;added - put MS out back to ptr or whatever +DO ;for index = start address to end address Z>S DUP S>Z ;copy record counter to stack IFZ ;if zero then start of new block... Y>S DUP S>Y ;get end address INDEX ;get current address X>S DROP ;discard prev checksum DUP S>X ;copy address to checksum SUB INC ;sub/inc to get # words left DUP ;save to use in a bit 33 SUB ;subtract 33 oct to see if incomplete IF<0 ;if incomplete block leave #left on stack ELSE ;else DROP ; don't need #words left 33 ; instead do 33 octal words ENDIF Z>S DROP DUP S>Z ;copy record count to Z MSBOUT ;output record count to mass storage #0 MSBOUT ;write 0 pad byte INDEX MSWOUT ;write two byte starting address ENDIF MSWIN ;get word from MS in (from alt) DUP MSWOUT ;write to mass storage X>S ADD DUP S>X ;add data to checksum and duplicate Z>S DEC DUP S>Z ;decrement record counter IFZ ;if last word... MSWOUT ; write checksum ELSE DROP ;else discard it ENDIF +LOOP X>S DROP ;discard checksum Y>S DROP ;discard last address Z>S DROP ;discard record counter MS_RESTORE ;added - restore MS pointers END ; OCTAL DEFINE ALTABS CRLF "1) Save 31K ABS dump" $PRINT CRLF "2) Save HP BASIC to re-enter/run" $PRINT CRLF "3) Manually save range(s)" $PRINT CRLF "Attach PTP to file and enter selection: " $PRINT $IN 40 $APPEND $VAL CASE = 1 ;straight save "Saving alt mem from 2 to 75777..." $PRINT PTHEADER 2 75777 AAOUT PTZERO CRLF "Done" $PRINT CRLF = 2 ;save HPBASIC 100 150 6 A>CCOPY ;get a little to verify 2 ;#matches needed 150 GET 124201 SUB IFZ DEC ENDIF 155 GET 002200 SUB IFZ DEC ENDIF IFNZ "HP BASIC not detected" $PRINT CRLF ELSE 77 150 #1 A>CCOPY ;get loc 77 150 GET IFZ ;if BYE not patched "Patch BYE? " $PRINT $IN 40 $APPEND #0 $GET 131 SUB IFNZ $DROP ELSE "Address? (77000 for swap/exit, 0 to halt) " $PRINT $IN 40 $APPEND $VAL DUP IFZ ;if zero for halt 150 #0 PUT 151 102077 PUT ;halt for loc 77 ELSE 150 SWAP PUT 151 124076 PUT ;jump for 77/76 ENDIF 150 76 2 C>ACOPY ;patch BYE ENDIF ENDIF "Select..." $PRINT CRLF "1) Save just basic and drivers" $PRINT CRLF "2)" $PRINT "Save basic and program to " $DUP $PRINT "re-enter" $PRINT CRLF "3)" $PRINT $PRINT "auto-run" $PRINT CRLF "? " $PRINT $IN 40 $APPEND $VAL DUP CASE = 1 100 = 2 2027 = 3 5137 DEFAULT #0 ENDCASE ;6/13/11 DUP IFZ ;if invalid choice DROP DROP ;address and selection ELSE ;do it, stack=selection, address on top PTHEADER ;write leader 151 SWAP PUT 150 124003 PUT 150 2 2 C>ACOPY ;patch run address 2 ;first location SWAP ;get selection CASE = 1 110 DEFAULT 113 ENDCASE ;if just bas use 110 else 113 150 #1 A>CCOPY 150 GET ;get alt loc 110 or 113 "Saving " $PRINT OVER PNUM "to " $PRINT DUP PNUM AAOUT CRLF 111 150 #1 A>CCOPY 150 GET ;push 1st loc of drivers 154 GET 777 OR ;calculate last location (loc 104) "Saving " $PRINT OVER PNUM "to " $PRINT DUP PNUM AAOUT PTZERO CRLF "Done" $PRINT ENDIF ENDIF = 3 ;specified save "Run address (enter for no change): " $PRINT $IN 40 $APPEND $VAL DUP IFZ DROP ELSE 150 124003 PUT 151 SWAP PUT 150 2 2 C>ACOPY "(range must includes 2/3)" $PRINT CRLF ENDIF PTHEADER ;write leader zeros "Enter ranges, just enter when done..." $PRINT CRLF DO ;while ranges entered "Starting address: " $PRINT $IN 40 $APPEND $VAL DUP IFNZ "Ending address : " $PRINT $IN 40 $APPEND $VAL DUP IFZ DROP DROP #0 ELSE OVER OVER SUB IF<0 "Saving..." $PRINT AAOUT #1 CRLF ELSE "Invalid" $PRINT CRLF DROP DROP #1 ENDIF ENDIF ENDIF WHILE ;non-zero address entered PTZERO "Done" $PRINT ENDCASE END ; OCTAL DEFINE ALTDUMP 151 #1 PUT ;a flag to indicate 1st word +DO INDEX 7 AND IFZ CRLF INDEX PNUM ": " $PRINT 151 #0 PUT ELSE 151 GET IFNZ INDEX PNUM ": " $PRINT 151 #0 PUT ENDIF ENDIF INDEX 150 #1 A>CCOPY 150 GET PNUM +LOOP END ;----------------------------------------------------------------------- ; ; CLRHALT - saves HP-IPL/OS to alt mem, clears main mem and halts, ; useful for operating BCS utilities, asm/compilers etc, ; presents an (almost) empty machine to build in. ; ALTHALT - swaps alt mem and HP-IPL/OS and halts, useful for running ; binaries (loaded via ABSLOAD) from an address besides 2. ; ALTSAVE must have been previously run to place the swapper ; code into memory. ; Run from location 77000 to return to previous system. ; Note.. both of these overwrite location 2, make note of contents if ; necessary to restore (often 124003 to run from address in 3). ; New for ALTHALT - preserves original run link at 2/3 so pressing ; the run button executes. ; 8/25/07 9/30/07 OCTAL DEFINE CLRHALT "Run 77000 to return" $PRINT ALTSAVE ZAM 150 102003 PUT 150 2 #1 C>ACOPY PRESET 77000 RUN END ; OCTAL DEFINE ALTHALT 77000 GET 105734 SUB IFNZ "ALTSAVE not run " $PRINT ELSE 2 150 2 A>CCOPY 150 GET 124003 SUB IFZ ;if run address present 77075 102007 PUT ;a halt in loc 77075 77076 127077 PUT ;a jmp 77077,i in loc 77076 (fixed 12/13/07) 77077 151 GET PUT ;original run address in loc 77077 "Press Run to execute " $PRINT 151 GET PNUM CRLF 151 77075 PUT 151 3 #1 C>ACOPY ;patch run address to halt ELSE ;not a standard run address or zero "Loc.2/3 was " $PRINT 150 GET PNUM 151 GET PNUM CRLF 150 3 #1 C>ACOPY ;move loc 2 to loc 3 150 102003 PUT 150 2 #1 C>ACOPY ;halt in loc 2 ENDIF PRESET 77000 RUN ENDIF END ;----------------------------------------------------------------------- ; CONSOLE