1
0
mirror of https://github.com/DoctorWkt/unix-jun72.git synced 2026-02-01 14:32:40 +00:00
Files
DoctorWkt.unix-jun72/pages/e11-06
2008-04-26 02:21:27 +00:00

57 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
tat 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
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
beq 1f
cmp r0,$$ / is it $
beq 3f / yes
rts pc / no
1:
mov $200,escap / mark presence of \ in command line
br getc / get next character
2:
movb *param,r0 / pick up substitution character put in
/ r0
beq 1f / if end of substitution arc, branch
inc param / if not end, set for next character
rts pc / return as though character in ro is normal
/ input
1:
clr param / unset substitution pointer
br getc / get next char in normal input
3:
jsr pc,getc / get digit after $
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
1:
mov shellarg,r1 / get pointer to stack for
/ this call of shell
inc r0 / digit +1
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
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 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