diff --git a/level1/cmds/echo.asm b/level1/cmds/echo.asm index a1837055e..e2be6a184 100644 --- a/level1/cmds/echo.asm +++ b/level1/cmds/echo.asm @@ -12,8 +12,6 @@ nam Echo ttl Echo text -* Disassembled 98/09/10 22:44:14 by Disasm v1.6 (C) 1988 by RML - ifp1 use defsfile endc @@ -26,18 +24,18 @@ edition set 5 mod eom,name,tylg,atrv,start,size org 0 -u0000 rmb 450 + rmb 200 stack size equ . name fcs /Echo/ fcb edition -start tfr d,y - lda #1 - os9 I$WritLn - bcs Exit - clrb -Exit os9 F$Exit +start tfr d,y transfer parameter count to Y + lda #1 we are writing to standard out + os9 I$WritLn write the line + bcs ex@ branch if an error + clrb clear error and carry +ex@ os9 F$Exit exit emod eom equ * diff --git a/level1/cmds/ident.asm b/level1/cmds/ident.asm index 999c7b233..de985d146 100644 --- a/level1/cmds/ident.asm +++ b/level1/cmds/ident.asm @@ -179,64 +179,65 @@ start leas >u019C,u ldd #$0000 std M_MInc,pcr + +L0263 lda ,x+ get next parameter character +L0265 cmpa #C$SPAC space? + beq L0263 branch if so + cmpa #C$COMA comma? + beq L0263 branch if so + cmpa #C$CR carriage return? + beq L02BB branch if so + cmpa #'- option? + beq L027E branch if so + ldy M_MInc,pcr point to incorrect header message lbsr L05FC lbsr L0612 clrb @@ -572,17 +573,19 @@ L05E9 lda #'$ pshs b,a andb #$0F bra L05E9 -L05FC lda ,y - anda #$7F + +L05FC lda ,y get character at Y + anda #$7F clear hi bit bsr L0608 - lda ,y+ - bpl L05FC -L0606 lda #C$SPAC -L0608 pshs x - ldx OS9Prmpt,pcr - ldy #OS9PrmL - bra L0070 -L00A4 tst 1 + bhi testecho@ yes, process the command + leax >OS9Prmpt,pcr else return was pressed by itself; load OS-9 prompt string + ldy #OS9PrmL and load OS-9 prompt length + bra chkintro@ show if needed +testecho@ tst >>" fdb IERedir-* fcs "<>>" @@ -242,368 +256,429 @@ L0146 fdb AllRedir-* fcs "#" fdb $0000 -L0169 fcb $0d +L0169 fcb C$CR fcc "()" fcb $ff -L016D fcb $0d + +CRConst fcb C$CR fcc "!#&;<>" fcb $ff -L0175 clr b,u - decb - bpl L0175 - rts -L017B ldb #$0E - bsr L0175 -L017F clr L00FB,pcr - lbsr L020F - bcs L01DE - cmpa #C$CR - beq L01DE - sta L000D,pcr - sty = 0 + rts return + +* Parse commands on the command line +ParseCmdLine ldb #kbdsignl start from the keyboard signal variable down + bsr ClearAtU and clear to start of variables +L017F clr InternalCmds,pcr point to the internal commands table + lbsr DoParse parse the command line + bcs L01DE branch if there was an error + cmpa #C$CR is the character a carraige return? + beq L01DE branch if so + sta shellname,pcr point to shell name + sty L013A,pcr - bsr L020F + leay >ShellChars,pcr + bsr DoParse bcs L01DE - ldy L0146,pcr - bsr L020F - stx L016D,pcr -L0251 cmpa ,x+ - bhi L0251 - puls pc,x -L0257 leas $02,s - lda #C$SPAC -L025B cmpa ,x+ - beq L025B - leax -$01,x -NextCmd andcc #^Carry - rts -L0264 pshs y,x - leay $02,y -L0268 ldx ,s -L026A lda ,x+ - cmpa #$61 - bcs L0272 - suba #$20 -L0272 eora ,y+ - lsla - bne L0286 - bcc L026A - lda -$01,y - cmpa #$C1 - bcs L0283 - bsr L0241 - bcs L0286 -L0283 clra - puls pc,y,b,a -L0286 leay -$01,y -L0288 lda ,y+ - bpl L0288 - sty $02,s - ldd ,y++ - bne L0268 - comb - puls pc,y,x - -Ex lbsr L01E1 - clra - bsr L02B8 - bsr L02B7 - bsr L02B7 - bsr Comment - leax $01,x - tfr x,d - subd u00FF,u - lbsr L0497 - os9 F$Chain - lbra L00C2 -L02B7 inca -L02B8 pshs a - bra L0313 - -Chx lda #DIR.+EXEC. - bra L02C2 -*Chd lda #DIR.+UPDAT. note write mode!! -* Removed WRITE. requirement above (some devices are read only) + +* Process command +* +* Entry: X = program on command line to execute. +L01E1 stx Redirects,pcr point to redirect table + bsr DoParse attempt to match + stx CRConst,pcr point to carriage return +l@ cmpa ,x+ compare character to it + bhi l@ branch if higher + puls pc,x grab X and return +clean@ leas 2,s clean the stack + lda #C$SPAC load A with space +l1@ cmpa ,x+ is it the next character as well? + beq l1@ branch if so + leax -1,x else back up +NextCmd andcc #^Carry clear the carry + rts return +* X = Address of the source string. +* Y = Address of the string to match. +L0264 pshs y,x save registers + leay 2,y advance past the entry pointer +L0268 ldx ,s recover X on the stack +L026A lda ,x+ get the character at X and increment X + cmpa #'a is it 'a'? + bcs L0272 branch if lower than + suba #$20 make uppercase +L0272 eora ,y+ XOR with the character at Y and increment Y + lsla shift A left (move high bit of A into carry) + bne L0286 branch if not zero + bcc L026A branch if carry clear + lda -1,y get the previous character + cmpa #$C1 compare against ?? + bcs L0283 branch if carry set + bsr SkipCnsc skip consecutive characters + bcs L0286 branch if carry set +L0283 clra clear carry + puls pc,y,b,a pull registers and return +L0286 leay -1,y back up one +l0@ lda ,y+ get character + bpl l0@ keep going until we get passed hi-bit char + sty 2,s save pointer to next entry + ldd ,y++ get value at Y into D + bne L0268 branch if not zero + comb else set carry + puls pc,y,x and return + +* Process the EXIT command +* +* TODO: check of no parameters so we can bypass F$Chain and just call F$Exit. +Ex lbsr L01E1 process the argument as a command + clra set A to standard input + bsr procpath@ process standard input + bsr incpath@ process standard output + bsr incpath@ process standard error + bsr Comment go to end of the line + leax 1,x go past end of line + tfr x,d transfer to D + subd u00FF,u point S to area in our stack + lbsr ExecPrep prepare for chaining + os9 F$Chain chain the program + lbra ExitShellWithErr branch if error +incpath@ inca increment the path number +procpath@ pshs a push the path number + bra L0313 go process the path number + +* Change directory +Chx lda #DIR.+EXEC. set to "dir + exec" + bra l@ go change the directory +* Removed WRITE. requirement (some devices are read only) Chd lda #DIR.+READ. note write mode!! -L02C2 os9 I$ChgDir - rts - -Prompt clra - bra L02CB - -NoPrompt lda #$01 -L02CB sta >>" L03B3 bsr L03BC bcc L03DC L03B7 rts -IORedir lda #$0D - sta -$02,x + +IORedir lda #C$CR load A with carriage return + sta -$02,x terminate prior to "<>" L03BC bsr L03AA bcs L03B7 - ldd #$0180 + ldd #$01*256+$80 standard output in A and standard input in B (hi bit set to indicate path) bra L0362 -IERedir lda #$0D - sta -$03,x + +IERedir lda #C$CR load A with carriage return + sta -$03,x terminate prior to "<>>" bsr L03AA bcs L03B7 - ldd #$0280 + ldd #$02*256+$80 standard error in A and standard input in B (hi-bit set to indicate path) bra L0362 -OERedir lda #$0D - sta -$03,x - lda #$01 + +OERedir lda #C$CR load A with carriage return + sta -$03,x terminate prior to ">>>" + lda #$01 offset to standard output variable bsr L03AB bcs L03B7 -L03DC ldd #$0281 +L03DC ldd #$02*256+$81 standard error in A and standard output in B (hi-bit set to indicate path) bra L0362 -L03E1 pshs x,b,a - ldd ,x++ - cmpd #$2F30 - bcs L040D - cmpd #$2F32 - bhi L040D - pshs x,b,a - lbsr L0241 - puls x,b,a - bcs L040D - andb #$03 - cmpb $01,s - bne L0404 - ldb $01,s - ldb b,u + +* Check if /0, /1, or /2 syntax is being used. +* +* Entry: B = path (0, 1, or 2) +* X = pointer to characters to parse. +ChkStdSntx pshs x,b,a save registers + ldd ,x++ get next two characters + cmpd #'/*256+'0 /0 (redirect standard input)? + bcs ex@ branch if lower (not /0, /1, or /2) + cmpd #'/*256+'2 /2 (redirect standard error)? + bhi ex@ not higher (not /0, /1, or /2) + pshs x,b,a save registers + lbsr SkipCnsc skip characters after /0, /1, of /2 + puls x,b,a restore registers + bcs ex@ branch if carry set + andb #%00000011 mask out all but std/std/stderr + cmpb 1,s same as what was passed? + bne L0404 branch if not + ldb 1,s else get path + ldb b,u and load mode in our variables L0404 orb #$80 - stb ,s + stb ,s save it on A in stack puls b,a - leas $02,s - rts -L040D puls pc,x,b,a - -StkSize ldb #$0D - stb -$01,x - ldb L0013,pcr -L04E4 tst ,x +* Entry: X = first few bytes of module data +DetermineMod cmpa #Prgrm+Objct program? + beq L0527 branch if so + sty ModulTbl,pcr point to the module table +l0@ tst ,x end of table? ifgt Level-1 - beq L055F + beq badlang@ branch if so else - lbeq L055F + lbeq badlang@ branch if so endc - cmpa ,x+ - beq L04F2 -L04EC tst ,x+ - bpl L04EC - bra L04E4 -L04F2 ldd L000D,pcr -L0525 stx shellname,pcr point to shell name +L0525 stx