> SMJoin 0 Build Sideways Modules into a single image : (, ctrl% 31,mem% &4100:X%=ctrl%:Y%=X%256 2& :Close_All: " at line ";: <ptr%=0:in%=0 F* "Enter input files, end with RETURN" P : ": "in$: in$<>"":add Z in$="" d% "Enter output filename: "out$ n6 "Save "+out$+" "+~mem%+"+"+~ptr%+" 0 FFFBBC00" x  "Stamp "+out$  : add  in$,1)="|":  in$,1)="*": in$,2): 2in%=(in$): in%=0:"File '"in$"' not found": Glen%=#in%: len%>&4100-ptr%:"File '"in$"' too long":#in%:in%=0:  ptr%:ptr%=ptr%+2 -gbpb(4,in%,mem%+ptr%,len%,0):#in%:in%=0 Zreloc%=0: mem%?ptr%=0: (mem%?(ptr%+2) &80)=&80:reloc%=ptr%+(mem%!(ptr%+1) &3FFF) L reloc%=0: ptr%:"File '"in$"' not relocatable, must be first entry": ?old%=ptr%:ptr%=link: old%=ptr%:"File '"in$"' too long": ( A%=ptr% &3FFF 4:mem%!A%=0: A%  old%<>0 ptr%<&3FFF: 5:ptr%=ptr%-1: mem%?ptr%<>mem%?&3FFF:ptr%=ptr%+1 " ,: 6 byte @9 count%=0:byte%=mem%?reloc%:reloc%=reloc%+1:count%=8 J` byte%1:addr%=(mem%!(here%-1)&3FFF)+code%:mem%?(here%-1)=addr%:mem%?here%=(addr%256)+&80 Tz IF byte%AND1:PRINT" At ";~here%-code%+&8000;" (";~here%+&8000;") addr=";~addr%-code%+&8000;" reloc to ";~addr%+&8000 ^!byte%=byte%2:count%=count%-1 h r: | ݤlink B ptr%=0: reloc%=0:=len% : First item, no relocation table E ptr%=0: reloc%>0:=reloc% : First item, strip relocation table :  Relocate loaded module 9code% =ptr% : Start of loaded code 7end% =reloc% : End of loaded code 5count%=0 : No bits read yet 6byte% =0 : Relocation bitmap U end%>&4000:=ptr% : Even after removing reloc table, will be too long  here%=code% end%-1 $ (mem%?here% &C0)=&80:byte  here% : # Look for last unlinked module  Look for:  JSR xxxx:JMP yyyy &" or JSR xxxx:LDX &F4:JMP yyyy 0 link%=-2 : D found%= NR mem%?link%=&20 (mem%!(link%+3) &FFFFFF)=&4CF4A6:found%=:next%=link%+6 XA (mem%!link% &FF0000FF)=&4C000020:found%=:next%=link%+4 b& link%<0:found%=:next%=link%+6 l3 found%:last%=link%:link%=mem%!next% &3FFF v found%=0 2 last%=> JSR xxxx opcode field of last module 5 link%=> Start of service handler of last module 3 next%=> JMP yyyy address field of last module : 1 Link new module to previous service handler mem%?(ptr%-2)=&20 mem%?(ptr%-1)=link% %mem%?(ptr%-0)=(link% 256) &80 mem%?(ptr%+1)=&A6 mem%?(ptr%+2)=&F4 : ( Link previous module to new module mem%?(next%+0)=ptr%-2 )mem%?(next%+1)=((ptr%-2) 256) &80  =end% :  Close_All *"in%=in%:in%:A%=in%:in%=0:#A% 4 >: H#gbpb(A%,chn%,addr%,num%,ptr%) R>?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:<&FFFFF:&FFD1: \A%=1A%=3:#?X%=X%!9 f5:A%=1A%=2:#?X%,?X%!1 A%=3A%=4:?X%!1=#?X% p2X%!1=X%!1+1:X%!5=X%!5-1:(#?X%A%>2)X%!5<1: