REM Author: Graham Toal REM Date: 04/02/1985 REM Acorn VLSI CAD Group REM New PANOS/UNIX file system - implements minimum subset of REM calls as issued by PANOS. See VLSI CAD Group document # 45. REM AUTO 1000 OSBYTE = &FFF4 filev = &212 argsv = &214 bgetv = &216 bputv = &218 gbpbv = &21A findv = &21C fscv = &21E Bit0=1:Bit1=2:Bit2=4:Bit3=8:Bit4=16:Bit5=32:Bit6=64:Bit7=128 ServiceBit=Bit7 :REM This is a service rom. LanguageBit=Bit6 :REM language Proc2Reloc=Bit5 ElkSoftKey=Bit4 SWRomBit=Bit1 :REM Must be set InternalVersion = 1 Version$ = "0.00.00/00" dirbit = 1: fromtobit = 2 :REM (un)Used in command table for *HELP info our_fs_no = 11 :REM See Hugo? ROMtable = &0DF0 Our_rom = &F4 REM **** Workspace declarations **** swzp0 = &A8: swzp1 = swzp0+1 Fixed_Start = &0E00 Fixed_End = &1000 :REM Address just past last byte we use - here = 512 bytes private_size = 256 :REM Bytes used in private workspace StackBase = &100 OffsetForA = 3 :REM Depends on stacking order - here assumes CC,A,Y,X OffsetForY = 2 DIM Code 4095 FOR Pass = 4 TO 6 STEP 2 :REM Remove later O% = Code: P%=&8000 [OPT Pass \########################################################################## \## ## \## Rom header ## \## ## \########################################################################## .RomHeader BRK:BRK:BRK \ No language entry Jmp service \ Service entry only EQUB SWRomBit+ServiceBit EQUB Copyright-RomHeader EQUB InternalVersion \ Unseen version number EQUS "Panos/UnixFS" EQUB 0 EQUS Version$ .Copyright EQUB 0 \ Copyright pointer points at the NUL EQUS "(C)1985 Graham Toal" EQUB 0 \########################################################################## \## ## \## Service rom entry point decoding ## \## ## \########################################################################## \============================================================================= \ Jumps out to various routines according to reason code in A \ Note that Y is passed on to the called service as it is sometimes \ a parameter. All registers pushed on stack in case command not wanted. .service Php \ STACK CC Pha \ STACK A Tya Pha \ STACK Y Txa Pha \ STACK X Tsx : Lda StackBase+OffsetForA,X \ Pick up A off stack (which points to NEXT FREE) \ (stack is downward growing) Cmp #(SWtable_end-SWtable_start) DIV 2 Bcs passon \ Range check on sideways command - only want those in our table Asl A \ Table thus limited to 128 entries Tax Lda SWtable_start+1,X \ Push HIGH first, Pha Lda SWtable_start,X \ Then LOW (processor removes LOW first) Pha Rts \************** Jump to sideways procedure - All regs still on stack \============================================================================= .passon \ Pull all registers off stack & return from sideways call WITHOUT claiming Pla \ UNSTACK X Tax Pla \ UNSTACK Y Tay Pla \ UNSTACK A Plp \ UNSTACK CC Rts \ And pass on unrecognised/unwanted sideways call \============================================================================= .claimed \ Restore all registers except A which is set to 0 to claim Pla \ UNSTACK X Tax Pla \ UNSTACK Y Tay Pla \ UNSTACK A Lda #0 \ CLAIM Plp \ UNSTACK CC Rts \ And return to Mos. \============================================================================= .SWtable_start \ This tables is used in the 'Jump indirect using RTS' style - so \ addresses must be '-1' because the processor increments BEFORE jumping. EQUW passon-1 \ 0 NOP EQUW ReserveFixed-1 \ 1 reserve fixed space EQUW ReservePrivate-1 \ 2 reserve private space EQUW passon-1 \ 3 auto boot EQUW passon-1 \ 4 unrecognised *COMMAND EQUW passon-1 \ 5 unrecognised IRQ EQUW passon-1 \ 6 BRK EQUW passon-1 \ 6 unrecognised OSBYTE EQUW passon-1 \ 8 unrecognised OSWORD EQUW passon-1 \ 9 *HELP command EQUW FixedClaimed-1 \ &A fixed workspace is being claimed EQUW passon-1 \ &B NMI release EQUW passon-1 \ &C NMI claim EQUW passon-1 \ &D ROM FS init EQUW passon-1 \ &E ROM Bget EQUW VectorsClaimed-1 \ &F vectors have been claimed (or will be?) EQUW passon-1 \ &10 Spool/exec closure warning EQUW passon-1 \ &11 Font implosion/explosion warning EQUW StartFS-1 \ &12 Start up filing system \**************************** Also calls FE & FF - ignored earlier \ (These calls may not exist in later systems) .SWtable_end \----------------------------------------------------------------------------- .ReserveFixed Tsx: Lda StackBase+OffsetForY,X \ Load original Y parameter \ Which we need to update if too small Cmp #(Fixed_End+255) DIV 256 \ The formula- 0 bytes -> 0 pages, \ 1..256 bytes -> 1 page Bcs fixed1 Lda #(Fixed_End+255) DIV 256 .fixed1 Sta StackBase+OffsetForY,Y Jmp passon \----------------------------------------------------------------------------- .ReservePrivate Tsx: Lda StackBase+OffsetForY,X \ Load original Y parameter into A Ldy Our_rom \ Our ROM number Sta ROMtable,Y \ Save start of our private space in romnumber'th byte \ of space at ROMtable (X contains ROM no.) \ LATER - USE TOP BIT FOR FRUGAL MECHANISM. Clc: Adc #(private_size+255) DIV 256 \ Add no of pages we use. Sta StackBase+OffsetForY,X \ And re-store in Y slot. Jmp passon \----------------------------------------------------------------------------- .FixedClaimed \ Remove any important data from fixed workspace to private workspace \ Ldx Our_rom \ ROM no. [ Is this the best place to get the No? ] \ Lda ROMtable,X \ Have we got the fixed workspace ? \ SHOULDN'T LOOK HERE - FRUGAL. Jmp passon \ No. \----------------------------------------------------------------------------- .VectorsClaimed \ May not be needed? Jmp passon \----------------------------------------------------------------------------- .StartFS \ S/W-OFFER to start up filing system Tsx: Lda StackBase+OffsetForY,X \ Load original Y parameter Cmp #our_fs_no Bne passon Jsr StartUpFilingSystem \ Start-up this filing system. Jmp claimed \----------------------------------------------------------------------------- .StartUpFilingSystem \############################################################ \## ## \## Filing system vectors ## \## FILEV - *LOAD, *SAVE ## \## ARGSV - Cli param line, fsys no. ## \## BGETV, BPUTV - byte IO ## \## GBPBV - not implemented ## \## FINDV - OPENIN etc. ## \## FSCV - *cat, *run etc. ## \## ## \############################################################ OPT FNvec(filev, OsFile) OPT FNvec(argsv, OsArgs) OPT FNvec(bgetv, Bget) OPT FNvec(bputv, Bput) OPT FNvec(gbpbv, OsGBPB) OPT FNvec(findv, OsFind) OPT FNvec(fscv, filesys) Rts \------------------------------------------------------------------------- .filesys Cmp #0: Bne filesysA Jsr brk: EQUB 13: EQUS "*OPT not supported under PANOS": EQUB 0 .filesysA Cmp #1: Bne filesysB Jsr brk: EQUB 14: EQUS "EOF# not supported under PANOS": EQUB 0 .filesysB Cmp #2: Bne filesysB Jsr brk: EQUB 15: EQUS "*/ not supported under PANOS": EQUB 0 .filesysB \* 3 - unrecognised command Cmp #3: Bne filesys1 \ X,Y point to command - set up swzp0,1 Stx swzp0 Sty swzp1 \ Should skip leading spaces & stars? Jmp OsCli \ Is low,high order correct? .filesys1 Cmp #4: Bne filesysC Jsr brk: EQUB 16: EQUS "*RUN not supported under PANOS": EQUB 0 .filesysC Cmp #5: Bne filesysD Jsr brk: EQUB 17: EQUS "*CAT not supported under PANOS": EQUB 0 .filesysD \* 6 - vectors removed Cmp #6: Bne filesys2 \ Close spool & exec files - not needed. \ Ignore quietly RTS .filesys2 \* 7 - Cmp #7: Bne filesys3 \ Return range of handles RTS .filesys3 Cmp #8: Bne filesys4 \ *enable test \ Ignore quietly RTS .filesys4 \ Complain - PANOS Shouldn't issue these. Jsr brk: EQUB 1: EQUS "Illegal subset filing system operation": EQUB 0 \------------------------------------------------------------------------- .OsFile \* 0 - Save Cmp #0: Bne osfile1 Rts .osfile1 \* 1 - Set load/exec/attr Cmp #1: Bne osfile2 Rts .osfile2 \* 5 - Read load/exec/attr Cmp #5: Bne osfile3 Rts .osfile3 \* 6 - Delete file Cmp #6: Bne osfile4 Rts .osfile4 \* FF - Load Cmp #&FF: Bne osfile5 Rts .osfile5 Jsr brk: EQUB 6: EQUS "This OSFILE operation is not supported under PANOS" EQUB 0 \------------------------------------------------------------------------- .OsArgs \* Y <> 0, => Y = File handle Cpy #0: Bne osargs1 Jsr brk: EQUB 7: EQUS "OSARGS with Y=0 is not supported under PANOS" EQUB 0 .osargs1 \* A = 0 - Read file pointer Cmp #0: Bne osargs2 Rts .osargs2 \* 1 - Write file pointer Cmp #1: Bne osargs2 Rts .osargs2 \* 2 - Read file length Cmp #2: Bne osargs3 Rts .osargs3 \* FF - Update media (unix-sync) Cmp #&FF: Bne osargs4 Rts .osargs4 Jsr brk: EQUB 8: EQUS "This OSARGS is not supported under PANOS" EQUB 0 \------------------------------------------------------------------------- .Bget \ NOT IMPLEMENTED IN PANOS FILING SYSTEMS Jsr brk: EQUB 9: EQUS "OSBGET is not supported under PANOS" EQUB 0 \------------------------------------------------------------------------- .Bput \ NOT IMPLEMENTED IN PANOS FILING SYSTEMS Jsr brk: EQUB 10: EQUS "OSBPUT is not supported under PANOS" EQUB 0 \------------------------------------------------------------------------- .OsGBPB \* 2 - group of bytes Cmp #2: Bne osgbpb1 Rts .osgbpb1 \* 4 - group of bytes Cmp #4: Bne osgbpb2 Rts .osgbpb2 \* 8 - Read files in catalogue 1 by 1. Cmp #8: Bne osgbpb3 Rts .osgbpb3 Jsr brk: EQUB 11: EQUS "This OSGBPB operation is not supported under PANOS" EQUB 0 \------------------------------------------------------------------------- .OsFind \* 00 - close individual file (handle <> 0) Cmp #0: Bne osfind1 Cpy #0: Bne osfind_close Jsr brk: EQUB 12: EQUS "OSFIND Close#0 is not supported under PANOS" EQUB 0 .osfind_close Rts .osfind1 \* 40 - open for read Cmp #&40: Bne osfind2 Rts .osfind2 \* 80 - write Cmp #&80: Bne osfind3 Rts .osfind3 \* C0 - update Cmp #&C0: Bne osfind4 Rts .osfind4 Jsr brk: EQUB 13: EQUS "This OSFIND operation is not supported under PANOS" EQUB 0 \------------------------------------------------------------------------- \ \ Command Line Interpreter \ \ \ Enters here with X pointing to the first command \ allowable in this context, as an offset from the start of \ the command table. (swzp0,1) points to the command to be examined \ Table format is command text followed by a byte with the top \ bit set (which has syntax encoded in it for the help command) \ this is followed by the two byte address of the routine in question. \ Returns with carry set if unable to decode the command. \ The table is terminated by &FF \ Note that the command terminator byte may not be &FF \ \ .OsCli Ldx #0 \ X Points to first allowable command in cmdtab Ldy #0 \ Y points to base of command (in swzp0,1) .cli1 LDA (swzp0),Y \ Try a character from the command AND #&5F \ Force to upper case \ (weird if non alpha, but still not alpha) INX \ to point to next table char INY \ ready to go round loop EOR cmdtab-1,X \ Devious, this bit ! \ ... (-1 because X already inc'd) \ EOR because this leaves the top bit \ of table in N (top of A cleared \ earlier) but simultaneously leaves Z \ as the comparison result. BEQ cli1 \ Exactly the same - keep going BMI cli3 \ Top bit set (in table version) \ - we have reached the end \ \ At this point, we are in disagreement - \ could be dot abbreviation, or a genuine mis-match. \ DEY \ go back to the char in question LDA (swzp0),Y CMP #ASC"." BNE cli2 \ Definitely not OK now INY \ SKIP OVER "." WHEN PASSING REST OF LINE TO CLI \ \ Now OK so skip to end of command \ .cli5 INX LDA cmdtab-1,X \ This is the same offset as above, \ so exit condition has same X. \ Can't miss the end despite having inc'd X as we \ would have found it straight away \ if the last match was with the terminator. BPL cli5 BMI cli4 \ Unconditional \ \ Total failure if not dot abbreviation \ so skip to next table entry \ .cli2 INX LDA cmdtab-2,X \X has been incremented - on entry lowest value \possible would be 2nd byte of dud cmd, highest would be \pointing at lo byte of address, so at this point we either \test one of the command bytes or the byte with top bit set. BPL cli2 \ Find byte with top bit set INX \ X Now pointing at 1st byte of next cmd LDY #0 \ Restore pointer to base of command (in swzp0,1) CMP cmdtab,X BCS cli1 \ Another devious one ... \ A is always >127 (we have just \ tested it), and ,X is either &FF \ (= end of table), or is a character. \ If X=&FF, X is always >=A hence carry clear, if \ X=(character) then X<128 \ hence X