1
0
mirror of https://github.com/DoctorWkt/unix-jun72.git synced 2026-04-27 04:36:38 +00:00

oh, wow, let's actually add these files.

This commit is contained in:
jbeisser
2008-04-26 01:21:03 +00:00
parent db4cc665ad
commit 6bdfa64a70
4 changed files with 223 additions and 0 deletions

56
pages/e11-01 Normal file
View File

@@ -0,0 +1,56 @@
/ sh —— command interpreter
mov sp,r5
mov r5.shel larg / save orig sp in shel larg
cdpb B(r5),$’— / was this sh calleZd by init or loginx~
bne 2f / no
sys intr; O / yes, turn off interrupts
sys quit; O
2:
sys getuid / who is user
tst r0 / is it superuser
bne 2f / no
movb $'#,at / yes, set new prompt symbol
2:
cmn (r5),$l / tty input?
ble newline / yes, call with -(or with no command
/ file name)
clr rO / no, set ttv
sys close / close it
mov 4(r5),0f / get new file name
sys open; O:..; 0 / open it
bec 1f / branch if no error
jsr r5,error / error in file name
/<Input not found\n\O>: .even
sys exit
1:
clr at / clear prompt character, if reading non-tty
/ input file
newline:
tst at / is there a prompt symbol
beq newcom / no
mov $1,rO / yes
sys write; at; 2. / print prompt
newcom:
mov shellarq,sp /
mov $parbuf,r3 / initialize command list area
mov $parp,r4 / initialize command list pointers
clr infile / initialize alternate input
clr outfile / initialize alternate output
clr glflag / initialize global flag
newarg:
jsr pc,blank / squeeze out leading blanks
jsr r5,delim / is new character a ; \n or &
br 2f / yes
mov r3,—(sp) I no, push arg pointer onto stack
cmp rO,$'< / new input file?
bne 1f / no
mov (sp).infile / yes, save arg pointer
clr (sp) / clear pointer
br 3f
1:
cmp r0,$> / new output file?
bne newchar / no
mov (sp),outfile / yes, save arg pointer
clr (sp) / clear pointer
br 3f

56
pages/e11-02 Normal file
View File

@@ -0,0 +1,56 @@
newchar:
cmp $' .r0 / is character a blank
beq 1f / branch if it is (blank as arg separator)
cmp $\n+200,r0 / treat \n preceded by \
beq 1f / as blank
jsr pc,putc / put this character in parbuf list
3:
jsr pc,getc / get next character
jsr r5,delim / is char a : \n or &,
br 1f / yes
br newchar / no, start new character tests
1:
clrb (r3)+ / end name with \0 when read blank, or
/ delim
mov (sp)+,(r4)+ / move are ant! to par? location
bne 1f / if (sp)=O, in file or out file points to arg
tst -(r4) / so ignore dummy (O), in pointer list
1:
jsr r5,delim / is char a : \n or &.
br 2f / yes
br newarg / no, start newarg processing
2:
clr (r4) / \n, &, or ; takes to here (end of arg list)
/ after dellm call
mov r0,-(sp) / save delimter in stack
jsr pc,docom / go to exec command in parbuf
cmpb (sp),$& / get a new command without wait?
beq newcom / yes
tst r1 / was chdir just executed or line ended with
/ ampersand?
beq 2f / yes
1:
sys wait / no, wait for new process to terminate
/ command executed)
bcs 2f / no, children not previously waited for
cmp r0,r1 / is this my child
bne 1b
2:
cmp (sp),$\n / was delimiter a new line
beq newline / yes
br newcom / no, pick up next command
docom:
sub $parp,r4 / out arg count in r4
bne 1f / any arguments?
clr r1 / no, line ended with ampersand
rts pc / return from call
1:
jsr r5,chcom; qchdir / is command chdir?
br 2f / command not chdir
cmp r4,$4 / prepare to exec chdir, 4=aro count x 2
beq 3f
jsr r5,error / go to print error
<Arg count\n\0>; .even
br 4f
3:

56
pages/e11-03 Normal file
View File

@@ -0,0 +1,56 @@
mov parp+2,0f / more directory name to sys coll
sys chdir; 0:0 / exec chdir
bec 4f / no error exit
jsr r5,error / go to print error
<Bad directory\n\0>; .even / this diagnostic
4:
clr r1 / set r1 to zero to dkip wait
rts pc / and return
2:
jsr r5,chcom: qloqin / is command looin?
br 2f / not loqin, no to fork
sys exec; parbuf: parp / exec login
sys exec; binpb: parp / or /bin/login
2: / no error return??
sys fork / generate sh child process for command
br newproc / exec command with new process
bec 1f / no error exit, old orocess
jsr r5,error / go to print error
<Try again\n\0>; .even / this diaonostic
jmp newline / and return for next try
1:
mov r0,r1 / save id of child sh
rts pc / return to “jsr pc, docom“ call in parent sh
error:
movb (r5)+,och / pick up diagnostic character
beq 1f / 0 is end of line
mov $1,r0 / set for tty output
sys write; och; 1 / print it
br error / continue to get characters
1:
inc r5 / inc r5 to point to return
bic $!,r5 / make it even
clr r0 / set for input
sys seek;,O; 2 / exit from runcom. skip to end of
/ input file
chcom: / has no effect if tty input
mov (r5)+,r1 / glogin gchdir r1, bump r5
mov $parbuf,r2 / command address r2 login
1:
movb (r1)+,r0 / is this command chdir
cmpb (r2)+,r0 / compare command name byte with 'login
/ or chdir
bne 1f / doesnt compare
tst r0 / is this
one 1b / end of names
tst (r5)+ / yes, bump r5 again to execute login
/ chdir
1:
rts r5 / no, return to exec command
putc:
cmp r0,$'' / single quote?
beq 1f / yes
cmp r0,$" / double quote
beq 1f / yes

55
pages/e11-04 Normal file
View File

@@ -0,0 +1,55 @@
bic $!177,r0 / no, remove 200, if present
movb r0,(r3)+ / store character in parbuf
rts po
1:
mov r0,-(sp) / push quote mark onto stack
1:
jsr pc,getc / get a quoted charactef
cmp | r0.$\n / is it end or line
bne 2f / no
jsr r5,error / yes, indicate missing quote mark
<" imbalance\n\0)>; .even
jmp newline / ask for new line
2:
cmp r0,(sp) / is this closing quote mark
beq 1f / yes
bic $!177,r0 / no, strip off 200 if present
movb r0,(r3)+ / store quoted character in parbuf
br 1b / continue
1:
tst (sp)+ / pop quote mark off stack
rts bc, return
/ thpe new process
newproc:
mov infile,0f / move pointer to new file name
beq lf / branch if no alternate read file given
tstb *0f
beq 3f / branch if no file name miven
clr rO / set tty input file name
sys close / close it
sys open; 0:..; 0 / open new input file for reading
bcc 1f / branch if input file ok
3:
jsr r5,error / file not ok, print error
<Input file\n\0>: .even / this diagnostic
sys exit / terminate this process and make narent sh
1:
mov outfile,r2 / more pointer to new file name
beq 1f / branch if no alternate write file
cmpb (r2),$> / is > at beqinninrg of file name?
bne 4f / branch if it isnt
inc r2 / yes, increment pointer
mov r2,0f
svs open; O:..; 1 / open file for writing
bec 3f / if no error
4:
mov r2,0f
sys creat; 0:..; 17 / create new file with this name
bec 3f / branch it no error
2:
jsr r5,error
<Output file\n\O>; .even
sys exit
3:
sys close / close the new write file