mirror of
https://github.com/DoctorWkt/unix-jun72.git
synced 2026-04-12 15:16:44 +00:00
- proofreading e11
This commit is contained in:
27
pages/e11-01
27
pages/e11-01
@@ -1,26 +1,26 @@
|
||||
/ 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~
|
||||
mov r5,shellarg / save orig sp in shellarg
|
||||
cmpb 8(r5),$'- / was this sh calleZd by init or loginx~
|
||||
bne 2f / no
|
||||
sys intr; O / yes, turn off interrupts
|
||||
sys quit; O
|
||||
sys intr; 0 / yes, turn off interrupts
|
||||
sys quit; 0
|
||||
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?
|
||||
cmp (r5),$1 / tty input?
|
||||
ble newline / yes, call with '-(or with no command
|
||||
/ file name)
|
||||
clr rO / no, set ttv
|
||||
clr r0 / no, set ttv
|
||||
sys close / close it
|
||||
mov 4(r5),0f / get new file name
|
||||
sys open; O:..; 0 / open it
|
||||
sys open; 0:..; 0 / open it
|
||||
bec 1f / branch if no error
|
||||
jsr r5,error / error in file name
|
||||
/<Input not found\n\O>: .even
|
||||
<Input not found\n\0>: .even
|
||||
sys exit
|
||||
1:
|
||||
clr at / clear prompt character, if reading non-tty
|
||||
@@ -28,10 +28,10 @@
|
||||
newline:
|
||||
tst at / is there a prompt symbol
|
||||
beq newcom / no
|
||||
mov $1,rO / yes
|
||||
mov $1,r0 / yes
|
||||
sys write; at; 2. / print prompt
|
||||
newcom:
|
||||
mov shellarq,sp /
|
||||
mov shellarg,sp /
|
||||
mov $parbuf,r3 / initialize command list area
|
||||
mov $parp,r4 / initialize command list pointers
|
||||
clr infile / initialize alternate input
|
||||
@@ -41,10 +41,10 @@ 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?
|
||||
mov r3,-(sp) / no, push arg pointer onto stack
|
||||
cmp r0,$'< / new input file?
|
||||
bne 1f / no
|
||||
mov (sp).infile / yes, save arg pointer
|
||||
mov (sp),infile / yes, save arg pointer
|
||||
clr (sp) / clear pointer
|
||||
br 3f
|
||||
1:
|
||||
@@ -53,4 +53,3 @@ newarg:
|
||||
mov (sp),outfile / yes, save arg pointer
|
||||
clr (sp) / clear pointer
|
||||
br 3f
|
||||
|
||||
|
||||
23
pages/e11-02
23
pages/e11-02
@@ -1,30 +1,30 @@
|
||||
newchar:
|
||||
cmp $' .r0 / is character a blank
|
||||
cmp $' ,r0 / is character a blank
|
||||
beq 1f / branch if it is (blank as arg separator)
|
||||
cmp $’\n+200,r0 / treat \n preceded by \
|
||||
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 &,
|
||||
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
|
||||
mov (sp)+,(r4)+ / move arg ptr to parp location
|
||||
bne 1f / if (sp)=0, in file or out file points to arg
|
||||
tst -(r4) / so ignore dummy (0), in pointer list
|
||||
1:
|
||||
jsr r5,delim / is char a : \n or &.
|
||||
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
|
||||
/ after 'delim' 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?
|
||||
cmpb (sp),$'& / get a new command without wait?
|
||||
beq newcom / yes
|
||||
tst r1 / was chdir just executed or line ended with
|
||||
/ ampersand?
|
||||
@@ -36,7 +36,7 @@ newchar:
|
||||
cmp r0,r1 / is this my child
|
||||
bne 1b
|
||||
2:
|
||||
cmp (sp),$’\n / was delimiter a new line
|
||||
cmp (sp),$'\n / was delimiter a new line
|
||||
beq newline / yes
|
||||
br newcom / no, pick up next command
|
||||
docom:
|
||||
@@ -47,10 +47,9 @@ docom:
|
||||
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
|
||||
cmp r4,$4 / prepare to exec chdir, 4=arg count x 2
|
||||
beq 3f
|
||||
jsr r5,error / go to print error
|
||||
<Arg count\n\0>; .even
|
||||
br 4f
|
||||
3:
|
||||
|
||||
|
||||
32
pages/e11-03
32
pages/e11-03
@@ -7,10 +7,10 @@
|
||||
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
|
||||
jsr r5,chcom: qloqin / is command login?
|
||||
br 2f / not loqin, go 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
|
||||
@@ -20,7 +20,7 @@
|
||||
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
|
||||
rts pc / return to "jsr pc, docom" call in parent sh
|
||||
|
||||
error:
|
||||
movb (r5)+,och / pick up diagnostic character
|
||||
@@ -30,27 +30,27 @@ error:
|
||||
br error / continue to get characters
|
||||
1:
|
||||
inc r5 / inc r5 to point to return
|
||||
bic $!,r5 / make it even
|
||||
bic $1,r5 / make it even
|
||||
clr r0 / set for input
|
||||
sys seek;,O; 2 / exit from runcom. skip to end of
|
||||
sys seek; 0; 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’
|
||||
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 / doesn’t compare
|
||||
movb (r1)+,r0 / is this command 'chdir'
|
||||
cmpb (r2)+,r0 / compare command name byte with 'login'
|
||||
/ or 'chdir'
|
||||
bne 1f / doesn't compare
|
||||
tst r0 / is this
|
||||
one 1b / end of names
|
||||
bne 1b / end of names
|
||||
tst (r5)+ / yes, bump r5 again to execute login
|
||||
/ chdir
|
||||
/ chdir
|
||||
1:
|
||||
rts r5 / no, return to exec command
|
||||
|
||||
putc:
|
||||
cmp r0,$'' / single quote?
|
||||
beq 1f / yes
|
||||
cmp r0,$’" / double quote
|
||||
cmp r0,$'" / double quote
|
||||
beq 1f / yes
|
||||
|
||||
|
||||
33
pages/e11-04
33
pages/e11-04
@@ -1,14 +1,14 @@
|
||||
bic $!177,r0 / no, remove 200, if present
|
||||
movb r0,(r3)+ / store character in parbuf
|
||||
rts po
|
||||
rts pc
|
||||
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
|
||||
jsr pc,getc / get a quoted character
|
||||
cmp r0,$'\n / is it end or line
|
||||
bne 2f / no
|
||||
jsr r5,error / yes, indicate missing quote mark
|
||||
<"’ imbalance\n\0)>; .even
|
||||
<"' imbalance\n\0)>; .even
|
||||
jmp newline / ask for new line
|
||||
2:
|
||||
cmp r0,(sp) / is this closing quote mark
|
||||
@@ -18,38 +18,39 @@
|
||||
br 1b / continue
|
||||
1:
|
||||
tst (sp)+ / pop quote mark off stack
|
||||
’ rts bc‘, return
|
||||
/ thp‘e new process
|
||||
rts pc / return
|
||||
|
||||
/ thp`e new process
|
||||
|
||||
newproc:
|
||||
mov infile,0f / move pointer to new file name
|
||||
beq lf / branch if no alternate read file given
|
||||
beq 1f / branch if no alternate read file given
|
||||
tstb *0f
|
||||
beq 3f / branch if no file name miven
|
||||
clr rO / set tty input file name
|
||||
clr r0 / 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
|
||||
<Input file\n\0>; .even / this diagnostic
|
||||
sys exit / terminate this process and make parent 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 isn’t
|
||||
cmpb (r2),$'> / is > at beqinninrg of file name?
|
||||
bne 4f / branch if it isn't
|
||||
inc r2 / yes, increment pointer
|
||||
mov r2,0f
|
||||
svs open; O:..; 1 / open file for writing
|
||||
sys open; 0:..; 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
|
||||
bec 3f / branch if no error
|
||||
2:
|
||||
jsr r5,error
|
||||
<Output file\n\O>; .even
|
||||
<Output file\n\0>; .even
|
||||
sys exit
|
||||
3:
|
||||
sys close / close the new write file
|
||||
|
||||
|
||||
30
pages/e11-05
30
pages/e11-05
@@ -1,7 +1,7 @@
|
||||
mov r2,0f / move new name to open
|
||||
mov $1,r0 / set ttv file name
|
||||
sys close / close it
|
||||
sys open; 0:..; 1 / ooen new output file, it now has
|
||||
sys open; 0:..; 1 / open new output file, it now has
|
||||
/ file descriptor 1
|
||||
sys seek; 0; 2 / set pointer to current end of file
|
||||
1:
|
||||
@@ -10,46 +10,46 @@
|
||||
sys exec; parbuf; parp / no, execute this commend
|
||||
sys exec; binpb; parp / or /bin/this command
|
||||
2:
|
||||
sys stat; binpb; inbuf / if can’t execute does it
|
||||
sys stat; binpb; inbuf / if can't execute does it
|
||||
/ exist?
|
||||
bes 2f / branch if it doesn’t
|
||||
bes 2f / branch if it doesn't
|
||||
mov $shell,parp-2 / does exist, not executable
|
||||
mov $binpb,parp / so it must be
|
||||
svs exec; shell; parp-2 / a command file, get it with
|
||||
/ sh /bin/x (if x name of file)
|
||||
2:
|
||||
jsr r5,error / a return for exec is the diaonostic
|
||||
<No command\n\O>; .even
|
||||
jsr r5,error / a return for exec is the diagnostic
|
||||
<No command\n\0>; .even
|
||||
sys exit
|
||||
1:
|
||||
mov $glob,parp-2 / prepare to process *,?
|
||||
sys exec; glob: parp-2 / execute modified command
|
||||
sys exec; glob; parp-2 / execute modified command
|
||||
br 2b
|
||||
|
||||
delim:
|
||||
cmp r0,$'\n / is character a newline
|
||||
beq 1f
|
||||
cmp r0,S’& / ls it &
|
||||
cmp r0,S'& / is it &
|
||||
beq 1f / yes
|
||||
cmu r0,$'; / is it ;
|
||||
cmp r0,$'; / is it ;
|
||||
beq 1f / yes
|
||||
cmp r0,$’? / is it ?
|
||||
cmp r0,$'? / is it ?
|
||||
beq 3f
|
||||
cmp r0,$’[ / is it beginning of character string
|
||||
cmp r0,$'[ / is it beginning of character string
|
||||
/ (for glob)
|
||||
bne 2f
|
||||
3:
|
||||
inc glflag / ? or * or [ set flag
|
||||
2:
|
||||
tst (r5)+ / bump to process all except \n,:,&
|
||||
tst (r5)+ / bump to process all except \n,;,&
|
||||
1:
|
||||
rts r5
|
||||
|
||||
blank:
|
||||
jsr pc,getc / get next character
|
||||
cmp $' ,r0 / leadino blanks
|
||||
beq blank / yes, ’squeeze out'
|
||||
cmp r0,$200+'\n / new—line preceded by \ is translated
|
||||
cmp $' ,r0 / leading blanks
|
||||
beq blank / yes, 'squeeze out'
|
||||
cmp r0,$200+'\n / new-line preceded by \ is translated
|
||||
beq blank / into blank
|
||||
rts pc
|
||||
getc:
|
||||
|
||||
|
||||
27
pages/e11-06
27
pages/e11-06
@@ -1,19 +1,19 @@
|
||||
tat param / are we substituting for $n
|
||||
tst param / are we substituting for $n
|
||||
bne 2f/ yes
|
||||
mov inbufp,r1 / no, move normal input pointer to r1
|
||||
cmp r1,einbuf / end of input line?
|
||||
bne 1f / no
|
||||
jsr pc,netbuf / vas. put next console line in buffer
|
||||
br gotc
|
||||
jsr pc,getbuf / yes, put next console line in buffer
|
||||
br getc
|
||||
1:
|
||||
movb (r1)+,r0 / move byte from input buffer to r0
|
||||
mov r1,inbufp / increment routine
|
||||
bis escap,r0 / if last character was \ this adds
|
||||
/ 200 to current character
|
||||
clr escap / clear, so escap normally zero
|
||||
cmp r0,$’\\ / note that \\ is equal \ in as
|
||||
cmp r0,$'\\ / note that \\ is equal \ in as
|
||||
beq 1f
|
||||
cmp r0,$’$ / is it $
|
||||
cmp r0,$'$ / is it $
|
||||
beq 3f / yes
|
||||
rts pc / no
|
||||
1:
|
||||
@@ -22,7 +22,7 @@
|
||||
2:
|
||||
movb *param,r0 / pick up substitution character put in
|
||||
/ r0
|
||||
beq 1f / if end of substitution arc, branch
|
||||
beq 1f / if end of substitution arg, branch
|
||||
inc param / if not end, set for next character
|
||||
rts pc / return as though character in ro is normal
|
||||
/ input
|
||||
@@ -31,7 +31,7 @@
|
||||
br getc / get next char in normal input
|
||||
3:
|
||||
jsr pc,getc / get digit after $
|
||||
sub $’0,r0 / strip off zone bits
|
||||
sub $'0,r0 / strip off zone bits
|
||||
cmp r0,$9, / compare with digit 9
|
||||
clos 1f / less than or equal 9
|
||||
mov $9.,r0 / if larger than 9, force 9
|
||||
@@ -42,15 +42,14 @@
|
||||
cmp r0,(r1) / is it less than # of args in this call
|
||||
bge getc / no, ignore it. so this $n is not replaced
|
||||
asl r0 / yes, multiply by 2 (to skip words)
|
||||
add r01,r0 / form pointer to aro pointer (-2)
|
||||
mov 2(r0),param / more arg pointer to param
|
||||
add r01,r0 / form pointer to arg pointer (-2)
|
||||
mov 2(r0),param / move arg pointer to param
|
||||
br getc / go to get substitution arg for $n
|
||||
getbuf:
|
||||
mov $inbuf,r0 / move inout buffer address
|
||||
mov r0,inbufp / to inout buffer pointer
|
||||
mov $inbuf,r0 / move input buffer address
|
||||
mov r0,inbufp / to input buffer pointer
|
||||
mov r0,einbuf / and initialize pointer to end of
|
||||
/ character string
|
||||
dec r0 / decrement pointer so can utilize normal
|
||||
/ l00p starting at If
|
||||
mov r0,0f / initialize address for readlng 1st char
|
||||
|
||||
/ 100p starting at 1f
|
||||
mov r0,0f / initialize address for reading 1st char
|
||||
|
||||
22
pages/e11-07
22
pages/e11-07
@@ -1,32 +1,36 @@
|
||||
1:
|
||||
inc 0f / this routine filles inbuf with line from
|
||||
/ console - if there is cnc
|
||||
clr r0 / set for tty inout
|
||||
sys read; O:O; I / read next char into inbuf
|
||||
clr r0 / set for tty input
|
||||
sys read; 0:0; 1 / read next char into inbuf
|
||||
bcs xit1 / error exit
|
||||
tst r0 / a zero input is and of file
|
||||
tst r0 / a zero input is end of file
|
||||
beq xit1 / exit
|
||||
inc einbuf / eventually einbuf points to \n
|
||||
/ (+1) or this line
|
||||
cmp 0b,$1nbuf+256. / have we exceeded innut buffer size
|
||||
/ (+1) of this line
|
||||
cmp 0b,$inbuf+256. / have we exceeded input buffer size
|
||||
bhis xit1 / if so, exit assume some sort of binary
|
||||
cmpb *0b,$’\n / end of line?
|
||||
cmpb *0b,$'\n / end of line?
|
||||
bne 1b / no, go to get next char
|
||||
rts pc / yes, return
|
||||
|
||||
xit1:
|
||||
sys exit
|
||||
|
||||
quest:
|
||||
<?\n>
|
||||
|
||||
at:
|
||||
<@ >
|
||||
|
||||
qchdir:
|
||||
<chdir\0>
|
||||
glogin:
|
||||
<login\0> -
|
||||
<login\0>
|
||||
shell:
|
||||
</bin/sh\0> .
|
||||
</bin/sh\0>
|
||||
glob:
|
||||
</etc/g10b\0>
|
||||
</etc/glob\0>
|
||||
binpb:
|
||||
</bin/>
|
||||
parbuf: .=.+1000.
|
||||
|
||||
Reference in New Issue
Block a user