100REM Next IWord 200REM Detect next available Inter-Word package by reading ROM-Link 300REM table starting in memory at &500 400REM (C) Ian Wolstenholme 2024 500REM Version 1.1 13/viii/2024 600REM Invoke next package with filename if specified 700REM Done on Station 201 800DIM code 256 900load=&900 1000romlink=&501 1100FOR B%=4TO7STEP3 1200P%=load 1300O%=code 1400[OPTB% 1500.nextiw 1600LDA#1 1700LDY#0 1800LDX#&70 1900JSR&FFDA \ OSARGS Get rest of CLI 2000LDX#9 \ Offset in cli buffer 2100.cliloop \ Copy rest of cli, ie. , to buffer 2200LDA(&70),Y 2300STAcli,X 2400INX:INY 2500CMP#13 2600BNEcliloop 2700LDY#0 2800STYnext 2900LDYromlink-1 3000CPY#&F 3100BEQallused \ Total=15=no free packages 3200CPY#&FF 3300BEQfoundnext \ Total=FF=all packages killed, therefore IW.0 free 3400INY 3500STYtotal 3600LDX#0 3700.matchloop 3800LDAromlink,X 3900AND#&F 4000CMPpackagetype 4100BNEnomatch 4200LDAromlink,X \ If here, IW package found, reload byte 4300AND#&F0 4400LSR A:LSR A:LSR A:LSR A \ IW package no now in A 4500\STA&70 \ Debug print ASCII number on screen 4600\CLC 4700\ADC#&30 4800\JSR&FFE3 4900\LDA&70 5000CMPnext 5100BEQmatch 5200.nomatch 5300INX \ Test next byte in ROM link table 5400CPXtotal 5500BNEmatchloop 5600.foundnext 5700LDX#6 \ Offset in CLI buffer 5800CLC 5900LDAnext 6000CMP#10 6100BMIsingledigit 6200PHA 6300LDA#&31 6400STAcli,X 6500INX 6600PLA 6700SEC 6800SBC#10 6900.singledigit 7000CLC 7100ADC#&30 7200STAcli,X 7300LDX#cli MOD256 7400LDY#cli DIV256 7500JMP&FFF7 7600RTS 7700.match 7800CMP#15 7900BEQallused 8000INC next 8100LDX#0 \ Reset X to check table again 8200JMPmatchloop 8300.allused EQUB0:EQUB254:EQUS"All packages used":EQUB0 8400.packagetype EQUB2 \ IWord identifier is 2 8500.next EQUB0 8600.total EQUB0 8700.cli EQUS"IWORD " 8800] 8900NEXT 9000PRINT"Start: ";~code 9100PRINT"End: ";~O% 9200PRINT"Load: ";~&FFFF0000+load 9300PRINT"Exec: ";~&FFFF0000+load