home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / UNIFLEX / UNIFLEX / UniFLEX_Std.Utils1.tar.Z / UniFLEX_Std.Utils1.tar / utils1 / testshell < prev    next >
Text File  |  1982-03-09  |  45KB  |  2,402 lines

  1.  opt pag,nol
  2.  ttl UniFLEX Shell
  3.  pag
  4.  lib sysdef
  5.  opt lis
  6.  pag
  7.  
  8.  info UniFLEX shell
  9.  info Version 1.03, Released June 22, 1981
  10.  info Copyright, (C) 1981, by
  11.  info Technical Systems Consultants, Inc.
  12.  info All rights reserved.
  13.  
  14.  ifc &a,"notext"
  15.  org 0
  16.  else
  17.  text
  18.  endif
  19.  
  20. *
  21. * Program parameters
  22. *
  23.  
  24. ENTTY equ 29 device not terminal
  25. ENOFL equ 8 no file
  26. ENOTB equ 21 not binary
  27. NFILES equ 16 number of files (max)
  28. ASSIZ equ 5 number of async tasks
  29. BUFSIZ equ 256 input line buffer size
  30. SPACE equ $20 ascii space character
  31. COMMA equ ', ascii comma
  32. TAB equ $9 tab character
  33. BHDBT equ $8a basic header byte
  34. BHDBT2 equ $9a new basic header byte (v2.0)
  35. PHDBT0 equ $8B Pascal (normal) header byte ***GDT
  36. PHDBT1 equ $8c pascal (system) ***GDT
  37. LTS equ '<
  38. GTS equ '>
  39. TPCH equ '~ time prompt character
  40.  
  41.  
  42. *
  43. * Program starts here
  44. *
  45.  
  46. sh lbsr sinit do init
  47.  sts sp save sp
  48.  tst bgop background?
  49.  bne sh00
  50.  tst intflg interactive?
  51.  beq sh0
  52. sh00 sys cpint,2,1 if so, ignore ints
  53.  sys cpint,3,1
  54. sh0 lds sp reset stack ptr
  55.  ldd ctrm check term status
  56.  bne sh05
  57.  tst termc still more line?
  58.  bne sh12
  59. sh05 tst pipmod in pipe?
  60.  beq sh07
  61.  clr pipmod clear out mode
  62.  ldd pprdf close pipe files
  63.  sys close
  64.  ldd ppwrf
  65.  sys close
  66. sh07 clr pipmod clear out pipe
  67.  clr ctrm clear exit status
  68.  clr ctrm+1
  69.  tst intflg interactive?
  70.  beq sh1 if not, skip prompt
  71.  ldd #0 set file desc
  72.  sys ttyget,ttgbuf get tty params
  73.  lda ttgbuf get stat flags
  74.  anda #%10111110 clear schar mode (also raw)
  75.  sta ttgbuf
  76.  ldd #0 set file desc
  77.  sys ttyset,ttgbuf set tty status
  78.  lbsr wrtpr output prompt
  79. sh1 lbsr getlin get an input line
  80.  bne sh11
  81.  tst supf doing startup?
  82.  lbeq sexit if so, terminate
  83.  clr supf clear mode
  84.  bra sh0 re-prompt
  85. sh11 cmpb #1 only c.r.??
  86.  beq sh0 if so, go to start
  87.  ldx #buffer
  88.  stx bufpt set buffer start
  89. sh12 lbsr pars parse the line
  90.  swi
  91.  beq sh0 error?
  92.  lbsr scmnd check for shell command
  93.  bne sh6
  94.  jmp 0,x go do command
  95. sh6 ldd #0 clear command
  96.  std comnd
  97.  ldx arglst point to command name
  98.  beq sh9 null args?
  99.  tst prflg paren command?
  100.  bne sh92
  101.  ldy #comnd point to command buffer
  102. sh62 lda 0,x+ get a character
  103.  sta 0,y+ xfr to command buffer
  104.  bne sh62 end?
  105.  leax -1,x back up to term
  106. sh8 cmpx arglst back to beginning?
  107.  beq sh9
  108.  lda 0,-x get previous character
  109.  cmpa #'/ is it /?
  110.  bne sh8
  111.  leax 1,x eat slash
  112. sh9 stx arglst set first arg (cmnd name)
  113.  lda comnd check for null command
  114.  lbeq sh0
  115. sh92 lda termc get term char
  116.  cmpa #'| is it pipe?
  117.  lbeq cpipe
  118.  cmpa #'^
  119.  lbeq cpipe if so, create pipe
  120. sh95 sys fork do system fork call
  121.  bra doit this is new task here
  122.  lbes frkerr fork error?
  123.  pshs d old task, save new ones id
  124.  lda termc get term character
  125.  cmpa #'| is it pipe?
  126.  lbeq dpipe
  127.  cmpa #'^ is it pipe?
  128.  lbeq dpipe
  129.  tst pipmod pipe active?
  130.  beq sh97
  131.  clr pipmod clear pipe mode
  132.  ldd apprdf get read file
  133.  sys close close it
  134. sh97 lda termc get term character
  135.  cmpa #'& is it async mode?
  136.  lbeq async
  137. pwait puls d get task id
  138.  std syntid save it
  139. pwait1 sys wait wait for task to die
  140.  cmpd syntid is it the child?
  141.  beq pwait2
  142.  lbsr chasy check for async job termination
  143.  bra pwait1 go wait some more
  144. pwait2 stx ctrm save command term status
  145.  beq pwait3 errors?
  146.  tst intflg interactive mode?
  147.  bne pwait3
  148.  tst supf doing startup?
  149.  beq pwai25
  150.  ldd #linbuf
  151.  std linpt
  152.  std linend
  153.  ldd ifd
  154.  sys seek,0,0,2 seek to end of file
  155.  bra pwait3
  156. pwai25 tfr x,d get status
  157.  sys term exit!
  158. pwait3 lbsr abtrm report any abnormal terminations
  159.  lbra rprt go report termd tasks
  160.  
  161.  pag
  162.  
  163. * execute command
  164.  
  165. doit lda termc check for async
  166.  cmpa #'&
  167.  beq doi12
  168.  cmpa #'| doing pipe?
  169.  beq doi12
  170.  cmpa #'^
  171.  beq doi12
  172.  tst bgop background option set?
  173.  bne doi12
  174. doit1 sys cpint,2,0
  175.  sys cpint,3,0
  176. doi12 ldd sifil test input redirection
  177.  beq doi14
  178.  lbsr opsi open new input
  179.  lbes bdfil error?
  180. doi14 tst sofil test for output redirection
  181.  beq doi15
  182.  lbsr opso open new output
  183.  lbes bdfil error?
  184. doi15 tst safil output append?
  185.  beq doi16
  186.  lbsr opsa open append file
  187.  lbes bdfil error?
  188. doi16 lbsr spipe set up pipe
  189.  lda termc check for async
  190.  cmpa #'&
  191.  bne doi17
  192.  tst pipmod in pipe?
  193.  bne doi17
  194.  ldd sifil new input file?
  195.  bne doi17 if so, ok
  196.  ldd #nldst set up null device
  197.  std sifil
  198.  lbsr opsi open as input
  199. doi17 tst prflg check for paren string
  200.  lbne dosub if so, do subshell
  201.  clr rtcnt clear out retry counter
  202.  sys exec,comnd,arglst exec program
  203.  cmpd #ENOTB file not binary?
  204.  beq trya
  205.  lda comnd check first char
  206.  cmpa #'/ is it path head?
  207.  beq doit3
  208.  inc rtcnt bump retry count
  209.  sys exec,retry1,arglst try 'bin/...'
  210.  cmpd #ENOTB not binary?
  211.  beq trya
  212.  inc rtcnt bump counter
  213.  sys exec,retry2,arglst try '/bin/...'
  214.  cmpd #ENOTB not binary?
  215.  beq trya
  216.  inc rtcnt bump retry count
  217.  sys exec,retry3,arglst try '/usr/bin/...'
  218.  cmpd #ENOTB
  219.  beq trya
  220. doit3 ldd #1 if here, error!
  221.  sys write,ermsg1,ERSIZ1
  222.  ldx #comnd
  223.  ldd #0
  224. doit4 lda 0,x+
  225.  beq doit5
  226.  incb
  227.  bra doit4
  228. doit5 tst b
  229.  beq doit7
  230.  std doit6+5 save as arg
  231.  ldd #1 set file desc
  232. doit6 sys write,comnd,0
  233. doit7 ldd #1
  234.  sys write,ermsg2,ERSIZ2
  235.  ldd #$ff set error status
  236.  sys term terminate this guy!
  237.  
  238. *
  239. * trya
  240. *
  241. * Try to execute ascii file.
  242. *
  243.  
  244. trya ldx #rtclst point to list
  245.  lda rtcnt get retry count
  246.  asla
  247.  leax a,x point to retry number
  248.  ldd 0,x get pointer
  249.  std iopn2 set in open call
  250.  std arglst
  251.  sys ind,iopn open file
  252.  bes trya6
  253.  pshs d save file desc
  254.  clr smbuf
  255.  sys read,smbuf,2 read 1st 2 characters
  256.  puls d get fd
  257.  sys close close the file
  258.  lda smbuf get 1st char
  259.  bmi trybas basic file?
  260.  cmpa #$20 is it ascii?
  261.  blo trya6
  262.  lda termc check term char
  263.  cmpa #'& background?
  264.  bne trya4
  265.  ldd #plbst get '+b' string
  266.  std sargls
  267.  sys exec,cshell,bsrgls exec shell with '+b'
  268.  lbra doit3
  269. trya4 sys exec,cshell,sargls execute a shell
  270. trya6 lbra doit3 report error
  271.  
  272. rtclst fdb comnd,retry1,retry2,retry3
  273.  
  274. trybas cmpa #BHDBT is it basic file?
  275.  beq trybs2
  276.  cmpa #BHDBT2 new type?
  277. trybs2 bne tryP try Pascal program ***GDT
  278.  sys exec,cbasic,sargls try basic execution
  279.  lbra doit3 error?
  280.  
  281. tryP cmpa #PHDBT0 normal Pascal program? ***GDT
  282.  bne tryP1 no - try system ***GDT
  283.  sys exec,Pscl0,sargls try Pascal execution ***GDT
  284.  lbra doit3 error ***GDT
  285.  
  286. tryP1 cmpa #PHDBT1 system Pascal program? ***GDT
  287.  lbne doit3 no - error ***GDT
  288.  sys exec,Pscl1,sargls try to execute Pascal program ***GDT
  289.  lbra doit3 error ***GDT
  290.  
  291. *
  292. * Report fork error
  293. *
  294.  
  295. frkerr ldd #1 set file desc
  296.  sys write,frkmsg,FRKSIZ
  297.  lbra rprt
  298.  
  299.  pag
  300.  
  301. * exit shell
  302.  
  303. sexit ldd ctrm get term cond
  304. sexit4 sys term terminate this task!
  305.  
  306. *
  307. * sinit
  308. *
  309. * Shell initialization
  310. *
  311.  
  312. sinit clr coptf reset 'c' opt flag
  313.  clr termc
  314.  clr pipmod
  315.  ldd #0 set input fd
  316.  std ifd
  317.  ldb #ASSIZ*9
  318.  ldx #attab clear out async table
  319. sini05 clr 0,x+
  320.  decb
  321.  bne sini05
  322.  lbsr cfile close all files
  323.  ldd #cshln get shell name
  324.  std sargls save as arg
  325.  std bsrgls
  326.  ldx #linbuf set initial pointers
  327.  stx linpt
  328.  stx linend
  329.  lda #1 set interactive mode
  330.  sta intflg
  331.  ldd #0 set file desc 0
  332.  sys ttyget,ttgbuf
  333.  bec sinit0 error?
  334.  cmpb #ENTTY is it not a tty?
  335.  bne sinit0
  336.  clr intflg clear interactive mode
  337. * sys cpint,2,0 reset ints ?????
  338. * sys cpint,3,0 ?????
  339. sinit0 ldd 2,s get arg count
  340.  cmpd #1 any args?
  341.  bhi sinit2
  342.  lda [4,s] get 1st char of arg 1
  343.  cmpa #'+ is it '+'?
  344.  beq sinit4
  345. sinit1 rts return
  346. sinit2 lbsr opts process options
  347.  tst coptf 'c' option set?
  348.  beq sinit3
  349. sini25 rts return
  350. sinit3 ldx subpt get arg pointer
  351.  beq sini25 any left?
  352.  ldd 0,x get arg
  353.  beq sini25 null?
  354.  clr intflg set non-interactive mode
  355.  ldd [subpt] get file name pointer
  356. sini35 std iopn2 set up sys call
  357.  sys ind,iopn open file for read
  358.  bes sini37 errors?
  359.  std ifd save file desc
  360.  bra sini25
  361. sini37 tst supf startup?
  362.  bne sinit6
  363.  sys term exit
  364. sinit4 sys open,hmfl,0 get home file
  365.  bes sinit5 ignore errors
  366.  pshs d save file desc
  367.  sys read,defdir,48 read in dir name
  368.  puls d get file desc
  369.  sys close the file
  370.  sys unlink,hmfl delete home file
  371. sinit5 lda #1 set startup mode
  372.  sta supf
  373.  clr intflg clear interactive mode
  374.  ldd #cstrt get startup name
  375.  bra sini35 go open & run it
  376. sinit6 clr supf clear out startup mode
  377.  inc intflg set interactive
  378.  rts return
  379.  
  380.  pag
  381.  
  382. *
  383. * opts
  384. *
  385. * Process options for shell call.
  386. *
  387.  
  388. opts leax 8,s point to arg list
  389.  stx subpt save it
  390.  ldx 0,x get arg
  391.  beq opts9 null?
  392.  lda 0,x+ get 1st char
  393.  cmpa #'+ is it '+'?
  394.  bne opts9
  395. opts2 lda 0,x+ get next char of arg
  396.  beq opts8
  397.  cmpa #'c is it c option?
  398.  bne opts4
  399.  sta coptf set option flag
  400.  clr intflg set non-interactive
  401.  ldd 10,s get string pointer
  402.  std cbpt
  403.  bra opts2
  404. opts4 cmpa #'b is it b option?
  405.  bne opts2
  406.  stb bgop set option flag
  407.  bra opts2
  408. opts8 leax 10,s point to arg
  409.  stx subpt set pointer
  410. opts9 ldd [subpt] check for null args
  411.  bne opts10
  412.  std subpt
  413. opts10 rts return
  414.  
  415.  pag
  416.  
  417. *
  418. * pars
  419. *
  420. * Parse the command line.  Return 'eq' if error.
  421. *
  422.  
  423. pars ldd #0 zero out data
  424.  std sifil
  425.  std sofil
  426.  std safil
  427.  sta prflg
  428.  deca set non zero
  429.  sta soft
  430.  ldd #fstlst set string pointer
  431.  std fstpt
  432.  ldd #arglst init pointers
  433.  std argpt
  434.  ldx bufpt point to command line
  435. pars1 lda 0,x+ sjip leading spaces
  436.  beq pars9 eol?
  437.  cmpa #SPACE
  438.  beq pars1
  439.  cmpa #TAB is it tab?
  440.  beq pars1
  441.  leax -1,x back up to prev char
  442.  stx bufpt save new pos
  443. pars2 lda soft last term a soft one?
  444.  beq pars7 if not, exit
  445.  lbsr gword get a word
  446.  tst quote quoted string?
  447.  bne pars6
  448.  lda 0,y get first chars of word
  449.  ldx #sifil point to list
  450.  cmpa #LTS is it '<'?
  451.  beq pars4
  452.  leax 2,x bump to next
  453.  cmpa #GTS is it '>'?
  454.  bne pars5
  455.  ldd 2,x is it ok?
  456.  bne pars8 error?
  457.  ldd 0,x
  458.  bne pars8
  459.  ldb 1,y get 2nd char
  460.  cmpb #GTS is it '>>'?
  461.  bne pars4
  462.  leax 2,x
  463. pars4 ldd 0,x already defined?
  464.  bne pars8 if so, error
  465.  leay 1,y move past '>'
  466.  cmpx #safil is it append?
  467.  bne pars45
  468.  leay 1,y
  469. pars45 sty 0,x save file pointer
  470.  tst 0,y null file name??
  471.  beq pars8
  472.  bra pars2 repeat
  473. pars5 lbsr subst check for substitution
  474.  beq pars2 null arg?
  475. pars6 ldx argpt get arg pos
  476.  sty 0,x++ save new arg
  477.  stx argpt
  478.  lbsr marg do arg matching
  479.  bra pars2 repeat
  480. pars7 ldx argpt get arg pos
  481.  ldd #0 set null arg
  482.  std 0,x set null term
  483.  clz set status
  484.  rts return
  485. pars8 bsr synerr report error
  486.  sez set error
  487.  rts return
  488. pars9 clr termc set eol
  489.  rts return
  490.  
  491.  pag
  492.  
  493. *
  494. * synerr
  495. *
  496. * Report syntax error
  497. *
  498.  
  499. synerr clr termc clear out term
  500.  tst intflg interractive?
  501.  beq syner4
  502.  ldd #2 set file desc
  503.  sys write,syrms,SYSIZ write error message
  504. syner2 rts return
  505. syner4 ldd #$ff set error status
  506.  sys term exit!
  507.  
  508.  
  509. *
  510. * gword
  511. *
  512. * Parse a word and return pointer in Y.
  513. *
  514.  
  515. gword ldx bufpt get buffer pos
  516.  clr quote
  517.  lda 0,x get 1st char
  518.  cmpa #'( is it paren?
  519.  lbeq bldpr
  520.  cmpa #'" is it quote?
  521.  beq gword1
  522.  cmpa #'' is it quote?
  523.  bne gword2
  524. gword1 sta quote set quote mode
  525.  leax 1,x skip the '
  526.  stx bufpt save new start
  527. gword2 lda 0,x+ get a character
  528.  clr soft clear soft term flag
  529.  bsr tsttrm test for term
  530.  bne gword2 repeat til term
  531.  ldy bufpt get start of word
  532.  stx bufpt save new pos
  533.  rts return
  534.  
  535.  pag
  536.  
  537. *
  538. * tsttrm
  539. *
  540. * Test if char in A is term char.
  541. *
  542.  
  543. tsttrm tst quote quoted arg?
  544.  bne tsttr8
  545.  cmpa #SPACE is it space?
  546.  beq tsttr6
  547.  cmpa #TAB is it tab?
  548.  beq tsttr6
  549.  inc soft set soft term flag
  550.  cmpa #COMMA is it comma?
  551.  beq tsttr4
  552. tsttr1 clr soft
  553.  tsta is it null term?
  554.  bne tsttr2
  555.  clr termc set term char to null
  556.  rts return
  557. tsttr2 bsr chktrm check for hard term
  558.  beq tsttr4
  559.  rts no term
  560. tsttr4 sta termc save term character
  561.  clr -1,x set null word term
  562. tstt45 lda 0,x+ skip trailing spaces
  563.  cmpa #SPACE
  564.  beq tstt45
  565.  cmpa #TAB is it tab?
  566.  beq tstt45
  567.  leax -1,x
  568.  sez set term status
  569. tsttr5 rts return
  570. tsttr6 sta termc save term char
  571.  clr -1,x set null word term
  572. tsttr7 lda 0,x+ get next
  573.  beq tsttr1
  574.  cmpa #SPACE more spaces?
  575.  beq tsttr7
  576.  cmpa #TAB is it tab?
  577.  beq tsttr7
  578.  bsr chktrm check for hard term
  579.  beq tsttr4
  580.  leax -1,x
  581.  inc soft set soft term flag
  582.  sez set term status
  583.  rts return
  584. tsttr8 tsta term?
  585.  beq tsttr1
  586.  cmpa quote is it '?
  587.  bne tsttr5
  588.  lda #SPACE set up space term
  589.  bra tsttr6
  590.  
  591.  pag
  592.  
  593. *
  594. * chktrm
  595. *
  596. * Check if character in A is a hard term.
  597. *
  598.  
  599. chktrm ldy #trmtab point to table
  600. chktr2 cmpa 0,y+ look for char
  601.  beq chktr4
  602.  cmpy #trmend end of table?
  603.  bne chktr2
  604.  clz set no term
  605. chktr4 rts return
  606.  
  607. trmtab fcb ';,'|,'^,'&
  608. trmend equ *
  609.  
  610.  
  611. *
  612. * opsi
  613. *
  614. * Open new input file.
  615. *
  616.  
  617. opsi ldd sifil get file name
  618.  std iopn2 save in ind call
  619.  sys ind,iopn open file for read
  620.  bes opsi4 error?
  621.  pshs d save file desc
  622.  ldd #0 get input file desc
  623.  sys close close it
  624.  ldd 0,s get new fd
  625.  sys dup dup this file
  626.  puls d
  627.  sys close close the file
  628.  clc set status
  629. opsi4 rts return
  630.  
  631. *
  632. * opso
  633. *
  634. * Open new output file.
  635. *
  636.  
  637. opso ldd sofil get file name
  638. opso1 std icrt2 set in ind call
  639.  sys ind,icrt creat file
  640.  bes opso4 error?
  641.  pshs d save file desc
  642. opso2 ldd #1 get output file fd
  643.  sys close close the file
  644.  ldd 0,s get new fd
  645.  sys dup dup this file
  646.  puls d
  647.  sys close now close it
  648.  clc set status
  649. opso4 rts return
  650.  
  651.  pag
  652.  
  653. *
  654. * opsa
  655. *
  656.  
  657. opsa ldd safil get file name
  658.  std iopnw2 set up call
  659.  sys ind,iopnw open for write
  660.  bes opsa2
  661.  pshs d save file desc
  662.  sys seek,0,0,2 seek to eof
  663.  bra opso2
  664. opsa2 cmpb #ENOFL is it no file error?
  665.  bne opsa4
  666.  ldd safil get file name
  667.  bra opso1 go create it
  668. opsa4 sec set error
  669.  rts return
  670.  
  671.  
  672. *
  673. * getlin
  674. *
  675. * Get an input line and put it in the buffer.
  676. *
  677.  
  678. getlin ldx #buffer point to buffer
  679.  clr 0,-s set count
  680. getli2 bsr gtch get a character
  681.  beq getli6 eof?
  682.  sta 0,x+ save char in buffer
  683.  inc 0,s bump count
  684.  cmpa #$d is it cr?
  685.  bne getli2
  686.  clr -1,x set null term
  687.  clz set status
  688. getli4 puls b,pc return
  689. getli6 tst supf doing startup?
  690.  beq getli4 if not - exit
  691.  inc intflg set interactive
  692.  ldd ifd get file desc
  693.  sys close close the input file
  694.  ldd #0 reset input file to 0
  695.  std ifd
  696.  ldd #linbuf reset pointers
  697.  std linpt
  698.  std linend
  699.  sez set status
  700.  puls b,pc return
  701.  
  702.  pag
  703.  
  704. *
  705. * gtch
  706. *
  707. * Get a character from linbuf
  708. *
  709.  
  710. gtch pshs x save pointer
  711.  tst coptf check c opt flag
  712.  bne gctc
  713. gtch2 ldx linpt get line pointer
  714.  cmpx linend end of current?
  715.  bne gtch4
  716.  ldd ifd set file desc
  717.  sys read,linbuf,512 read in data
  718.  bes gtch6 error?
  719.  cmpd #0 eof?
  720.  beq gtch6
  721.  ldx #linbuf set start pointer
  722.  stx linpt
  723.  leax d,x mark end of buffer
  724.  stx linend set end
  725.  ldx linpt reset to start
  726. gtch4 lda 0,x+ get a character
  727.  stx linpt save pointer
  728.  clz set status
  729.  puls x,pc return
  730. gtch6 sez set eof status
  731.  puls x,pc return
  732.  
  733.  
  734. *
  735. * gctc
  736. *
  737.  
  738. gctc ldx cbpt get command pointer
  739.  beq gctc6
  740.  lda 0,x+ get a character
  741.  beq gctc4
  742.  cmpa #$d end of line?
  743.  bne gctc5
  744.  tst 0,x check for term
  745.  bne gctc5
  746. gctc4 lda #$d set end of line
  747.  ldx #0 null out pointer
  748. gctc5 stx cbpt set new pointer
  749.  clz set ok status
  750. gctc6 puls x,pc return
  751.  
  752.  pag
  753.  
  754. *
  755. * bdfil
  756. *
  757. * Report bad redirection file
  758. *
  759.  
  760. bdfil clr termc clear out term char
  761.  tst intflg interactive?
  762.  beq bdfil2
  763.  pshs d
  764.  ldd #2
  765.  sys write,bdfms,BDSIZ output error
  766.  puls d get status back
  767. bdfil2 sys term term this task
  768.  
  769.  
  770. *
  771. * rprt
  772. *
  773. * Report any tasks which have terminated.
  774. *
  775.  
  776. rprt ldx #attab point to async table
  777. rprt2 tst 2,x check its activity
  778.  bne rprt4
  779. rprt3 leax 9,x move to next entry
  780.  cmpx #atend end of table?
  781.  bne rprt2
  782.  lbra sh0 go to main loop
  783. rprt4 pshs x save entry
  784.  ldd 0,x get task id
  785.  lbsr prtid
  786.  ldd #1 output message
  787.  sys write,ttmsg,TTMSZ
  788.  ldx 0,s get table pointer
  789.  lda 3,x get term status
  790.  lbsr ptmsg print term message
  791.  puls x get entry
  792.  ldd #0 zero out entry
  793.  std 0,x
  794.  std 2,x
  795.  sta 4,x
  796.  bra rprt3
  797.  
  798.  pag
  799.  
  800. *
  801. * async
  802. *
  803. * Run a job async.
  804. *
  805.  
  806. async ldx #attab point to async table
  807. async2 ldd 0,x look for empty slot
  808.  beq async4
  809.  leax 9,x move to next entry
  810.  cmpx #atend
  811.  bne async2
  812.  ldd #2 set file desc
  813.  sys write,tmtms,TMTSZ output error
  814.  lbra pwait wait for task
  815. async4 puls d get task id
  816.  std 0,x save in table
  817.  clr 2,x set activity
  818.  pshs d,x save pos
  819.  sys time,asytim get current time
  820.  ldx 2,s reset pos
  821.  ldu #asytim point to time
  822.  ldd 0,u xfr time
  823.  std 5,x
  824.  ldd 2,u
  825.  std 7,x
  826.  puls d,x
  827.  bsr prtid print task id
  828.  ldd #1 set file desc
  829.  sys write,rtmsg,RTSZ
  830.  lbra sh0 goto main loop
  831.  
  832. *
  833. * prtid
  834. *
  835.  
  836. prtid ldx #idbuf+3 point to buffer
  837.  lbsr decstn convert to string
  838.  addd #3
  839.  std wrid2 save length
  840.  ldx #idbuf point to buffer
  841.  ldd #('*<<8)|'*
  842.  std 0,x
  843.  ldd #$2000|'T
  844.  std 2,x
  845.  ldd #1 set file desc
  846.  sys ind,wrid write out id
  847.  rts return
  848.  
  849. *
  850. * chasy
  851. *
  852. * Check for terminated async job.
  853. *
  854.  
  855. chasy ldy #attab point to async table
  856. chasy2 cmpd 0,y look for this guy
  857.  beq chasy4
  858.  leay 9,y move to next entry
  859.  cmpy #atend end of table?
  860.  bne chasy2
  861.  rts non found
  862. chasy4 stx 3,y save term status
  863.  inc 2,y set term stat
  864.  rts return
  865.  
  866.  pag
  867.  
  868. *
  869. * dpipe
  870. *
  871. * Create job as part of pipe
  872. *
  873.  
  874. dpipe tst pipmod in pipe?
  875.  beq dpipe2 if not, go ahead
  876.  ldd apprdf get read file
  877.  sys close close it
  878. dpipe2 inc pipmod set pipe mode
  879.  ldd pprdf get read file
  880.  std apprdf save it
  881.  ldd ppwrf get write file
  882.  sys close it
  883.  puls d get task id
  884.  lbra sh0 goto main
  885.  
  886. *
  887. * cpipe
  888. *
  889. * Create a pipe
  890. *
  891.  
  892. cpipe sys crpipe create it
  893.  bes cpipe2 error?
  894.  std pprdf save read file
  895.  stx ppwrf save write file
  896.  lbra sh95 go continue
  897. cpipe2 clr termc set null term
  898.  ldd #2 set error chan
  899.  sys write,nopms,NPSZ
  900.  lbra sh0 goto main
  901.  
  902.  pag
  903.  
  904. *
  905. * spipe
  906. *
  907. * Setup pipe io.
  908. *
  909.  
  910. spipe lda termc check for pipe
  911.  cmpa #'|
  912.  beq spipe2
  913.  cmpa #'^
  914.  bne spipe4
  915. spipe2 ldd #1 close standard output
  916.  sys close
  917.  ldd ppwrf get write file
  918.  sys dup make file 1
  919.  ldd ppwrf get write file
  920.  sys close close it
  921.  ldd pprdf get read file
  922.  sys close close it
  923. spipe4 tst pipmod in pipe mode?
  924.  beq spipe6
  925.  ldd #0 close standard input
  926.  sys close
  927.  ldd apprdf get read file
  928.  sys dup dup it
  929.  ldd apprdf get read file
  930.  sys close close it
  931. spipe6 rts return
  932.  
  933.  
  934.  pag
  935.  
  936. *
  937. * scmnd
  938. *
  939. * Check for shell command.  If it is, return
  940. * 'eq' and address of command in X.
  941. *
  942.  
  943. scmnd ldy #sctab point to command table
  944. scmnd1 ldx arglst point to arg
  945. scmnd2 lda 0,x+ get a character
  946.  beq scmnd6 term char?
  947.  tst 0,y end of command?
  948.  beq scmnd4
  949.  cmpa 0,y+ does it match?
  950.  beq scmnd2 if so, do next char
  951. scmnd4 tst 0,y+ find end of name
  952.  bne scmnd4
  953.  leay 2,y skip command address
  954.  cmpy #scend end of table?
  955.  bne scmnd1 if not, repeat
  956.  clz set no find status
  957.  rts return
  958. scmnd6 tst 0,y end of command?
  959.  bne scmnd4 if so, match!
  960.  ldx 1,y get address
  961.  sez set find status
  962.  rts return
  963.  
  964. *
  965. * chd
  966. *
  967. * Change dir command
  968. *
  969.  
  970. chd ldd arglst+2 get 2nd arg
  971.  bne chd1 default arg?
  972.  ldd #defdir point to home
  973. chd1 pshs d
  974.  lda #chdir set up command
  975.  pshs a
  976.  leax 0,s point to call data
  977.  sys indx do sys call
  978.  lbec rprt error?
  979.  ldd #2 set file desc
  980.  sys write,ccdrms,CCDSZ output error
  981.  lbra rprt goto main loop
  982.  
  983. *
  984. * login
  985. *
  986. * Log in command.
  987. *
  988.  
  989. login sys defacc,0 set default to 0
  990.  sys status,utnam,mfsb get status
  991.  ldd mfsb+11 get file size
  992.  beq login2 if 0 - single user mode
  993.  sys exec,logn,arglst exec login
  994. login2 sys term term if error
  995.  
  996.  pag
  997.  
  998. *
  999. * log
  1000. *
  1001. * log out command
  1002. *
  1003.  
  1004. log ldd #0 set term status
  1005.  sys term term shell
  1006.  
  1007. *
  1008. * wait
  1009. *
  1010. * Wait on asynch tasks.
  1011. *
  1012.  
  1013. cwait ldd #0
  1014.  std wtid set id to 0
  1015.  ldx arglst+2 get arg
  1016.  bne cwait6 is there one?
  1017.  ldx #attab point to task table
  1018. cwait1 ldd 0,x look for active tasks
  1019.  bne cwait2 found one?
  1020.  leax 9,x get next entry
  1021.  cmpx #atend end of table?
  1022.  bne cwait1
  1023.  ldd #1 set file desc
  1024.  sys write,nchms,NCHSZ output error meg
  1025.  lbra sh0 go to main loop
  1026. cwait2 sys cpint,2,ctwait set int trap
  1027.  ldx #attab point to task table
  1028. cwait3 ldd 0,x check for task
  1029.  beq cwait4
  1030.  tst 2,x has it termed?
  1031.  beq cwait5
  1032. cwait4 leax 9,x get next entry
  1033.  cmpx #atend end of table?
  1034.  bne cwait3
  1035. cwai45 sys cpint,2,1 ignore ints
  1036.  lbra rprt go report tasks termed
  1037. cwait5 sys wait wait for task
  1038.  lbsr chasy update task table
  1039.  ldx #attab point to table
  1040.  bra cwait3 repeat loop
  1041. cwait6 lbsr decvt convert task id
  1042.  bne cwai75 error?
  1043.  std wtid set id
  1044.  sys cpint,2,ctwait set ints
  1045.  ldd wtid get task id
  1046.  ldx #attab point to task table
  1047. cwait7 cmpd 0,x look for task id
  1048.  beq cwait8
  1049.  leax 9,x get next entry
  1050.  cmpx #atend end of table?
  1051.  bne cwait7
  1052. cwai75 ldd #1 set file desc
  1053.  sys write,ntfms,NTSZ output error
  1054.  lbra sh0
  1055. cwait8 tst 2,x task active?
  1056.  bne cwai45
  1057.  sys wait wait for it
  1058.  lbsr chasy update info
  1059.  ldx #attab point to task table
  1060.  ldd wtid get task id
  1061.  bra cwait7
  1062.  
  1063. *
  1064. * ctwait
  1065. *
  1066.  
  1067. ctwait sys cpint,2,1 ignore ints
  1068.  ldd #rprt set new pc
  1069.  std 10,s
  1070.  rti return (exit 'wait')
  1071.  
  1072.  pag
  1073.  
  1074. *
  1075. * jobs
  1076. *
  1077. * Output list of running tasks.
  1078. *
  1079.  
  1080. jobs clr 0,-s set counter to 0
  1081.  ldx #attab point to task table
  1082. jobs1 ldd 0,x get task number
  1083.  bne jobs4
  1084. jobs2 leax 9,x bump to next entry
  1085.  cmpx #atend end of table?
  1086.  bne jobs1
  1087.  ldb 0,s+ get task count
  1088.  bne jobs3
  1089.  ldd #1 output error
  1090.  sys write,nchms,NCHSZ
  1091. jobs3 lbra rprt goto main loop
  1092. jobs4 inc 0,s bump count
  1093.  pshs x save index
  1094.  lbsr prtid print task id
  1095.  ldd #1 set file desc
  1096.  sys write,ttmsg,TTMSZ output message
  1097.  ldx 0,s get table entry
  1098.  ldd 5,x get time
  1099.  std asytim save in block
  1100.  ldd 7,x
  1101.  std asytim+2
  1102.  ldx #asytim point to time block
  1103.  lbsr tmloc convert time
  1104.  lbsr tasc
  1105.  ldd #1 set file desc
  1106.  sys write,tstr,25 output time
  1107.  puls x
  1108.  bra jobs2 repeat
  1109.  
  1110. *
  1111. * dprm
  1112. *
  1113. * Set default permissions (command)
  1114. *
  1115.  
  1116. dprm clr slot clear out value
  1117.  ldu #arglst+2 set arg ptr
  1118. dprm2 ldx 0,u++ get an arg
  1119.  beq dprm5 end of args?
  1120.  ldd 0,x++ get 1st 2 chars of arg
  1121.  cmpb #'- check if valid
  1122.  bne dprm4
  1123.  bsr setp set up perms
  1124.  bne dprm2 error?
  1125. dprm4 lbsr synerr report syntax error
  1126.  lbra rprt go to main loop
  1127. dprm5 ldb slot get value
  1128.  stb isdp2 set in os call
  1129.  sys ind,isdp set perms
  1130.  lbra rprt exit
  1131.  
  1132. *
  1133. * setp
  1134. *
  1135. * Get the permission value
  1136. *
  1137.  
  1138. setp pshs a save type
  1139.  bsr getp get rwx bits
  1140.  puls a get type
  1141.  beq setp6 error?
  1142.  cmpa #'u is it user?
  1143.  beq setp3
  1144.  cmpa #'o is it other?
  1145.  bne setp6 if not - error
  1146. setp2 aslb shift bits to other pos
  1147.  aslb
  1148.  aslb
  1149. setp3 orb slot or in with others
  1150.  stb slot save new
  1151.  clz set status
  1152.  rts return
  1153. setp6 sez set error
  1154.  rts return
  1155.  
  1156. *
  1157. * getp
  1158. *
  1159. * Process the rwx args
  1160. *
  1161.  
  1162. getp clr 0,-s save mask
  1163. getp2 clrb set count
  1164.  lda 0,x+ get char of arg
  1165.  beq getp6 end of arg?
  1166.  incb set for r
  1167.  cmpa #'r is it r?
  1168.  beq getp4
  1169.  aslb set for w
  1170.  cmpa #'w is it w?
  1171.  beq getp4
  1172.  aslb set for x
  1173.  cmpa #'x is it x?
  1174.  bne getp7
  1175. getp4 orb 0,s or in new mask bit
  1176.  stb 0,s save it
  1177.  bra getp2
  1178. getp6 clz set status
  1179.  puls b,pc return
  1180. getp7 sez set error
  1181.  puls b,pc return
  1182.  
  1183. *
  1184. * wrtpr
  1185. *
  1186. * Output prompt line.
  1187. *
  1188.  
  1189. wrtpr tst tprfl time prompt?
  1190.  beq wrtpr2
  1191.  sys time,shtime get current time
  1192.  ldx #shtime point to time
  1193.  lbsr tmloc convert time
  1194.  lbsr tasc
  1195.  ldd #1 set file desc
  1196.  sys write,tstr,5 output time
  1197. wrtpr2 ldd #1 set file desc
  1198.  ldu iwrtp3 null string?
  1199.  beq wrtpr4
  1200.  sys ind,iwrtp output prompt
  1201. wrtpr4 rts return
  1202.  
  1203.  pag
  1204.  
  1205. *
  1206. * stprm
  1207. *
  1208. * Set prompt command.
  1209. *
  1210.  
  1211. stprm clr tprfl clear time mode
  1212.  ldx arglst+2 get arg
  1213.  beq stprm2 is it null?
  1214.  lda 0,x get 1st char
  1215.  cmpa #TPCH requesting time prompt?
  1216.  bne stprm4
  1217.  sta tprfl set flag
  1218.  leax 1,x eat the +
  1219.  bra stprm4
  1220. stprm1 std iwrtp3 set in call
  1221.  lbra rprt go to main loop
  1222. stprm2 ldd #prompt set up default prompt
  1223.  std iwrtp2
  1224.  ldd #3 set length
  1225.  bra stprm1
  1226. stprm4 clrb set count to 0
  1227.  ldy #prmbuf point to prompt buffer
  1228.  sty iwrtp2 set in call
  1229. stprm5 lda 0,x+ xfr new prompt
  1230.  sta 0,y+
  1231.  beq stprm6 end?
  1232.  incb bump count
  1233.  cmpb #24 max yet?
  1234.  bne stprm5
  1235.  decb
  1236. stprm6 clra
  1237.  bra stprm1
  1238.  
  1239.  pag
  1240.  
  1241. *
  1242. * bldpr
  1243. *
  1244. * Build the paren string for sub shell.
  1245. *
  1246.  
  1247. bldpr leax 1,x skip paren
  1248.  ldb #1 set flags
  1249.  stb prflg
  1250. bldpr2 lda 0,x+ get a character
  1251.  beq bldpr8 error?
  1252.  cmpa #$d is it cr?
  1253.  beq bldpr8 error?
  1254.  cmpa #') end of list?
  1255.  beq bldpr4
  1256.  cmpa #'( nesting parens?
  1257.  bne bldpr2
  1258.  incb bump nest count
  1259.  bra bldpr2 repeat
  1260. bldpr4 decb dec the nest count
  1261.  bne bldpr2 zero level?
  1262.  clr soft
  1263.  lda #SPACE set space term
  1264.  sta -1,x
  1265.  lbsr tsttrm test term char
  1266.  ldy bufpt get buffer start
  1267.  leay 1,y skip ')'
  1268.  sty subrg2 save arg ptr
  1269.  sty bsbrg2
  1270.  stx bufpt save new buf ptr
  1271.  rts return
  1272. bldpr8 lbsr synerr set error
  1273.  lbra sh0 goto main loop
  1274.  
  1275. *
  1276. * dosub
  1277. *
  1278. * Do the sub shell execution.
  1279. *
  1280.  
  1281. dosub lda termc check for background
  1282.  cmpa #'&
  1283.  bne dosub4
  1284.  sys exec,cshell,bsubrg exec the shell
  1285.  sys term error terminate
  1286. dosub4 sys exec,cshell,subrg exec the shell
  1287.  sys term
  1288.  
  1289.  pag
  1290.  
  1291. *
  1292. * cfile
  1293. *
  1294. * Close all files
  1295. *
  1296.  
  1297. cfile ldd #3 start with file 3
  1298.  pshs d save file desc
  1299. cfile2 sys close close the file
  1300.  ldd 0,s get fd
  1301.  addd #1 bump by 1
  1302.  std 0,s
  1303.  cmpd #NFILES end of files?
  1304.  bne cfile2
  1305.  puls d,pc return
  1306.  
  1307. *
  1308. * subst
  1309. *
  1310. * Substitute arguments
  1311. *
  1312.  
  1313. subst pshs y save arg pointer
  1314.  lda 0,y get character
  1315.  cmpa #'$ is it param?
  1316.  beq subst2
  1317. subst1 puls y,pc return
  1318. subst2 lda 1,y check 2nd char
  1319.  beq subst7 if null, exit
  1320.  leax 1,y point to number
  1321.  lbsr decvt convert to binary
  1322.  bne subst1
  1323.  cmpd #255 is it greater than 255?
  1324.  bhi subst1
  1325.  bra subst4
  1326. subst3 leas 2,s clean up stack
  1327.  rts return
  1328. subst4 ldx subpt get sub pointer
  1329.  beq subst3 is it null?
  1330.  pshs b
  1331. subst5 ldd 0,x check for null arg
  1332.  puls b
  1333.  beq subst3
  1334.  tstb found it?
  1335.  beq subst6 is this the one?
  1336.  leax 2,x bump to next
  1337.  decb dec the count
  1338.  pshs b
  1339.  bra subst5
  1340. subst6 ldy 0,x get arg pointer
  1341. subst7 leas 2,s fix stack
  1342.  clz set status
  1343.  rts return
  1344.  
  1345. *
  1346. * abtrm
  1347. *
  1348. * Report abnormal termination of tasks.
  1349. *
  1350.  
  1351. abtrm lda ctrm get term status
  1352.  bne abtrm2 is it abnormal
  1353.  rts if not - return
  1354. abtrm2 ldy #comnd point to buffer
  1355.  ldb #$d set up cr
  1356.  stb 0,y+ set in buffer
  1357.  ldb #1 set count to 1
  1358.  bra ptmsg1
  1359.  
  1360. *
  1361. * ptmsg
  1362. *
  1363. * Print termination message.
  1364. *
  1365.  
  1366. ptmsg ldy #comnd point to out buffer
  1367.  clrb set count to 0
  1368. ptmsg1 pshs a save status
  1369.  asla
  1370.  ldx #tmstb point to message table
  1371.  ldx a,x get message pointer
  1372. ptmsg2 lda 0,x+ get a char
  1373.  incb bump the count
  1374.  sta 0,y+ save the char
  1375.  bne ptmsg2 repeat til null
  1376.  lda 0,s+ get status
  1377.  bpl ptmsg6 core dumped?
  1378.  decb back up count
  1379.  leay -1,y
  1380.  ldx #crdms point to 'core dump' message
  1381. ptmsg4 lda 0,x+ move the string
  1382.  incb
  1383.  sta 0,y+
  1384.  bne ptmsg4
  1385. ptmsg6 lda #$d get cr
  1386.  sta -1,y set at end of list
  1387.  clra
  1388.  std iwrt2 set write count
  1389.  ldd #1 set file desc
  1390.  sys ind,iwrt output string
  1391.  rts return
  1392.  
  1393.  pag
  1394.  
  1395. *
  1396. * decvt
  1397. *
  1398. * Decimal convert routine.  Convert ascii string
  1399. * pointed at by x and null terminated.
  1400. * Return number in D and ne if error.
  1401. *
  1402.  
  1403. decvt ldd #0 set up zero
  1404.  pshs d
  1405. decvt2 lda 0,x+ get character
  1406.  beq decvt4 end of list?
  1407.  cmpa #'0 check for valid number
  1408.  blo decvt3 error?
  1409.  cmpa #'9
  1410.  bhi decvt3
  1411.  anda #$F mask character
  1412.  pshs a save digit
  1413.  ldd 1,s get number
  1414.  aslb multiply by 8
  1415.  rola
  1416.  aslb
  1417.  rola
  1418.  aslb
  1419.  rola
  1420.  addd 1,s add in original twice
  1421.  addd 1,s
  1422.  addb 0,s+ add in new digit
  1423.  adca #0
  1424.  std 0,s save result
  1425.  bra decvt2 repeat
  1426. decvt3 clz set error
  1427. decvt4 puls d,pc return
  1428.  
  1429.  pag
  1430.  
  1431. *
  1432. * decst
  1433. *
  1434. * Convert the number in D into an ascii string
  1435. * representing a decimal number.  The string
  1436. * is pointed at by X (X should be set on entry!)
  1437. * Also on exit, D has the length of the string.
  1438. * The second entry point, 'decstn' will not print
  1439. * leading spaces for leading zeroes, but will
  1440. * suppress all leading zero info.  All strings
  1441. * start with a space.
  1442. *
  1443.  
  1444. decst pshs x save user pointer
  1445.  clr 0,-s set suppression flag
  1446.  bra decst2
  1447. *
  1448. decstn pshs x save user pointer
  1449.  clr 0,-s
  1450.  inc 0,s set for no fielding
  1451. decst2 pshs a
  1452.  lda #$20 setup leading space
  1453.  sta 0,x+ save in buffer
  1454.  puls a
  1455.  clr 0,-s set up bookkeeping
  1456.  clr 0,-s
  1457.  ldy #conlst point to constants
  1458. decst4 cmpd 0,y compare number to constant
  1459.  blo decst5
  1460.  subd 0,y do subtraction of constant
  1461.  inc 1,s bump digits counter
  1462.  bra decst4
  1463. decst5 pshs a save number
  1464.  tst 2,s zero digit?
  1465.  bne decst6
  1466.  tst 1,s any numbers output yet?
  1467.  bne decst6
  1468.  tst 3,s doing suppression?
  1469.  bne decst8
  1470.  lda #$20 set up space
  1471.  bra decst7
  1472. decst6 lda 2,s get digit count
  1473.  inc 1,s set 'got one' flag
  1474.  ora #$30 make ascii
  1475. decst7 sta 0,x+ save in buffer
  1476. decst8 puls a reset number
  1477.  clr 1,s clear out digit
  1478.  leay 2,y bump constant ptr
  1479.  cmpy #conend end of list?
  1480.  bne decst4
  1481.  leas 3,s clean up stack
  1482.  orb #$30 make last digit
  1483.  stb 0,x+ save in buffer
  1484.  clr 0,x null terminate string
  1485.  tfr x,d
  1486.  subd 0,s calculate string length
  1487.  puls x,pc return
  1488.  
  1489. * constants for convert
  1490.  
  1491. conlst fdb 10000
  1492.  fdb 1000
  1493.  fdb 100
  1494.  fdb 10
  1495. conend equ * end of list
  1496.  
  1497.  pag
  1498.  
  1499. *
  1500. * marg
  1501. *
  1502. * Check dor match list processing
  1503. *
  1504.  
  1505. marg tfr y,x get arg pointer
  1506.  tst quote quotes arg?
  1507.  bne marg9 if so - skip
  1508.  tst prflg paren command?
  1509.  bne marg9
  1510.  bsr sum do set up for match
  1511.  bes marg9 error?
  1512.  ldx argpt get arg pointer
  1513.  leax -2,x back up
  1514.  stx argpt
  1515.  stx starg save start arg
  1516.  lbsr opnmf open match file
  1517.  bes marg8 error?
  1518. marg4 lbsr cmntr compare names
  1519.  bes marg7 end of lists?
  1520.  bne marg4 match?
  1521.  inc mone set matched one flag
  1522.  ldx fstpt get string pointer
  1523.  ldu argpt get arg pointer
  1524.  stx 0,u++ save new arg
  1525.  stu argpt
  1526.  ldu #front get front part
  1527.  ldy #tstbuf+2 point to string
  1528. marg6 lda 0,u+ get char
  1529.  beq marg65 null?
  1530.  sta 0,x+ move it
  1531.  bra marg6
  1532. marg65 lda 0,y+ get a character
  1533.  sta 0,x+ move the character
  1534.  bne marg65 end of arg?
  1535.  stx fstpt save string pointer
  1536.  bra marg4 repeat
  1537. marg7 ldd mffd get file desc
  1538.  sys close close the file
  1539.  tst mone any matches?
  1540.  beq marg8
  1541.  ldd #0 set null arg pointer
  1542.  std [argpt]
  1543.  ldx starg get starting arg pos
  1544.  lbra sort go sort args & return
  1545. marg8 ldx argpt fix up arg ptr
  1546.  leax 2,x
  1547.  stx argpt
  1548. marg9 rts return
  1549.  
  1550.  pag
  1551.  
  1552. *
  1553. * sum
  1554. *
  1555. * Setup for match tests.
  1556. *
  1557.  
  1558. sum clr mone
  1559.  ldy #front point to front name buffer
  1560. sum2 lda 0,x+ get a character
  1561.  sta 0,y+ move to front buf
  1562.  beq sum6 end of string?
  1563.  cmpa #'* check for match char
  1564.  beq sum3
  1565.  cmpa #'?
  1566.  beq sum3
  1567.  cmpa #'[
  1568.  bne sum2
  1569. sum3 lda -1,y move back thru string
  1570.  cmpa #'/ look for '/'
  1571.  beq sum4
  1572.  leay -1,y
  1573.  leax -1,x
  1574.  cmpy #front or beginning of string
  1575.  bne sum3
  1576. sum4 clr 0,y set term char
  1577.  stx mtpt set match pointer
  1578. sum5 lda 0,x+ look at rest of string
  1579.  beq sum7 end?
  1580.  cmpa #'/ is it '/'?
  1581.  bne sum5
  1582. sum6 sec set error
  1583.  rts return
  1584. sum7 clc set ok status
  1585.  rts return
  1586.  
  1587.  pag
  1588.  
  1589. *
  1590. * opnmf
  1591. *
  1592. * Open match file.
  1593. *
  1594.  
  1595. opnmf sys open,front,0 open the file for read
  1596.  bes opnmf4 error?
  1597.  std mffd save file desc
  1598.  sys ofstat,mfsb get status
  1599.  lda mfsb+4 get mode byte
  1600.  bita #$8 is it dir?
  1601.  beq opnmf2 if not - error
  1602.  clc
  1603.  rts return
  1604. opnmf2 ldd mffd get fd
  1605.  sys close close the file
  1606. opnmf4 sec set error
  1607.  rts return
  1608.  
  1609. *
  1610. * cmntr
  1611. *
  1612. * Compare names for match test.  Return 'eq'
  1613. * if match, 'cs' if error or no more names.
  1614. *
  1615.  
  1616. cmntr ldd mffd get file desc
  1617.  sys read,tstbuf,16 read entry
  1618.  bes cmntr4 error?
  1619.  cmpd #0 eof?
  1620.  beq cmntr4
  1621.  clr tstbuf+16 set null term
  1622.  ldd tstbuf check for deleted entry
  1623.  beq cmntr repeat
  1624.  ldx mtpt get match string
  1625.  ldy #tstbuf+2 point to test name
  1626.  lda 0,y get 1st char
  1627.  cmpa #'. is it '.'?
  1628.  bne cmntr2
  1629.  leay 1,y skip char
  1630.  cmpa 0,x+ must match!
  1631.  bne cmntr3
  1632. cmntr2 bsr match do match test
  1633. cmntr3 clc set ok status
  1634.  rts return
  1635. cmntr4 sec set error
  1636.  rts return
  1637.  
  1638.  pag
  1639.  
  1640. *
  1641. * match
  1642. *
  1643. * See if the match string pointed at by X matches
  1644. * the string pointed at by Y.  Return 'eq' if
  1645. * they match.  This routine handles the following
  1646. * special match characters: *, ?, [...].
  1647. *
  1648.  
  1649. match pshs x,y save pointers
  1650. match1 lda 0,x+ get character
  1651.  beq match2 end of string?
  1652.  cmpa #'* is it star?
  1653.  beq mstar
  1654.  tst 0,y end of test string?
  1655.  beq match3
  1656.  cmpa #'? is it '?'
  1657.  beq mqust
  1658.  cmpa #'[ is it '[...]' ?
  1659.  beq mspcl
  1660.  cmpa 0,y+ compare characters
  1661.  beq match1 if match, repeat!
  1662.  puls x,y,pc return - no match
  1663. match2 tst 0,y end of test string?
  1664.  puls x,y,pc if so - match!
  1665. match3 clz set no match
  1666. match4 puls x,y,pc return
  1667.  
  1668. * match question mark
  1669.  
  1670. mqust leay 1,y anything matches!
  1671.  bra match1 repeat
  1672.  
  1673. * match start ('*')
  1674.  
  1675. mstar tst 0,x end of match string?
  1676.  beq match4 if so - match!
  1677. mstar2 tst 0,y end of string?
  1678.  beq match3 if so - no match
  1679.  bsr match check reset of string
  1680.  beq match4 if 'eq' - match!
  1681.  leay 1,y skip a character
  1682.  bra mstar2 repeat
  1683.  
  1684.  pag
  1685.  
  1686. * match special list '[...]'
  1687.  
  1688. mspcl ldb 0,y+ get a character
  1689. mspcl2 lda 0,x+ get match char
  1690.  beq match3 if end - no match
  1691.  cmpa #'] end of special?
  1692.  beq match3 if so - no match
  1693.  cmpa #'- is it sep char?
  1694.  beq mspcl5
  1695.  cmpb -1,x compare the characters
  1696.  bne mspcl2 if no match - repeat
  1697. mspcl4 lda 0,x+ look for ']'
  1698.  beq match3 if null - no match!
  1699.  cmpa #']
  1700.  bne mspcl4
  1701.  bra match1 we have a match!
  1702. mspcl5 cmpb -2,x check 1st char in range (1-2)
  1703.  blo mspcl6 if lower, not here
  1704.  cmpb 0,x check 2nd char of range
  1705.  bls mspcl4 if 'ls' - match!
  1706. mspcl6 leax 1,x skip range char
  1707.  bra mspcl2 repeat
  1708.  
  1709.  pag
  1710.  
  1711. *
  1712. * sort routine
  1713. *
  1714. * General sort routine should be called with pointer
  1715. * to a list of pointers stored in X.  List is terminated
  1716. * by two zero bytes.  Each pointer in list points to
  1717. * a string which is terminated by a zero byte.
  1718. * On return, pointers in list are rearranged and all
  1719. * registers are destroyed.
  1720. *
  1721.  
  1722. sort ldd 0,x check first entry
  1723.  beq sort9 exit if null list
  1724.  ldd #$FFFF default end of list
  1725.  pshs x,d save begin and end
  1726.  leas -1,s did an exchange flag
  1727. sort1 ldx 3,s get begin of list
  1728.  clr 0,s show no exchange
  1729. sort2 ldd 2,x another entry?
  1730.  beq sort6 finished pass if not
  1731.  leay 2,x end of pass?
  1732.  cmpy 1,s
  1733.  beq sort6 skip if so
  1734. * compare current and next entry
  1735.  ldy 0,x get pointer to 1st
  1736.  ldu 2,x get pointer to 2nd
  1737. sort3 lda 0,y+ get char. from 1st
  1738.  beq sort5 no exchange if terminator
  1739.  ldb 0,u get char. from 2nd
  1740.  beq sort4 do exchange if terminator
  1741.  cmpa 0,u+ else, compare characters
  1742.  beq sort3 loop if equal
  1743.  blo sort5 skip if no exchange
  1744. * exchange two entries
  1745. sort4 ldy 2,x get 2nd entry
  1746.  ldd 0,x get 1st entry
  1747.  std 2,x swap them
  1748.  sty 0,x
  1749.  lda #1
  1750.  sta 0,s show exchange done
  1751. * do next two entries
  1752. sort5 leax 2,x bump current pointer
  1753.  bra sort2
  1754. * finished pass, see if another required
  1755. sort6 stx 1,s save new end pointer
  1756.  tst 0,s any exchanges in pass?
  1757.  bne sort1 another pass required
  1758. sort8 leas 5,s fix stack
  1759. sort9 rts
  1760.  
  1761.  pag
  1762.  
  1763. *
  1764. * tmloc
  1765. *
  1766. * Convert time pointed at by x to vector time (local).
  1767. *
  1768.  
  1769. tmloc ldd 0,x get time
  1770.  std ltime
  1771.  ldd 2,x
  1772.  std ltime+2
  1773.  lda 7,x get day light savings flag
  1774.  sta dlflg
  1775.  clr eutc init flag
  1776.  ldd 5,x get time zone
  1777.  bpl tmloc2 west of GMT?
  1778.  inc eutc if not - set flag
  1779.  coma and make pos number
  1780.  comb
  1781.  addd #1
  1782. tmloc2 std r0+2 save time zone
  1783.  ldd #60 calculate zone seconds
  1784.  std r1+2
  1785.  ldd #0 set hi bytes to 0
  1786.  std r0
  1787.  std r1
  1788.  lbsr lmul calculate time zone seconds
  1789.  ldd r0 get result
  1790.  std tzn save it
  1791.  ldd r0+2
  1792.  std tzn+2
  1793.  lbsr adjtim adjust time for zone
  1794.  ldx #ltime point to time
  1795.  lbsr tmutc convert to vector
  1796.  tst dlflg do dlst?
  1797.  beq tmloc6
  1798.  lbsr chkdl in dlst?
  1799.  bne tmloc6
  1800. tmloc5 ldd #3600 adjust for dlst
  1801.  addd ltime+2
  1802.  std ltime+2
  1803.  ldd ltime
  1804.  adcb #0
  1805.  adca #0
  1806.  std ltime
  1807.  ldx #ltime point to time
  1808.  lbsr tmutc convert to vector
  1809.  inc daylit set daylit flag
  1810. tmloc6 ldx #second point to vector
  1811.  rts return
  1812.  
  1813.  pag
  1814.  
  1815. *
  1816. * tmutc
  1817. *
  1818. * Convert the internal system time (4 bytes
  1819. * pointed at by X on entry) to an 18 byte
  1820. * vector representing the broken down time.
  1821. * The time in this form is UTC (Universal
  1822. * Coordinated Time).
  1823. *
  1824.  
  1825. tmutc ldd #0 set daylight savings word
  1826.  std daylit
  1827.  ldd 0,x get hi word of time
  1828.  std r0 save ir divide register
  1829.  ldd 2,x get lo word of time
  1830.  std r0+2
  1831.  ldd #60*60 seconds*minutes constant
  1832.  std r1 set up for divide
  1833.  lbsr ldiv min*sec=time % 3600
  1834.  ldd work hour*day=time / 3600
  1835.  pshs d save min*sec
  1836.  ldd #24 set up hours per day constant
  1837.  std r1
  1838.  lbsr ldiv hours= (hour*day) % 24
  1839.  ldd work day= (hour*day) / 24
  1840.  std hours set hours word
  1841.  ldd r0+2 get day number
  1842.  std day save the day
  1843.  addd #2 add in day bias (Jan 1 80 => Tue)
  1844.  std r0 set up for divide
  1845.  ldb #7 days per week constant
  1846.  stb r1
  1847.  lbsr div wday=(day+2) % 7
  1848.  ldb work get result
  1849.  clra make into word
  1850.  std wday set week day
  1851.  puls d get min*sec
  1852.  std r0 set up for divide
  1853.  ldb #60 seconds per minute
  1854.  stb r1
  1855.  lbsr div seconds= (min*sec) % 60
  1856.  ldb work minutes= (min*sec) / 60
  1857.  clra
  1858.  std second set seconds word
  1859.  ldd r0 get minutes
  1860.  std minute save it
  1861.  
  1862.  pag
  1863.  
  1864. * continue tutc for year and month data
  1865.  
  1866.  clr 0,-s clear year counter
  1867. tutc2 ldx #ylen point to year length table
  1868.  lda 0,s get year number
  1869.  bita #$3 is it leap year?
  1870.  bne tutc3
  1871.  leax 2,x if so, move to long year value
  1872. tutc3 ldd day get day number
  1873.  cmpd 0,x day in current year?
  1874.  blo tutc4 if 'lt' - we got the year!
  1875.  subd 0,x subtract off years days
  1876.  std day save new day count
  1877.  inc 0,s bump the year count
  1878.  bra tutc2 repeat
  1879. tutc4 std yday set day of year word
  1880.  puls b get year count
  1881.  addb #80 add to '1980'
  1882.  clra make 16 bits long
  1883.  std year save the year
  1884.  bitb #$3 is it leap year?
  1885.  bne tutc5
  1886.  ldd #29 if so, set Feb day count to 29
  1887.  std mdays+2
  1888. tutc5 ldx #mdays point to month-day table
  1889.  clr 0,-s set month count to zero
  1890.  ldd yday get day of the year
  1891. tutc6 cmpd 0,x in the month?
  1892.  blo tutc7 if 'lt' - we got the month!
  1893.  inc 0,s bump the month counter
  1894.  subd 0,x++ subtract of this month's days
  1895.  bra tutc6
  1896. tutc7 addd #1 add 1 to month day (day 1 is 1 - not 0!)
  1897.  std mday save the month day
  1898.  puls b get the month
  1899.  std month save it
  1900.  ldd #28 reset month - day table
  1901.  std mdays+2
  1902.  rts return
  1903.  
  1904.  pag
  1905.  
  1906. *
  1907. * chkdl
  1908. *
  1909. * Check if in dlst - return 'eq' if so.
  1910. *
  1911.  
  1912. chkdl ldd #119 check for last Sun in Apr
  1913.  bsr fixtim
  1914.  std fstdl first day of dlst
  1915.  ldd #303 last Sun in Oct
  1916.  bsr fixtim
  1917.  std lstdl last day of dlst
  1918.  ldd yday get day of year
  1919.  cmpd fstdl up to 1st day yet?
  1920.  blo chkdl6
  1921.  bhi chkdl4
  1922.  ldd hours on the 1st day - so
  1923.  cmpd #2 is it 2:00 AM yet?
  1924.  blo chkdl6
  1925.  bra chkdl5
  1926. chkdl4 ldd yday get day of year
  1927.  cmpd lstdl past last day of dlst?
  1928.  bhi chkdl6
  1929.  blo chkdl5
  1930.  ldd hours on the last day - so
  1931.  cmpd #1 is it 1:00 AM yet?
  1932.  bhs chkdl6
  1933. chkdl5 sez we are in dlst!
  1934.  rts return
  1935. chkdl6 clz not in dlst
  1936.  rts return
  1937.  
  1938.  pag
  1939.  
  1940. *
  1941. * adjtim
  1942. *
  1943. * Adjust time for time zone.
  1944. *
  1945.  
  1946. adjtim ldd ltime+2 get time
  1947.  tst eutc east of UTC?
  1948.  bne adjti2
  1949.  subd r0+2 subtract time zone minutes
  1950.  std ltime+2
  1951.  ldd ltime get hi part
  1952.  sbcb r0+1
  1953.  sbca r0
  1954.  bra adjti4
  1955. adjti2 addd r0+2 add in minutes
  1956.  std ltime+2
  1957.  ldd ltime
  1958.  adcb r0+1
  1959.  adca r0
  1960. adjti4 std ltime save new time
  1961. adjti5 rts return
  1962.  
  1963. *
  1964. * fixtim
  1965. *
  1966. * Return the closest day to the date in D
  1967. * which is a Sunday.
  1968. *
  1969.  
  1970. fixtim pshs d save day number
  1971.  ldd year get year
  1972.  bitb #$3 is it leap year?
  1973.  puls d
  1974.  bne fixti2
  1975.  addd #1 if so - bump day number
  1976. fixti2 pshs d save day number
  1977.  addd #420 add in 420 so no negatives result
  1978.  addd wday add in day of week
  1979.  subd yday subtract day of year
  1980.  std r0 save result
  1981.  ldb #7
  1982.  stb r1 set up for divide
  1983.  lbsr div do: (day+420+wday-yday) % 7
  1984.  puls d get day number
  1985.  subb work
  1986.  sbca #0
  1987.  rts return day in d
  1988.  
  1989.  pag
  1990.  
  1991. *
  1992. * Divide routines for time conversion use.  'Ldiv'
  1993. * divides a 32 bit number (r0 -> r0+3) by a 16 bit
  1994. * number (r1 -> r1+1) and produces a 32 bit result
  1995. * in r0 and a 16 bit remainder in 'work'.  'Div'
  1996. * divides a 16 bit number (r0 -> r0+1) by an 8 bit
  1997. * number (r1) and produces a 16 bit result (r0)
  1998. * and an 8 bit remainder (work).
  1999. *
  2000.  
  2001. div lda #17 set up loop counter
  2002.  clrb do initialize
  2003.  stb work
  2004.  bra div2
  2005. div1 ldb work
  2006.  subb r1 do subtraction
  2007.  bcs div2 s3et new work?
  2008.  stb work yes!
  2009. div2 rol r0+1 do shift left
  2010.  rol r0
  2011.  rol work
  2012.  deca dec the loop count
  2013.  bne div1 repeat?
  2014.  com r0 fix up result
  2015.  com r0+1
  2016.  lsr work fix remainder
  2017.  rts
  2018.  
  2019.  
  2020.  pag
  2021.  
  2022. *
  2023. * Long divide
  2024. *
  2025.  
  2026. ldiv ldb #33 set loop counter
  2027.  pshs b
  2028.  ldd #0 do init
  2029.  std work
  2030.  bra ldiv2
  2031. ldiv1 ldd work do subtraction
  2032.  subd r1
  2033.  bcs ldiv2 work > r1 ?
  2034.  std work set new work value
  2035. ldiv2 rol r0+3 do shifting
  2036.  rol r0+2
  2037.  rol r0+1
  2038.  rol r0
  2039.  rol work+1
  2040.  rol work
  2041.  dec 0,s dec the loop count
  2042.  bne ldiv1
  2043.  com r0 compliment the result
  2044.  com r0+1
  2045.  com r0+2
  2046.  com r0+3
  2047.  lsr work adjust the remainder
  2048.  ror work+1
  2049.  puls b,pc return
  2050.  
  2051.  pag
  2052.  
  2053. *
  2054. * lmul
  2055. *
  2056. * Long multiply - 32 bits (r0) X 32 bits (r1).
  2057. * Result is in r0.
  2058. *
  2059.  
  2060. lmul ldb #32 set loop count
  2061.  pshs b
  2062.  ldd #0 init variables
  2063.  std work
  2064.  std work+2
  2065.  lsr r0 do initial shift
  2066.  ror r0+1
  2067.  ror r0+2
  2068.  ror r0+3
  2069. lmul1 bcc lmul2 need to add?
  2070.  ldd work+2
  2071.  addd r1+2
  2072.  std work+2
  2073.  ldd work
  2074.  adcb r1+1
  2075.  adca r1
  2076.  std work save result
  2077. lmul2 ror work do shifting
  2078.  ror work+1
  2079.  ror work+2
  2080.  ror work+3
  2081.  ror r0
  2082.  ror r0+1
  2083.  ror r0+2
  2084.  ror r0+3
  2085.  dec 0,s dec the loop count
  2086.  bne lmul1 repeat?
  2087.  puls b,pc return
  2088.  
  2089.  pag
  2090.  
  2091. *
  2092. * tasc
  2093. *
  2094. * Convert the time vector data (18 bytes) pointed
  2095. * at by x into an ascii string.  Return x pointing
  2096. * to the string.
  2097. *
  2098.  
  2099. tasc tfr x,u save vector pointer
  2100.  ldx #tstr point to string
  2101.  ldd 4,u get hours
  2102.  lbsr cvt convert to ascii
  2103.  leax 1,x skip the ':'
  2104.  ldd 2,u get minutes
  2105.  lbsr cvt convert to ascii
  2106.  leax 1,x skip the ':'
  2107.  ldd 0,u get seconds
  2108.  lbsr cvt convert to ascii
  2109.  leax 1,x skip space
  2110.  ldd 6,u get day of week
  2111.  ldy #dtab point to day table
  2112.  bsr tasxfr xfr to string
  2113.  ldd 10,u get month
  2114.  ldy #mtab point to month table
  2115.  bsr tasxfr xfr to string
  2116.  ldd 8,u get month day
  2117.  bsr cvt convert to ascii
  2118.  leax 1,x
  2119.  ldd #('1<<8)|'9 set up '19'
  2120.  std 0,x save in string
  2121.  ldd 12,u get year
  2122.  cmpd #100 >100 (year 2000 yet?)
  2123.  blo tasc4
  2124.  subd #100 remove bias
  2125.  pshs d save year
  2126.  ldd #('2<<8)|'0 set up '20'
  2127.  std 0,x set in string
  2128.  puls d reset year
  2129. tasc4 leax 2,x
  2130.  bsr cvt convert year to ascii
  2131.  ldx #tstr point to string
  2132.  rts return
  2133.  
  2134.  pag
  2135.  
  2136. *
  2137. * tasxfr
  2138. *
  2139. * Transfer the 3 bytes of ascii indexed by b
  2140. * at y to location pointed at by x.
  2141. *
  2142.  
  2143. tasxfr pshs b index * 3
  2144.  aslb
  2145.  addb 0,s+
  2146.  leay b,y point to indexed data
  2147.  ldd 0,y xfr the data to x
  2148.  std 0,x++
  2149.  lda 2,y
  2150.  sta 0,x
  2151.  leax 2,x bump string pointer
  2152.  rts return
  2153.  
  2154. *
  2155. * cvt
  2156. *
  2157. * Convert number in b to ascii at x.
  2158. *
  2159.  
  2160. cvt lda #'0 set ascii 0
  2161. cvt2 cmpb #10 >10?
  2162.  blo cvt4
  2163.  subb #10 subtract off 10
  2164.  inca bump ascii
  2165.  bra cvt2 repeat
  2166. cvt4 addb #'0 make 1's ascii
  2167.  std 0,x++ save ascii at x
  2168.  rts return
  2169.  
  2170.  pag
  2171.  
  2172.  if *>$1000
  2173.  err Text Overflow into Data!
  2174.  endif
  2175.  
  2176.  ifc &a,"notext"
  2177.  org $1000
  2178.  else
  2179.  data $1000
  2180.  endif
  2181.  
  2182. *
  2183. * Shell data section
  2184. *
  2185.  
  2186. prompt fcc '++ '
  2187. PRSIZ equ *-prompt size of prompt
  2188. bdfms fcc "Can't open I/O file.",$d
  2189. BDSIZ equ *-bdfms
  2190. ermsg1 fcc "Can't execute '"
  2191. ERSIZ1 equ *-ermsg1
  2192. ermsg2 fcc "'",$d
  2193. ERSIZ2 equ *-ermsg2
  2194. syrms fcc 'Syntax error.',$d
  2195. SYSIZ equ *-syrms
  2196. ccdrms fcc "Can't change directories.",$d
  2197. CCDSZ equ *-ccdrms
  2198. ntfms fcc 'No such task.',$d
  2199. NTSZ equ *-ntfms
  2200. rtmsg fcc ' running.',$d
  2201. RTSZ equ *-rtmsg
  2202. ttmsg fcc ' - '
  2203. TTMSZ equ *-ttmsg
  2204. tmtms fcc 'Too many tasks ... waiting!',$d
  2205. TMTSZ equ *-tmtms
  2206. nopms fcc "Can't create pipe",$d
  2207. NPSZ equ *-nopms
  2208. nchms fcc 'No tasks active.',$d
  2209. NCHSZ equ *-nchms
  2210. frkmsg fcc "Can't fork task.",$d
  2211. FRKSIZ equ *-frkmsg
  2212. crdms fcc ' (Core dumped)',0
  2213. utnam fcc '/act/utmp',0
  2214. nldst fcc '/dev/null',0
  2215. hmfl fcc '.home?',0
  2216. cshell fcc '/bin/shell',0
  2217. carg fdb cshln,cstrt,0
  2218. cshln fcc 'shell',0
  2219. cstrt fcc '.startup',0
  2220. cptst fcc '+c',0
  2221. bcptst fcc '+bc',0
  2222. cbasic fcc '/bin/basic',0
  2223. Pscl0 fcc '/bin/nrun',0 ***GDT
  2224. Pscl1 fcc '/bin/sys_rt',0 ***GDT
  2225. logn fcc '/etc/login',0
  2226. logr fdb 0
  2227. plbst fcc '+b',0
  2228. tmstb fdb tm0,tm1,tm2,tm3,tm4,tm5
  2229.  fdb tm6,tm7,tm8,tm9,tm10,tm11,tm12
  2230. tm0 fcc 'Ended.',0
  2231. tm1 fcc 'Hangup.',0
  2232. tm2 fcc 'INTERRUPT!',0
  2233. tm3 fcc 'Quit.',0
  2234. tm4 fcc 'EMT trap.',0
  2235. tm5 fcc 'Killed.',0
  2236. tm6 fcc 'Pipe.',0
  2237. tm7 fcc 'Argument.',0
  2238. tm8 fcc 'Trace.',0
  2239. tm9 fcc 'Time limit.',0
  2240. tm10 fcc 'Alarm.',0
  2241. tm11 fcc 'Terminated.',0
  2242. tm12 fcc 'Interrupt #12.',0
  2243.  
  2244. ylen fdb 365 year length
  2245.  fdb 366 leap year
  2246.  
  2247. mdays fdb 31,28,31,30,31,30,31,31,30,31,30,31
  2248.  
  2249.  
  2250. tstr fcc 'xx:xx:xx xxx xxx xx xxxx',$d,0
  2251.  
  2252. dtab fcc 'SunMonTueWedThuFriSat'
  2253.  
  2254. mtab fcc 'JanFebMarAprMayJunJulAugSepOctNovDec'
  2255.  
  2256. second fdb 0 seconds (0-59)
  2257. minute fdb 0 minutes (0-59)
  2258. hours fdb 0 hours (0-23)
  2259. wday fdb 0 week day (0-6) 0=Sunday
  2260. mday fdb 0 month day (1-31)
  2261. month fdb 0 month (0-11)
  2262. year fdb 0 year (80+)
  2263. yday fdb 0 day of year (0-355)
  2264. daylit fdb 0 daylight savings flag
  2265.  
  2266.  
  2267. r0 fdb 0,0 regs for div and mul
  2268. r1 fdb 0,0
  2269. work fdb 0,0
  2270. day fdb 0 day temp
  2271. ntime fdb 0,0 new time
  2272. eutc fcb 0 east of utc flag
  2273. fstdl fdb 0 1st day of dlst
  2274. lstdl fdb 0 last day of dlst
  2275. dlflg fcb 0 dlst flag
  2276. ltime fdb 0,0 local time
  2277. tzn fdb 0,0 time zone seconds
  2278.  
  2279.  
  2280. * command table
  2281.  
  2282. sctab fcc 'chd',0
  2283.  fdb chd
  2284.  fcc 'login',0
  2285.  fdb login
  2286.  fcc 'log',0
  2287.  fdb log
  2288.  fcc 'wait',0
  2289.  fdb cwait
  2290.  fcc 'prompt',0
  2291.  fdb stprm
  2292.  fcc 'jobs',0
  2293.  fdb jobs
  2294.  fcc 'dperm',0
  2295.  fdb dprm
  2296. scend equ * end of table
  2297.  
  2298. subrg fdb cshln,cptst
  2299. subrg2 fdb 0,0
  2300. bsubrg fdb cshln,bcptst
  2301. bsbrg2 fdb 0,0
  2302. syntid fdb 0 sync task id
  2303. termc fcb 0 term character
  2304. soft fcb 0 soft term flag
  2305. ctrm fdb 0 termination status
  2306. intflg fcb 0 interactive mode flag
  2307. coptf fcb 0 c option flag
  2308. rtcnt fcb 0 retry counter
  2309. sp fdb 0 stack pointer
  2310. subpt fdb 0 subs pointer
  2311. prflg fcb 0 paren flag
  2312. pipmod fcb 0 pipe mode flag
  2313. pprdf fdb 0 pipe read file
  2314. ppwrf fdb 0 pipe write file
  2315. apprdf fdb 0 actual pipe read file
  2316. starg fdb 0 starting arg for sort
  2317. quote fcb 0 quoted string flag
  2318. slot fcb 0 default perm value
  2319. mone fcb 0 match flag
  2320. mffd fdb 0 match file desc
  2321. mtpt fdb 0 match pointer
  2322. fstpt fdb 0 final arg pointer
  2323. cbpt fdb 0 command line pointer
  2324. smbuf fdb 0 small buffer
  2325. tprfl fcb 0 time prompt flag
  2326. linpt fdb 0 line pointer
  2327. linend fdb 0 buffer end
  2328. bufpt fdb 0 buffer pointer
  2329. argpt fdb 0 argument pointer
  2330. sifil fdb 0 input file
  2331. sofil fdb 0 output file
  2332. safil fdb 0 append file
  2333. ttgbuf fdb 0,0,0 ttyget buffer
  2334. shtime fdb 0,0,0,0 shell time buffer
  2335. asytim fdb 0,0,0,0 task time
  2336. tmpfd fdb 0 temp file desc
  2337. bgop fcb 0 background option flag
  2338. supf fcb 0 startup flag
  2339. wtid fdb 0 wait task id
  2340. ifd fdb 0 input file desc
  2341.  
  2342. iopn fcb open ind open call
  2343. iopn2 fdb 0,0
  2344.  
  2345. icrt fcb create ind create call
  2346. icrt2 fdb 0,$1B
  2347.  
  2348. iopnw fcb open ind open write call
  2349. iopnw2 fdb 0,1
  2350.  
  2351. wrid fcb write
  2352.  fdb idbuf
  2353. wrid2 fdb 0
  2354.  
  2355. iwrt fcb write
  2356.  fdb comnd
  2357. iwrt2 fdb 0
  2358.  
  2359. iwrtp fcb write
  2360. iwrtp2 fdb prompt
  2361. iwrtp3 fdb 3
  2362.  
  2363. isdp fcb defacc,0
  2364. isdp2 fcb 0
  2365.  
  2366. defdir fcc '/' default dir for chd
  2367.  rzb 47
  2368.  
  2369. retry3 fcc '/usr'
  2370. retry2 fcc '/'
  2371. retry1 fcc 'bin/'
  2372. comnd rzb 64 command name buffer
  2373.  
  2374. attab rzb 9*ASSIZ async table
  2375. atend equ *
  2376.  
  2377. idbuf rzb 8 output buffer for task id
  2378. tstbuf rzb 17 match test buffer
  2379.  
  2380. mfsb rzb 24 status buffer
  2381. prmbuf rzb 24 prompt buffer
  2382.  
  2383. front rzb 64 path name front for match
  2384.  
  2385. buffer rzb BUFSIZ input line buffer
  2386.  
  2387. bsrgls rzb 2
  2388. sargls rzb 2 shell arg start
  2389. arglst rzb BUFSIZ argument list for exec
  2390.  
  2391.  ifc &a,"notext"
  2392.  org $1E00
  2393.  else
  2394.  bss $1E00
  2395.  endif
  2396.  
  2397. linbuf rmb 512 input buffer
  2398. fstlst rmb 4096
  2399.  
  2400.  
  2401.  end sh
  2402.