; OSCLI - Execute command ; ======================= ; On entry: X=>command string ; On exit: A holds any return value ; ; First check for local commands, then pass on sideways ROMs, then filing system ; CLI: PSHS B,DP,X,Y,U ; Save everything on caller's stack, except A and CC BSR CLI_GO ; Process the *command PULS B,DP,X,Y,U,PC ; Restore everything and return contents of A. ; OSCLI - Check for local commands ; -------------------------------- ; On entry: X=>command string ; CLI_GO: CLI_LP1: BSR SKIPSPC ; Skip leading spaces LDA ,X+ CMPA #'*' BEQ CLI_LP1 ; Skip leading '*'s CMPA #13 BEQ CLI_DONE ; * -> null line, done CMPA #'|' BEQ CLI_DONE ; *|comment -> done LEAX -1,X PSHS X ; Save start of command text CMPA #'/' BEQ CMD_SLASH ; */filename -> FSC 3 BSR SKIPWORD ; Step past command STX LPTR ; Point LPTR to command parameters LDY #CLI_TABLE ; Point to command table CLI_LOOP1: LDX ,S ; Get start of command text back LDA ,X ; Get first character CMPA #'A' BCS CLI_ROMS ; Not a letter, pass to ROMs CLI_LOOP2: LDA ,X+ ; Get character from command line ANDA #$DF ; Force to upper case CMPA ,Y+ ; Compare with table entry BEQ CLI_LOOP2 ; Characters match, check next LDA ,-Y ; Step to command token BMI CLI_MATCH ; Match LDA -1,X ; Get character from command line CMPA #'.' BEQ CLI_DOT ; Abbreviated command CLI_NEXT: LDA ,Y+ ; Search for command token BPL CLI_NEXT ; Step to end of table entry LDA ,Y BNE CLI_LOOP1 ; Not end of table BRA CLI_ROMS ; Pass to ROMs CLI_DOT: LDA ,Y+ ; Search for command token BPL CLI_DOT ; Step to end of table entry BRA CLI_MATCH2 CLI_MATCH: LDB ,-X ; Get current character CMPB #'!' BCC CLI_ROMS ; Command line longer than table entry CLI_MATCH2: ; A=&80+command number PULS X ; Drop old line pointer LDX LPTR ; X=>command parameters JMP xxxx ; Dispatch to command subroutine ; Not a local *command, try the sideways ROMs ; ------------------------------------------- CLI_ROMS: PULS X ; Get command string back LDA #4 JSR SERVICE ; Issue service call 4, X=>command string BEQ CLI_DONE ; Claimed by a sideways ROM ; Not a local command or a SROM command, try filing system ; -------------------------------------------------------- LDA #3 ; 3=unrecognised *command JMP (FSCV) ; returns if matched, FS gives error if not matched CLI_TABLE: FCC "CAT" FCB $80 FCC "BASIC" FCB $81 FCC "FX" FCB $82 FCC "HELP" FCB $83 etc.... FCB 0