10 rem SUBLOA.BAS executable with patched BASIC 10 rem 10 rem C1%(9)= special call routine with save/restore R1,R5 10 rem C%( minimum routinelength ) store assembler routine 10 rem C% = length of common + 7 { 7= pos -1 of the calling start C1%(7)} 10 rem ****************************************** 10 rem * call sys(6) start topmem-3 = C1%(7) * 10 rem * routine start must be loaded in C1%(3) * 10 rem ****************************************** 10 rem 10 COMMON C1%(9),C%(2000) \ C%=2001+7 100 rem 100 rem ------- read .rel file ----------------------------------- 100 rem 100 PRINT 'enter routine File_name';\ INPUT A$ 110 OPEN A$ FOR INPUT AS FILE #1 \ DIM #1,A%(20479) 120 rem 120 rem test the radix REL word of the input file 120 IF A%(24)<>29012 THEN PRINT "NOT '.REL' FORMAT" \ STOP 150 rem 150 rem load .rel file 150 rem routine length in bytes = A%(20) - A%(17) 150 rem Highest_memory_add. - Initial_Stack_offset 150 rem note : preserve the old values of the data_part of your DIM with 150 rem a for_next starting at your data_length (150 FOR I%=256% ...) 150 rem 150 FOR I%=0 TO (A%(20)-A%(17)+1%)/2% \ C%(I%)=A%(256%+I%) \ NEXT I% 200 rem 200 rem ------- reclocation of the direct addressed variables ----- 200 rem 200 rem first SYS6 with C1%(7)=rts pc -> C1%(7)=memoryaddress 200 rem I%=reloc_table_start (note end of table = -2) 200 rem I1%=reloc_offset = C%()start_stackoffset 200 rem 200 I%=A%(25)*256% 210 C1%(7)=135 \ I1%=SYS(6)-(C%*2%)-A%(17) 220 IF A%(I%)<>-2% THEN C%(A%(I%))=A%(I%+1%)+I1% \ I%=I%+2% \ GO TO 220 250 rem 250 rem ------- *** read call_routine program (data)*** ----------- 250 rem this special call save/restore R1 and R5 data 250 rem 0 mov R1,-(SP) !push R1 250 rem 1 mov R5,-(SP) !push R5 250 rem 2 jsr PC, !call routine 250 rem 3 ** routine_start ** 250 rem 4 mov (SP)+,R5 !pop R5 250 rem 5 mov (SP)+,R1 !pop R1 250 rem 6 rts 250 rem sys(6) entry> 7 br Set_save_restore_start -> C1%(0) 250 rem 8 eventual sys4 entry (branch to other routine) 250 rem 9 =0 250 DATA 4198 ,4454 ,2527 ,0 ,5509 ,5505 ,135 ,504 ,135 ,0 260 FOR I%=0 TO 9% \ READ C1%(I%) \ NEXT I% 270 rem 270 rem ---- Let the absolute routine_start_address in C1%(3) ----- 270 rem = reloc_offset + subroutine_start_address A%(16) 270 rem 270 C1%(3)=I1%+A%(16) 300 rem 300 rem ----- Optional : If any .EXIT found ,change to RETURN PC -- 300 rem 300 FOR I=0 TO (A%(20)-A%(17)+1%)/2% 310 IF C%(I)=-30488 THEN C%(I)=135 \ PRINT 'found .EXIT at';I 320 NEXT I 400 rem 400 STOP