Replaced last of old shell calls with their newer counterparts. This

removed the need for p-string routines, so they were removed. Also
removed alloc256/free256 and associated data structures.

In removing calls, found instances in pwd & prefix commands and prompt
handler where current directory name was assumed to be < 256 characters;
recoded to use a flexible buffer size.

Updated and expanded mmdebug.asm routines that perform error checking on
memory management calls. Added macros ~NEW and ~DISPOSE that invoke either
the real or debug routines.

Fixed call to read $TERM variable's length to fix PR#81.

Removed echo of data when setting value of $< in expandvars (expand.asm).
The characters are echoed as they are typed and do not need to be reprinted
on stdout after carriage-return is typed.

Added error checking to the various flavors of prefix (just like cd):
  - Verify 2nd parameter is a valid directory before setting.
  - Verify 1st parameter < 32 before displaying or setting.
This commit is contained in:
tribby 1998-08-03 17:30:30 +00:00
parent d534981038
commit 2e0ebb5392
24 changed files with 1160 additions and 1296 deletions

View File

@ -1,7 +1,7 @@
#
# makefile for building gsh. This is for use with dmake.
#
# $Id: Makefile,v 1.5 1998/06/30 17:25:01 tribby Exp $
# $Id: Makefile,v 1.7 1998/09/08 16:53:04 tribby Exp $
#
# Devin Reade, February 1998.
#
@ -28,8 +28,8 @@ SRCS = $(MAINSRC) \
orca.asm \
edit.asm \
term.asm \
bufpool.asm
# unused: mmdebug.asm
bufpool.asm \
mmdebug.asm
# Note: STACK variable does not control size of stack/direct-page segment
# since this is assembly language. Edit stack segment in main.asm
@ -41,9 +41,12 @@ SRCS = $(MAINSRC) \
# ltermcap library from GNO v2.0.4.
#
# LDADD = -ltermcap
LDLIBS += -l/trenco3/lib.206/ltermcap
###LDLIBS += -l/trenco3/lib.206/ltermcap
###LDLIBS += -l/h1/orca/libraries/ltermcap
###LDLIBS += -l/usr/lib/libtermcap
LDLIBS += -l/usr/lib/libtermcap
# For debugging: produce a link map
## LDFLAGS += -M
# Make sure our macro files get built before trying to assemble source files.
# LOCAL_SETUP = macros

View File

@ -1,6 +1,43 @@
GSH 2.0 UPDATES
^^^^^^^^^^^^^^^
Aug 2 98 [dmt] Remove alloc256/free256 and associated data. Replace
with fixed 64-byte buffer for command filename (hash.asm)
and allocation of 261-byte buffer via ~NEW for shell
variable name (shellvar.asm).
Aug 1 98 [dmt] Updated and expanded mmdebug.asm routines that perform
error checking on memory management calls. Added macros ~NEW
and ~DISPOSE that invoke either the real or debug routines.
Fixed call to read $TERM variable's length (PR#81).
Replace call to allocate256 in AppendHome (shell.asm) with
code that allocates space for $HOME plus the string parameter.
Jul 28 98 [dmt] In expandvars (expand.asm), use echoFlag=0 (not 1)
for ReadLine. The characters are echoed as they are typed
and do not need to be reprinted on stdout.
Jul 27 98 [dmt] Added error checking to the various flavors of prefix:
- Verify 2nd parameter is a valid directory before setting.
- Verify 1st parameter < 32 before displaying or setting.
Jul 26 98 [dmt] Removed last of old shell calls and calls to and code for
p-string routines (p2cstr, c2pstr, c2pstr2, putp, errputp).
Removed old shell macros and "str" from gsh.mac. In removing
putp calls, found instances in pwd & prefix commands and prompt
handler where current directory name was assumed to be < 256
characters; recoded to use new routine getpfxstr.
Jul 21 98 [dmt] Changed invoke.asm to use RedirectGS instead of redirect.
Changed popd (in dir.asm) to get length of prefix 0 before
allocating its string, rather than assuming path is <= 256
characters. This allows directory stack to use very long names.
Jul 20 98 [dmt] Changed expand.asm to use InitWildcardGS and
NextWildcardGS instead of their obsolete counterparts.
Jul 20 98 [dmt] Changes up to this point checked-in to master archive.
Jul 19 98 [dmt] Changed edit.asm to use ReadIndexedGS, InitWildcardGS,
NextWildcardGS, instead of their obsolete counterparts.

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: alias.asm,v 1.4 1998/07/20 16:23:01 tribby Exp $
* $Id: alias.asm,v 1.5 1998/08/03 17:30:25 tribby Exp $
*
**************************************************************************
*
* ALIAS.ASM
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
*
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | |
@ -161,7 +162,7 @@ setalias ldy #4+2 ;put alias name on stack
pha
ph4 #2
jsl ~NEW
~NEW
sta arg
stx arg+2
lda #0
@ -323,7 +324,7 @@ yahaha sta AliasTable,x
;=========================================================================
expandalias START
outbuf equ 0
sub equ outbuf+4
word equ sub+4
@ -333,7 +334,7 @@ space equ buf+4
subroutine (4:cmd),space
ph4 #1024
jsl ~NEW
~NEW
stx buf+2
sta buf
stx outbuf+2
@ -483,7 +484,7 @@ done ldx word+2
;=========================================================================
addalias START
using AliasData
tmp equ 0
@ -539,7 +540,7 @@ replace ldy #8+2
inc a
pea 0
pha
jsl ~NEW
~NEW
sta tmp
stx tmp+2
ldy #8
@ -555,7 +556,7 @@ replace ldy #8+2
bra done
notfound ph4 #4*3
jsl ~NEW
~NEW
sta ptr
stx ptr+2
ldy #2
@ -570,7 +571,7 @@ notfound ph4 #4*3
inc a
pea 0
pha
jsl ~NEW
~NEW
sta tmp
stx tmp+2
ldy #4
@ -589,7 +590,7 @@ notfound ph4 #4*3
inc a
pea 0
pha
jsl ~NEW
~NEW
sta tmp
stx tmp+2
ldy #8

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: bufpool.asm,v 1.3 1998/06/30 17:25:09 tribby Exp $
* $Id: bufpool.asm,v 1.4 1998/08/03 17:30:26 tribby Exp $
*
**************************************************************************
*
* BUFPOOL
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6 (256-byte buffer code removed)
*
* This is the buffer pool
*
@ -23,14 +24,10 @@
* Interfaces defined in this file:
* The alloc routines are a jsl without any stack params.
* Pointer to requested buffer is returned in X/A registers.
* alloc256
* free256
* alloc1024
* free1024
*
* bufpool data:
* pool256 dc i4'0'
* pool256mutex key
* pool1024 dc i4'0'
* pool1024mutex key
*
@ -41,86 +38,6 @@
dummybufpool start ; ends up in .root
end
**************************************************************************
*
* get a buffer of size 256
*
**************************************************************************
alloc256 START
using bufpool
lock pool256mutex Mutual exclusion lock.
lda pool256 Get address of
ora pool256+2 256-byte pool.
beq allocbuf If NULL, go allocate the buffer.
phd Hold on to Direct Page register.
ph4 pool256 Put current contents of pool256 on stack.
tsc Copy stack pointer to
tcd Direct Page register.
lda [1] Store 4 bytes of data
sta pool256 that pool256 pointed to
ldy #2 in pool256.
lda [1],y
sta pool256+2
unlock pool256mutex Mutual exclusion unlock.
pla A = old pool256
plx X = old pool256+2
pld Restore Direct Page register.
rtl Return to caller.
allocbuf unlock pool256mutex Mutual exclusion unlock.
ph4 #256 Request 256 bytes
jsl ~NEW from system.
rtl Return to caller.
END
**************************************************************************
*
* free a buffer of size 256
*
**************************************************************************
free256 START
using bufpool
phd Save data bank register.
phx Put address to free
pha on stack.
tsc Copy stack pointer into
tcd direct page register.
lock pool256mutex Mutual exclusion lock.
lda pool256
sta [1]
ldy #2
lda pool256+2
sta [1],y
lda 1
sta pool256
lda 3
sta pool256+2
unlock pool256mutex Mutual exclusion unlock.
pla Restore Accumulator,
plx X-register, and
pld Direct Page register,
rtl Return to caller.
END
**************************************************************************
*
* get a buffer of size 1024
@ -128,7 +45,7 @@ free256 START
**************************************************************************
alloc1024 START
using bufpool
lock pool1024mutex
@ -154,7 +71,7 @@ alloc1024 START
allocbuf unlock pool1024mutex
ph4 #1024
jsl ~NEW
~NEW
rtl
END
@ -200,8 +117,6 @@ free1024 START
bufpool DATA
pool256 dc i4'0'
pool256mutex key
pool1024 dc i4'0'
pool1024mutex key

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: builtin.asm,v 1.4 1998/07/20 16:23:01 tribby Exp $
* $Id: builtin.asm,v 1.5 1998/08/03 17:30:26 tribby Exp $
*
**************************************************************************
*
@ -48,7 +48,6 @@
*
**************************************************************************
mcopy /obj/gno/bin/gsh/builtin.mac
dummybuiltin start ; ends up in .root
@ -101,7 +100,7 @@ end equ argc+2
ld4 builtintbl,tbl
ld2 -1,val
lda argc
jeq done
beq done
loop ldy #2
lda [tbl]
@ -449,7 +448,7 @@ cdmutex key Mutual exclusion key
; Parameter block for GS/OS SetPrefix call
PRec dc i'2' pCount
PRecNum dc i'0' prefixNum (0 = current directory)
dc i'0' prefixNum (0 = current directory)
PRecPath ds 4 Pointer to input prefix path
; Parameter block for GS/OS GetFileInfo call
@ -721,41 +720,30 @@ end equ argv+4
wait lock pwdmutex
jsl alloc256 Allocate buffer for GetPrefix.
sta gpptr
stx gpptr+2
pea 0
jsl getpfxstr Get value of prefix 0.
sta ptr
stx ptr+2
lda #256 Set max return len.
sta [ptr]
ora ptr+2 If NULL pointer returned,
beq done an error was reported.
GetPrefix gpparm Get value of prefix 0 via GetPrefix.
bcc ok If there was an error,
awshit sta errError Save the value
ErrorGS err and report it.
bra done
ldy #2 If length of returned
lda [ptr],y GS/OS string is 0,
beq freebuf an error was reported.
ok ldy #2 Get GS/OS string length word.
lda [ptr],y
xba Swap the bytes and store back,
sta [ptr],y so it can be used as a p-string.
ldx ptr+2 Load X/A with addr 3 bytes beyond ptr.
lda ptr
clc
adc #3
bcc doputp
lda ptr X/A = address of
clc text (four bytes
adc #4 beyond start).
bcc doputs
inx
doputp anop
jsr putp Print the p-string
doputs jsr puts Print the c-string
jsr newline and add a newline.
done ldx ptr+2 Free the buffer.
lda ptr
jsl free256
freebuf ph4 ptr Free the buffer.
jsl nullfree
unlock pwdmutex
done unlock pwdmutex
exit lda space Deallocate stack space
sta end-3 and return to the caller.
@ -773,15 +761,6 @@ exit lda space Deallocate stack space
pwdmutex key
; Parameter block for GS/OS call GetPrefix
gpparm dc i'2' Parameter count
dc i'0' Prefix number
gpptr ds 4 Pointer to result buffer
; Parameter block for shell ErrorGS call (p 393 in ORCA/M manual)
err dc i2'1' pCount
errError ds 2 Error number
Usage dc c'Usage: pwd',h'0d00'
END
@ -904,28 +883,32 @@ thispfx lock pwdmutex
showcwd pei (ptr+2)
pei (ptr)
jsl nullfree
jsl alloc256
pea 0
jsl getpfxstr Get value of prefix 0.
sta ptr
stx ptr+2
sta gpptr
stx gpptr+2
lda #256
sta [ptr]
GetPrefix gpparm
ldy #2
lda [ptr],y
xba
sta [ptr],y
ldx ptr+2
add2 ptr,#3,@a
jsr putp
ldx file+2
ora ptr+2 If NULL pointer returned,
beq donecwd an error was reported.
ldy #2 If length of returned
lda [ptr],y GS/OS string is 0,
beq freebuf an error was reported.
lda ptr X/A = address of
clc text (four bytes
adc #4 beyond start).
bcc doputs
inx
doputs jsr puts Print the directory name.
ldx file+2 Print the file name.
lda file
jsr puts
ldx ptr+2
lda ptr
jsl free256
freebuf ph4 ptr Free the buffer.
jsl nullfree
stz ptr
stz ptr+2
bra donecwd
@ -966,10 +949,6 @@ aliasstr dc c'Aliased as ',h'00'
pwdmutex key
gpparm dc i'2'
dc i'0'
gpptr ds 4
GRec dc i'4'
GRecPath ds 4
ds 2
@ -991,7 +970,8 @@ prefix START
dir equ 1
numstr equ dir+4
space equ numstr+4
pfxnum equ numstr+4
space equ pfxnum+2
argc equ space+3
argv equ argc+2
end equ argv+4
@ -1007,144 +987,182 @@ end equ argv+4
lock mutex
lda argc
lda argc Get number of arguments.
dec a
beq showall
beq showall If no parameters, show all prefixes.
dec a
jeq showone
jeq showone If one, show one.
dec a
jeq setprefix
jeq setprefix If two, set a prefix.
ldx #^usage
lda #usage
jsr errputs
jmp done
;
; No parameters provided: show all the prefixes
;
showall anop
lda #$FFFF
sta pfxnum First prefix # will be 0.
showall jsl alloc256
sta PRecPath
stx PRecPath+2
pha Get the boot volume string.
jsl getpfxstr
sta dir
stx dir+2
lda #254
sta [dir]
ld2 1,PRecNum
GetBootVol PRecNum
jcs awshit
ora dir+2 If NULL pointer returned,
beq bumppfx an error was reported.
ldx #^bootstr
lda #bootstr
jsr puts
ldy #2
lda [dir],y
xba
sta [dir],y
ldx dir+2
lda dir
inc2 a
inc a
jsr putp
jsr newline
lda dir X/A = address of
clc text (four bytes
adc #4 beyond start).
bcc doputs
inx
doputs jsr puts Print the directory name
jsr newline and a newline.
bra nextall Jump into the all loop.
stz PRecNum
allloop GetPrefix PRec
jcs awshit
ldy #2
allloop lda pfxnum
pha
jsl getpfxstr
sta dir
stx dir+2
ora dir+2 If NULL pointer returned,
beq bumppfx an error was reported.
ldy #2 Get length word.
lda [dir],y
beq nextall
xba
sta [dir],y
Int2Dec (PRecNum,#pfxstr,#2,#0)
beq nextall If zero, do the next prefix.
Int2Dec (pfxnum,#pfxstr,#2,#0)
ldx #^pfxstr
lda #pfxstr
jsr puts
ldx dir+2
lda dir
inc2 a
inc a
jsr putp
lda dir X/A = address of
clc text (four bytes
adc #4 beyond start).
bcc doputs2
inx
doputs2 jsr puts Print the directory name
jsr newline
nextall inc PRecNum
if2 PRecNum,cc,#32,allloop
nextall ph4 dir Free the GS/OS result buffer
jsl nullfree allocated for pathname.
bumppfx inc pfxnum Bump the prefix number.
if2 pfxnum,cc,#32,allloop
jmp finish
showone ldy #6
lda [argv],y
sta numstr+2
pha
dey2
lda [argv],y
;
; One parameter provided: show a single prefix
;
showone ldy #1*4+2 Put pointer to
lda [argv],y first command
sta numstr+2 argument in
pha numstr, and
dey2 also on stack
lda [argv],y as parameter.
sta numstr
pha
jsr cstrlen
jsr cstrlen Get length of argument.
tax
Dec2Int (numstr,@x,#0),PRecNum
Dec2Int (numstr,@x,#0),@a Convert to integer.
cmp #32 If prefix num >= 32,
bcc getpfx
jsr newline just print blank line.
jmp done
jsl alloc256
sta PRecPath
stx PRecPath+2
getpfx pha Get that prefix value.
jsl getpfxstr
sta dir
stx dir+2
lda #254
sta [dir]
GetPrefix PRec
bcs awshit
ldy #2
lda [dir],y
xba
sta [dir],y
ldx dir+2
lda dir
inc2 a
inc a
jsr putp
jsr newline
lda PRecPath
ldx PRecPath+2
jsl free256
bra done
setprefix ldy #6
lda [argv],y
sta numstr+2
pha
dey2
lda [argv],y
ora dir+2 If NULL pointer returned,
jeq done an error was reported.
Int2Dec (pfxnum,#pfxstr,#2,#0)
ldy #2 Get length word.
lda [dir],y
beq donewline If zero, just print newline.
ldx dir+2
lda dir X/A = address of
clc text (four bytes
adc #4 beyond start).
bcc doputs3
inx
doputs3 jsr puts Print the directory name
donewline jsr newline
ph4 dir Free the GS/OS result buffer
jsl nullfree allocated for pathname.
jmp done
;
; Two parameters provided: set a prefix
;
setprefix ldy #1*4+2 Put pointer to
lda [argv],y first command
sta numstr+2 argument (prefix
pha num) in numstr, and
dey2 also on stack
lda [argv],y as parameter.
sta numstr
pha
jsr cstrlen
jsr cstrlen Get length of argument.
tax
Dec2Int (numstr,@x,#0),PRecNum
Dec2Int (numstr,@x,#0),PRecNum Convert to integer string.
ldy #2*4+2
lda PRecNum
cmp #32 If prefix num >= 32,
bcs done nothing to do.
ldy #2*4+2 Put pointer to
lda [argv],y second command
pha argument (value)
dey2 on stack as parameter.
lda [argv],y
pha
dey2
lda [argv],y
pha
jsr c2gsstr
sta PRecPath
sta GRecPath
jsr c2gsstr Convert to GS string.
sta GRecPath Store in GetFileInfo
stx GRecPath+2 parameter block and
sta PRecPath SetPrefix p.b.
stx PRecPath+2
stx GRecPath+2
;
; Get file information to determine whether target is a valid directory
;
GetFileInfo GRec
bcc okay
awshit ldx #^errorstr
lda #errorstr
bcc ok
sta ErrError
ErrorGS Err
bra done
ok if2 GRecFT,eq,#$F,ok2 If filetype != $F,
ldx #^direrr print error message
lda #direrr 'Not a directory'
jsr errputs
bra finish
bra done
okay SetPrefix PRec
bcs awshit
ok2 SetPrefix PRec Set the prefix.
bcc finish If error flag set,
ldx #^errorstr print error message
lda #errorstr 'could not set prefix,
jsr errputs pathname may not exist.'
finish ph4 PRecPath
finish ph4 PRecPath Free the name string buffer.
jsl nullfree
done unlock mutex
lda space
sta end-3
lda space+1
@ -1166,14 +1184,28 @@ errorstr dc c'prefix: could not set prefix, pathname may not exist.'
usage dc c'Usage: prefix prefixnum prefixname',h'0d00'
bootstr dc c' *: ',h'00'
pfxstr dc c'00: ',h'00'
dirErr dc c'prefix: Not a directory',h'0d00'
;
; Parameter block for GS/OS GetFileInfo call
;
GRec dc i'3' pCount
GRecPath ds 4 Pointer to input pathname
GRecAcc ds 2 access (result)
GRecFT ds 2 fileType (result)
PRec dc i'2'
PRecNum dc i'0'
PRecPath ds 4
;
; Parameter buffer for SetPrefix GS/OS call
;
PRec dc i'2' pCount
PRecNum dc i'0' prefix number
PRecPath ds 4 pointer to GS/OS string with value
GRec dc i'2'
GRecPath ds 4
GRecAcc ds 2
;
; Parameter block for shell ErrorGS call (p 393 in ORCA/M manual)
;
Err dc i2'1' pCount
ErrError ds 2 Error number
END

View File

@ -1,4 +1,4 @@
***********************************************************************
**************************************************************************
*
* The GNO Shell Project
*
@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: cmd.asm,v 1.4 1998/07/20 16:23:02 tribby Exp $
* $Id: cmd.asm,v 1.5 1998/08/03 17:30:27 tribby Exp $
*
**************************************************************************
*
@ -325,7 +325,7 @@ errstr2 dc c"gsh: Missing ending '.",h'0d00'
**************************************************************************
command START
pipefds equ 1
errappend equ pipefds+2
errfile equ errappend+2
@ -359,7 +359,7 @@ end equ waitpid+4
tcd
ph4 #1024 Allocate 1024 bytes
jsl ~NEW and pointer in cmdline.
~NEW and pointer in cmdline.
sta cmdline
stx cmdline+2
lda #0 Initialize to null C string.
@ -370,7 +370,7 @@ end equ waitpid+4
stx word+2
ph4 #MAXARG*4
jsl ~NEW
~NEW
sta argv
stx argv+2
@ -421,7 +421,7 @@ word1 pei (word+2)
inc a
pea 0
pha
jsl ~NEW
~NEW
sta temp
stx temp+2
ora temp+2
@ -771,7 +771,7 @@ free2 pei (argv+2)
**************************************************************************
ShellExec START
using vardata
using global
@ -857,27 +857,27 @@ set_value anop
vars_set unlock mutex
ph4 #4 ;Close parms
jsl ~NEW
~NEW
sta CRec
stx CRec+2
ph4 #10 ;Open parms
jsl ~NEW
~NEW
sta ORec
stx ORec+2
ph4 #12 ;NewLine parms
jsl ~NEW
~NEW
sta NRec
stx NRec+2
ph4 #16 ;Read parms
jsl ~NEW
~NEW
sta RRec
stx RRec+2
ph4 #1000 ;data buffer
jsl ~NEW
~NEW
sta data
stx data+2

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: dir.asm,v 1.4 1998/07/20 16:23:03 tribby Exp $
* $Id: dir.asm,v 1.5 1998/08/03 17:30:27 tribby Exp $
*
**************************************************************************
*
@ -33,6 +33,8 @@
*
* path2tilde
*
* getpfxstr
*
**************************************************************************
mcopy /obj/gno/bin/gsh/dir.mac
@ -552,60 +554,68 @@ space equ idx+2
subroutine (0:dummy),space
lda tods
asl a
asl a
sta idx
tay
lda dirstack,y
ora dirstack+2,y
lda tods Get index number.
asl a Multiply by four
asl a to get byte offset.
sta idx Store in idx
tay and Y-register.
lda dirstack,y If there is an address
ora dirstack+2,y in this position,
beq setit
lda dirstack+2,y
pha
lda dirstack,y
pha
jsl nullfree
jsl nullfree free it.
setit lock mutex
jsl alloc256
sta gppath
stx gppath+2
sta p
stx P+2
lda #254
sta [p]
GetPrefix gpparm
ldy #2
lda [p],y
xba
sta [p],y
add4 p,#3,p
pei (p+2)
pei (p)
jsr p2cstr
pea 0
jsl getpfxstr Get value of prefix 0.
sta p
stx p+2
ldx gppath+2
lda gppath
jsl free256
unlock mutex
ora p+2 If NULL pointer returned,
beq done an error was reported.
ldy idx
lda p
sta dirstack,y
ldy #2 If length of returned
lda [p],y GS/OS string is 0,
bne ok an error was reported.
ph4 p Free the buffer.
jsl nullfree
bra done
;
; Move text in GS/OS result buffer to beginning of buffer
; (overwritting the two length words).
;
ok clc Source is result
lda p buffer plus
adc #4 four bytes.
tay
lda p+2
adc #0
pha
phy
pei (p+2) Destination is first
pei (p) byte of buffer.
jsr copycstr
ldy idx Store address of string
lda p in current position
sta dirstack,y of directory stack.
lda p+2
sta dirstack+2,y
done unlock mutex
return
mutex key
gpparm dc i2'2'
dc i2'0'
gppath dc i4'0'
END
**************************************************************************
@ -628,7 +638,7 @@ tods dc i'0'
**************************************************************************
path2tilde START
ptr equ 0
newpath equ ptr+4
home equ newpath+4
@ -636,26 +646,24 @@ space equ home+4
subroutine (4:path),space
pei (path+2)
pei (path)
jsr cstrlen
inc2 a
pea 0
pei (path+2) Get length of
pei (path) path string
jsr cstrlen parameter.
inc2 a Add 2, and allocate
pea 0 memory for result string.
pha
jsl ~NEW
~NEW
sta newpath
stx newpath+2
sta ptr
stx ptr+2
jsl alloc256 Allocate 256 byte GS/OS result buf.
ph4 #homename Get $HOME environment variable.
jsl getenv
sta home
stx home+2
sta ReadName
stx ReadName+2
lda #256 Set buffer length word.
sta [home]
ReadVariableGS ReadVar Read $home environment variable.
ora home+2 If buffer wasn't allocated
jeq notfound2 cannot search for $HOME.
ldy #2 Get result length word.
lda [home],y
@ -667,7 +675,7 @@ checkhome lda [path],y
beq notfound2 checking for end of string,
jsr tolower converting to lower-case
jsr toslash and changing ":" to "/".
pha Hold that character on the stack.
pha Hold on stack for comparison.
iny4 $home has 4 bytes of length info
lda [home],y that need to be indexed over.
dey2 Take back 3 of the offset,
@ -681,23 +689,31 @@ checkhome lda [path],y
dex Decrement $home length counter.
bne checkhome If more, stay in loop.
; All the characters matched $home.
cmp #'/'
;
; First part of parameter matched $HOME
;
cmp #'/' This char = "/"?
beq found yes -- it's a match.
lda [path],y If the following character
and #$FF is zero (end of string),
beq found
lda [path],y
and #$FF
beq found
jsr toslash
jsr toslash '/', or ':', we have a match.
cmp #'/'
bne notfound2
found lda #'~'
sta [ptr]
incad ptr
found lda #'~' Store '~' as first character
sta [ptr] in result buffer, and bump
incad ptr result pointer.
bra copyrest
notfound pla
notfound2 ldy #0
;
; First part of parameter does not match $HOME
;
notfound pla Get rid of comparison value on stack.
notfound2 ldy #0 Not found: copy from beginning.
;
; Copy remainder of parameter (Y-reg marks start) to destination string
;
copyrest short a
copyloop lda [path],y
beq endcopy
@ -710,28 +726,135 @@ copyput sta [ptr]
short a
iny
bra copyloop
endcopy sta [ptr]
endcopy sta [ptr]
long a
dec ptr
lda [ptr]
dec ptr If final character
lda [ptr] was "/",
cmp #'/'
bne skipshorten
lda #0
lda #0 obliterate it.
sta [ptr]
skipshorten ldx home+2
lda home
jsl free256
skipshorten pei (home+2) Free memory allocated
pei (home) for the value of $HOME.
jsl nullfree
return 4:newpath
; Parameter block for shell ReadVariableGS call (p 423 in ORCA/M manual)
ReadVar anop
dc i2'3' pCount
dc a4'homename' Pointer to name
ReadName ds 4 GS/OS Output buffer ptr: value
ds 2 export flag
homename gsstr 'home' Env variable name
END
**************************************************************************
*
* Return pointer to current directory (\0) GS/OS string in a/x
*
**************************************************************************
getpfxstr START
p equ 0
space equ p+4
subroutine (2:pnum),space
lock mutex
; Use dummy GS/OS result buf to get length of pathname
;
lda pnum Put prefix num into
cmp #$FFFF If it's $FFFF,
beq doboot use GetBootVol, not GetPrefix.
sta gpnum Store prefix num in parameter block.
ld4 TempResultBuf,gppath
GetPrefix gpparm
bra chklen
doboot ld4 TempResultBuf,gbpath
GetBootVol gbparm
chklen lda TempRBlen Use that length
clc plus five (for
adc #5 len words and terminator)
pea 0 to allocate memory
pha that holds the string.
~NEW
sta p Store result in
stx p+2 direct page pointer.
ora p+2 If memory was not available,
bne memok
lda #0201 report memory error and
bra rpterr return NULL to user.
memok lda TempRBlen Store result buf
inc2 a length at start
inc2 a of buffer.
sta [p]
tay Store a null byte
short a at the end of the
lda #0 string so it can
sta [p],y be used as a c-string.
long a
;
; Get the prefix string into the newly allocated buffer.
;
lda pnum Prefix number tells
cmp #$FFFF whether to use
beq doboot2 GetPrefix or GetBootVol.
mv4 p,gppath
GetPrefix gpparm
bcs rpterr
bra done
doboot2 mv4 p,gbpath
GetBootVol gbparm
bcc done If there was an error,
rpterr sta errError Save the value
ErrorGS err and report it.
ldy #2 Set length of returned
lda #0 string to 0 so caller
sta [p],y can detect error condition.
done unlock mutex
;
; Return pointer to caller. (Caller has responsibility to deallocate.)
;
return 4:p
mutex key
;
; Parameter block for GetPrefix GS/OS call
;
gpparm dc i2'2' pCount
gpnum dc i2'0' prefixNum (from parameter)
gppath dc i4'0' prefix returned to this GS/OS buffer.
;
; Parameter block for GetBootVol GS/OS call
;
gbparm dc i2'1' pCount
gbpath dc i4'0' prefix returned to this GS/OS buffer.
;
; GS/OS result buffer for getting the full length of the prefix string
;
TempResultBuf dc i2'5' Only five bytes total.
TempRBlen ds 2 String's length returned here.
ds 1 Only 1 byte for value.
;
; Parameter block for shell ErrorGS call (p 393 in ORCA/M manual)
;
err dc i2'1' pCount
errError ds 2 Error number
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: edit.asm,v 1.4 1998/07/20 16:23:03 tribby Exp $
* $Id: edit.asm,v 1.5 1998/08/03 17:30:28 tribby Exp $
*
**************************************************************************
*
@ -971,7 +971,7 @@ loop pha
;=========================================================================
wordmatch START
using global
using hashdata
using BuiltInData
@ -1114,7 +1114,7 @@ gv02a anop
inc a
pea 0
pha
jsl ~NEW Request memory to hold name.
~NEW Request memory to hold name.
sta 0
stx 0+2
ply Get matchbuf offset from stack.
@ -1140,7 +1140,7 @@ gv01 lda NameText-1,y Get next byte of name.
nextvar inc idxIndex
jmp varloop
vardone rts
vardone rts Return from wordmatch
;
; Match by file names; start by moving wordgs_text + trailing "*" to a GS/OS string
@ -1212,7 +1212,7 @@ filematch anop
iny Get length of name + 1
pea 0
phy
jsl ~NEW Request memory to hold name.
~NEW Request memory to hold name.
ply Get matchbuf offset from stack.
sta matchbuf,y Store allocated memory's
txa address in matchbuf array.
@ -1265,7 +1265,7 @@ isdir lda nummatch
inc a
pea 0
pha
jsl ~NEW
~NEW
ply
sta 8
stx 10
@ -1277,9 +1277,9 @@ isdir lda nummatch
txa
sta matchbuf+2,y
jsr copycstr
pei (2)
pei (0)
jsl nullfree
pei (2) Free entry that was
pei (0) allocated in non-directory
jsl nullfree section of code.
ldy NameLen
lda sepstyle
sta [8],y
@ -1350,7 +1350,7 @@ hl0 inx
pha
pea 0
phx
jsl ~NEW
~NEW
ply
pei (q+2)
pei (q)
@ -1401,7 +1401,7 @@ bl0 inx
pha
pea 0
phx
jsl ~NEW
~NEW
ply
pei (q+2)
pei (q)
@ -1416,7 +1416,7 @@ binext add2 p,#10,p
bra bilup
bidone anop
done rts
done rts Return from wordmatch.
startpos ds 2
cmdflag ds 2
@ -1570,7 +1570,7 @@ vt100key dc 65i2'undefined_char,0,0' ;^@ ... @
**************************************************************************
bindkeyfunc START
using keybinddata
p equ 0
@ -1608,7 +1608,7 @@ addb adc #0
beq next
phy
ph4 #128*6
jsl ~NEW
~NEW
sta p
stx p+2
ldy #128*6-2
@ -1678,7 +1678,7 @@ done return
**************************************************************************
bindkey START
str equ 0
func equ str+4
arg equ func+2
@ -1769,7 +1769,7 @@ foundit pla
inc a
pea 0
pha
jsl ~NEW
~NEW
sta str
stx str+2
pei (arg+2)

View File

@ -1,4 +1,4 @@
***********************************************************************
**************************************************************************
*
* The GNO Shell Project
*
@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: expand.asm,v 1.4 1998/07/20 16:23:03 tribby Exp $
* $Id: expand.asm,v 1.5 1998/08/03 17:30:28 tribby Exp $
*
**************************************************************************
*
@ -35,7 +35,7 @@ dummyexpand start ; ends up in .root
**************************************************************************
glob START
using vardata
count equ 0
@ -70,14 +70,15 @@ space equ buf+4
;
; noglob isn't set, so now we can actually start.
;
doglob jsl alloc1024 ;create an output buffer
sta buf
sta ptr
stx buf+2
stx ptr+2
jsl alloc1024 ;create a word buffer
sta wordbuf
stx wordbuf+2
doglob jsl alloc1024 Create an output buffer.
sta buf
stx buf+2
sta ptr ptr points to next
stx ptr+2 position in buf.
jsl alloc1024 Create a word buffer.
sta wordbuf
stx wordbuf+2
;
; Find the beginning of the next word
@ -193,14 +194,14 @@ doneflush jmp findword
; Hello, boys and goils, velcome to Tim's Magik Shoppe
;
; Ok, here's the plan:
; 1. We give _InitWildcard a PATHNAME.
; 2. _NextWildcard returns a FILENAME.
; 1. We give InitWildcardGS a PATHNAME.
; 2. NextWildcardGS returns a FILENAME.
; 3. We need to expand to the command-line the full pathname.
; 4. Therefore, we must put aside the prefix, and cat each file returned
; from _NextWildcard to the saved prefix, but, we must still pass
; the entire path to _InitWildcard.
; from NextWildcardGS to the saved prefix, but, we must still pass
; the entire path to InitWildcardGS.
; 5. This solves our problem with quoting. Expand the quotes before
; passing along to _InitWildcard, BUT the saved prefix we saved to cat
; passing along to InitWildcardGS, BUT the saved prefix we saved to cat
; to will still have the quotes in it, so that the tokenizer can deal
; with it. Whew!
;
@ -212,16 +213,18 @@ doneflush jmp findword
; Expand out the quoted stuff, and keep an eye out for that ubiquitous last
; filename separator... then we can isolate him!
;
globword stz filesep
jsl alloc1024
sta eptr
stx eptr+2
sta exppath
stx exppath+2
incad eptr ;leave room for pascal length
mv4 eptr,sepptr
globword stz filesep
jsl alloc1024 Alloc buffer for wildcard pattern.
sta exppath
stx exppath+2
incad @xa Leave room for length word
incad @xa
sta eptr
stx eptr+2
sta sepptr
stx sepptr+2
ldy #0
exploop lda [wordbuf],y
and #$FF
@ -273,66 +276,65 @@ copyback lda [wordbuf],y
cmp #0
bne copyback
;
; save the length, heh, heh, 16-bit sub will do it!
; Calculate length by subtracting sepptr from starting address
;
sub2 sepptr,exppath,@a
dec2 a ;don't count length byte or \0!
short a
dec2 a Don't count length word or \0
dec a
sta [exppath]
long a
;
; We now have enough to call _InitWildCard!!!
; [ let's mutex the rest so we don't have to fix _InitWC and _NextWC ;-) ]
; We now have enough to call InitWildCardGS!!!
; [ let's mutex the rest so we don't have to fix InitWC and NextWC ;-) ]
;
lock glob_mutex
;
; Call shell routine InitWildcard to initialize the filename pattern
; Call shell routine InitWildcardGS to initialize the filename pattern
;
stz count
mv4 exppath,initWCparm
Init_Wildcard initWCparm
stz count
mv4 exppath,initWCpath
InitWildcardGS initWCparm
ph4 #65 Allocate memory for
~NEW expanded name.
sta gname Store in direct
stx gname+2 page pointer
sta nWCname and in NextWildcardGS
stx nWCname+2 parameter block.
lda #65 Store maximum length at
sta [gname] beginning of result buf.
;
; hey, we better get some memory for these new files...
; Call shell routine NextWildcardGS to get the next name that matches.
;
ph4 #65
jsl ~NEW
sta gname
stx gname+2
sta nWCparm
stx nWCparm+2
;
; Call shell routine NextWildcard to get the next name that matches.
;
WCloop Next_Wildcard nWCparm
lda [gname]
and #$FF
beq nomore
WCloop NextWildcardGS nWCparm
ldy #2
lda [gname],y
beq nomore
;
; Keep count of how many paths are expanded
;
inc count
inc count
;
; Copy the original path (up to file separator) to output buffer
;
ldy #0
outtahere if2 @y,eq,filesep,globout
lda [wordbuf],y
jsr g_putspecial
iny
bra outtahere
ldy #0
outtahere if2 @y,eq,filesep,globout
lda [wordbuf],y
jsr g_putspecial
iny
bra outtahere
;
; Copy the expanded filename to output buffer
;
globout lda [gname]
and #$FF
tax
ldy #1
globoutta lda [gname],y
jsr g_putspecial
iny
dex
bne globoutta
globout ldy #2 Get returned length
lda [gname],y from GS/OS buffer.
tax
ldy #4
globoutta lda [gname],y Copy next character
jsr g_putspecial into buffer.
iny
dex
bne globoutta
;
; Place blank as separator after name and see if more are expanded.
;
@ -345,6 +347,7 @@ globoutta lda [gname],y
;
nomore anop
unlock glob_mutex
;
; Deallocate path buffers (we should probably alloc once, not each word... )
;
@ -354,7 +357,6 @@ nomore anop
ldx exppath+2
lda exppath
jsl free1024
unlock glob_mutex
lda count If somehing was expanded,
jne findword go find the next word.
@ -428,12 +430,18 @@ g_putbyte short a
glob_mutex key
; Parameter block for InitWildcard shell call (ORCA/M pp 414-415)
InitWCParm ds 4 Path name, with wildcard
;
; Parameter block for shell InitWildcardGS call (p 414 in ORCA/M manual)
;
InitWCParm dc i2'2' pCount
InitWCPath ds 4 Path name, with wildcard
dc i2'%00000001' Flags (this bit not documented!!!)
; Parameter block for NextWildcard shell call (ORCA/M pp 417-418)
nWCparm ds 4 Pointer to returned path name
;
; Parameter block for shell NextWildcardGS call (p 414 in ORCA/M manual)
;
nWCparm dc i2'1' pCount
nWCname ds 4 Pointer to returned path name
nomatch dc c'No match: ',h'00'
ignored dc c' ignored',h'0d00'
@ -563,7 +571,7 @@ braceloop lda [cmd]
; get text from standard input
;
stdinexpand jsr e_getbyte
ReadLine (#value,#MAXVAL,#13,#1),@a
ReadLine (#value,#MAXVAL,#13,#0),@a
sta valueln
bra chklen

View File

@ -651,108 +651,6 @@
dc i4'&a2'
mend
; ------------------
; Old shell calls
; ------------------
********************
* ERROR
********************
MACRO
&lab ERROR &a1
&lab p16 $105,&a1
mend
********************
* EXPORT
********************
macro
&lab EXPORT &a1
&lab p16 $116,&a1
mend
********************
* INIT_WILDCARD
********************
MACRO
&lab INIT_WILDCARD &a1
&lab p16 $109,&a1
mend
********************
* NEXT_WILDCARD
********************
MACRO
&lab NEXT_WILDCARD &a1
&lab p16 $10A,&a1
mend
********************
* PopVariables
********************
MACRO
&lab PopVariables &a1
&lab p16 $117,&a1
mend
********************
* PushVariables
********************
MACRO
&lab PushVariables &a1
&lab p16 $118,&a1
mend
********************
* READ_INDEXED
********************
MACRO
&lab READ_INDEXED &a1
&lab p16 $108,&a1
mend
********************
* READ_VARIABLE
********************
MACRO
&lab READ_VARIABLE &a1
&lab p16 $10B,&a1
mend
********************
* REDIRECT
********************
macro
&lab REDIRECT &a1
&lab p16 $110,&a1
mend
********************
* Set_Variable
********************
macro
&lab Set_Variable &a1
&lab p16 $106,&a1
mend
********************
* UnsetVariable
********************
macro
&lab UnsetVariable &a1
&lab p16 $115,&a1
mend
********************
* p16
********************
MACRO
&lab p16 &a1,&a2
&lab jsl $E100A8
dc i2'&a1'
dc i4'&a2'
mend
; ------------------
; Debugging
; ------------------
@ -786,33 +684,15 @@ pastName&SYSCNT anop
; Data Structures
; ------------------
********************
* dosin
********************
macro
&l dosin &adr
&l dc i"l:~&sysname&syscnt"
~&sysname&syscnt dc c"&adr"
mend
********************
* GSStr
********************
*****************************
* GSStr: GS/OS output string
*****************************
MACRO
&lab GSStr &string
&lab dc i2'L:&string'
dc c"&string"
mend
********************
* Str
********************
MACRO
&lab Str &string
&lab dc i1'L:&string'
dc c"&string"
mend
; ------------------
; Branch
; ------------------
@ -2047,7 +1927,7 @@ pastName&SYSCNT anop
********************
MACRO
&lab breakpoint &flag
lda check4debug
&lab lda check4debug
and #$80
beq *+4
brk &flag
@ -2072,3 +1952,23 @@ pastName&SYSCNT anop
.done
skip&syscnt anop
MEND
********************************************************************
* ~NEW: call ~NEW or DB~NEW, depending upon whether debug is wanted
********************************************************************
MACRO
&lab ~NEW
&lab anop
jsl ~NEW
MEND
***************************************************************************
* ~DISPOSE: call ~DISPOSE or DB~DISPOSE, depending upon if debug is wanted
***************************************************************************
MACRO
&lab ~DISPOSE
&lab anop
jml ~DISPOSE
MEND

View File

@ -1,7 +1,7 @@
/*
* Resources for version and comment
*
* $Id: gsh.rez,v 1.3 1998/07/20 16:23:06 tribby Exp $
* $Id: gsh.rez,v 1.4 1998/08/03 17:30:30 tribby Exp $
*/
#define PROG "gsh"
@ -16,7 +16,7 @@
resource rVersion (1, purgeable3) {
{ 2, 0, 0, /* Version 2.0.0 */
development, /* development|alpha|beta|final|release */
2 }, /* non-final release number */
3 }, /* non-final release number */
verUS, /* Country */
PROG, /* Program name */
DESC

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: hash.asm,v 1.4 1998/07/20 16:23:06 tribby Exp $
* $Id: hash.asm,v 1.5 1998/08/03 17:30:19 tribby Exp $
*
**************************************************************************
*
* HASH.ASM
* By Tim Meekins & Greg Thompson
* Modified by Dave Tribby for GNO 2.0.6
*
* Command hashing routines
*
@ -179,7 +180,7 @@ tmp ds 2
**************************************************************************
dohash START
using hashdata
h equ 1
@ -221,7 +222,7 @@ mktsize asl a
asl a
pea 0
pha
jsl ~NEW
~NEW
sta table
stx table+2
;
@ -300,7 +301,7 @@ hashloop pei (files+2)
; table[h] = (tablenode *)malloc(sizeof(tablenode))
;
gotit ph4 #tn_size
jsl ~NEW
~NEW
sta temp
stx temp+2
ldy h
@ -358,7 +359,7 @@ done anop
**************************************************************************
search START
ptr equ 1
full_path equ ptr+4
qh equ full_path+4
@ -438,7 +439,7 @@ found lda [ptr]
adc #33 Add 33 (max prog name size + 1)
pea 0
pha
jsl ~NEW Allocate memory,
~NEW Allocate memory,
sta full_path storing address at
stx full_path+2 functional return value.
@ -553,137 +554,132 @@ done return
**************************************************************************
dir_search START
using hashdata
temp2 equ 0
temp equ temp2+4
entry equ temp+4
numEntries equ entry+2
ptr equ numEntries+2
space equ ptr+4
temp2 equ 0
temp equ temp2+4
entry equ temp+4
numEntries equ entry+2
ptr equ numEntries+2
space equ ptr+4
subroutine (4:dir,2:dirNum,4:files),space
subroutine (4:dir,2:dirNum,4:files),space
;
; Open directory name passed as 1st parameter
;
ld2 3,ORec
pei (dir+2) Turn "dir" c-string into
pei (dir) a GS/OS string, allocated
ld2 3,ORec
pei (dir+2) Turn "dir" c-string into
pei (dir) a GS/OS string, allocated
jsr c2gsstr via ~NEW.
sta ORecPath
stx ORecPath+2
sta ORecPath
stx ORecPath+2
phx Put GS/OS string addr on stack
pha so it can be deallocated.
Open ORec Open that file.
bcc goodopen If there was an error,
jsl nullfree Free the GS/OS string
jmp exit and exit.
Open ORec Open that file.
bcc goodopen If there was an error,
jsl nullfree Free the GS/OS string
jmp exit and exit.
goodopen jsl nullfree Free the GS/OS string.
goodopen jsl nullfree Free the GS/OS string.
;
; Set up parameter block for GetDirEntry
;
mv2 ORecRef,DRecRef Copy the file ref num from open.
stz DRecBase Zero the base and
stz DRecDisp displacement.
jsl alloc256 Get 256 bytes for name.
sta DRecName Store address in param block
sta ptr and also in direct page var.
stx DRecName+2
stx ptr+2
lda #254 Set total length of GS/OS buffer in
sta [ptr] bufsize word (save byte for 0 at end).
GetDirEntry DRec Make DirEntry call.
mv2 ORecRef,DRecRef Copy the file ref num from open.
stz DRecBase Zero the base and
stz DRecDisp displacement.
GetDirEntry DRec Make DirEntry call.
mv2 DRecEntry,numEntries Save number of entries.
ld2 1,(DRecBase,DRecDisp)
stz entry # processed entries = 0.
loop lda entry If number of processed entries
cmp numEntries equals the total number,
jge done we are all done.
GetDirEntry DRec
mv2 DRecEntry,numEntries Save number of entries.
ld2 1,(DRecBase,DRecDisp)
stz entry # processed entries = 0.
;
; Process each entry in the directory
;
loop lda entry If number of processed entries
cmp numEntries equals the total number,
jge done we are all done.
;
; Get directory entry's information
;
GetDirEntry DRec
; Check for filetype $B3: GS/OS Application (S16)
if2 DRecFileType,eq,#$B3,goodfile
if2 DRecFileType,eq,#$B3,goodfile
; Check for filetype $B5: GS/OS Shell Application (EXE)
if2 @a,eq,#$B5,goodfile
if2 @a,eq,#$B5,goodfile
; Check for filetype $B0, subtype $0006: Shell command file (EXEC)
cmp #$B0
bne nextfile
lda DRecAuxType
cmp #$06
bne nextfile
lda DRecAuxType+2
bne nextfile
cmp #$B0
bne nextfile
lda DRecAuxType
cmp #$06
bne nextfile
lda DRecAuxType+2
bne nextfile
;
; This directory entry points to an executable file.
; Included it in the file list.
;
goodfile inc hash_numexe Bump the (global) # files.
ldy #2 Get length word from GS/OS string
lda [ptr],y in result buffer.
add2 @a,#4,@y Use length + 4 as index
lda #0 to store terminating
sta [ptr],y null byte.
add2 ptr,#4,@a
pei (ptr+2) ;for copycstr
pha
pei (ptr+2)
pha
jsr lowercstr Convert name to lower case.
ldy #fn_next temp = files->next.
lda [files],y
sta temp
ldy #fn_next+2
lda [files],y
sta temp+2
ldx TempRBlen Get length word from GS/OS string
short a
stz TempRBname,x Store terminating null byte.
long a
ph4 #fn_size temp2 = new entry.
jsl ~NEW
sta temp2
stx temp2+2
ph4 #TempRBname
jsr lowercstr Convert name to lower case.
ldy #fn_next files->next = temp2
sta [files],y
ldy #fn_next+2
ph4 #TempRBname Push src addr for copycstr.
ldy #fn_next temp = files->next.
lda [files],y
sta temp
ldy #fn_next+2
lda [files],y
sta temp+2
ph4 #fn_size temp2 = new entry.
~NEW
sta temp2
stx temp2+2
ldy #fn_next files->next = temp2
sta [files],y
ldy #fn_next+2
txa
pha
sta [files],y
pha
sta [files],y
lda temp2
clc
adc #fn_name
pha
jsr copycstr
lda temp2
clc
adc #fn_name
pha
jsr copycstr Copy string into entry.
lda dirNum temp2->dirnum = dirNum
sta [temp2]
lda dirNum temp2->dirnum = dirNum
sta [temp2]
ldy #fn_next temp2->next = temp
lda temp
sta [temp2],y
ldy #fn_next+2
lda temp+2
sta [temp2],y
ldy #fn_next temp2->next = temp
lda temp
sta [temp2],y
ldy #fn_next+2
lda temp+2
sta [temp2],y
nextfile inc entry Bump entry number
jmp loop and stay in the loop.
nextfile inc entry Bump entry number
jmp loop and stay in the loop.
;
; Done adding entries to the hash table from this directory
;
done ldx DRecName+2 Free the Name buffer.
lda DRecName
jsl free256
done anop
ld2 1,ORec ORec.pCount = 1
Close ORec
ld2 1,ORec ORec.pCount = 1
Close ORec
exit return
@ -700,7 +696,7 @@ DRecRef ds 2 refNum
DRecFlag ds 2 flags: extended/not
DRecBase dc i'0' base: displacement is absolute entry #
DRecDisp dc i'0' displacement: get tot # active entries
DRecName ds 4 name: result buf
DRecName dc i4'TempResultBuf' name: result buf
DRecEntry ds 2 entryNum: entry # whose info is rtrned
DRecFileType ds 2 fileType
DRecEOF ds 4 eof: # bytes in data fork
@ -710,6 +706,12 @@ DRecMod ds 8 modDateTime
DRecAccess ds 2 access attribute
DRecAuxType ds 4 auxType
; GS/OS result buffer for getting a directory entry's name
TempResultBuf dc i2'68' Total length = 64 bytes + 4 for length
TempRBlen ds 2 Value's length returned here
TempRBname ds 64 Allow 64 bytes for returned name
ds 1 Extra byte for null string termination
END
**************************************************************************
@ -719,7 +721,7 @@ DRecAuxType ds 4 auxType
**************************************************************************
hashpath START
using hashdata
using vardata
@ -749,23 +751,13 @@ end equ space+3
; Allocate special file node
;
ph4 #fn_size
jsl ~NEW
~NEW
sta hash_files
sta files
stx hash_files+2
stx files+2
;
; Allocate memory for ExpandPath GS/OS result string
;
jsl alloc256
sta EPoutputPath
stx EPoutputPath+2
sta ptr
stx ptr+2
lda #254
sta [ptr]
;
; Initialize counters and pointers
;
lda #0
@ -779,7 +771,7 @@ end equ space+3
sta [files],y
sta [files]
;
; Determine length of $PATH environment variable string
; Get value of $PATH environment variable string
;
ph4 #pathname
jsl getenv
@ -911,55 +903,77 @@ storeit phy Push source index onto stack
long a Restore long accumulator.
;
; Convert the input pathname into the corresponding
; full pathname with colons as separators.
; Convert the input pathname into the corresponding full pathname with
; colons as separators. Use temp result buf this time, just to get length.
;
xpandit ExpandPath EPParm
xpandit anop
ld4 TempResultBuf,EPoutputPath
ExpandPath EPParm
;
; Allocate memory for ExpandPath GS/OS result string
;
lda TempRBlen Get length of value.
inc2 a Add 4 bytes for result buf len words.
inc2 a
sta len Save result buf len.
inc a Add 1 more for terminator.
pea 0
pha
~NEW Request the memory.
sta EPoutputPath Store address in ReadVariable
stx EPoutputPath+2 parameter block and
sta ptr direct page pointer.
stx ptr+2
ora ptr+2 If address == NULL,
jeq donext get next entry.
lda len Store result buffer length
sta [ptr] at beginning of buf.
ExpandPath EPParm Call again, and get the name.
bcc epok
ldx #^eperrstr Print error message:
lda #eperrstr "Invalid pathname syntax."
jsr errputs
jsl nullfree Free GS/OS string (pushed earlier).
donext jsl nullfree Free GS/OS string (pushed earlier).
jmp next Get the next one.
epok jsl nullfree Free GS/OS string (addr on stack)
epok anop
jsl nullfree Free source string (addr on stack)
clc Set ptr to GS/OS string
lda EPoutputPath portion of result buffer.
adc #2
sta ptr
lda EPoutputPath+2
ldy #2
lda [ptr],y Get length of text
sta len
tay
iny4 and add four.
short a
lda #0 Store 0 at end of text so it
sta [ptr],y can act like a C string.
long a
;
; Move text in GS/OS result buffer to beginning of buffer
; (overwritting the two length words).
;
clc Source is result
lda ptr buffer plus
adc #4 four bytes.
tay
lda ptr+2
adc #0
sta ptr+2
lda [ptr] Get GS/OS string's length word
sta len and store in len.
inc2 a Store 0 at end of text
tay in string.
lda #0
sta [ptr],y
pea 0 Allocate memory the
phy size of the expanded path.
jsl ~NEW
pei (ptr+2)
inc2 ptr
pei (ptr)
phx
pha
sta ptr
stx ptr+2
phy
pei (ptr+2) Destination is first
pei (ptr) byte of buffer.
jsr copycstr
lda ptr
ldy pathnum
sta hash_paths,y Store address of this
txa path's address in the
lda ptr+2 path's address in the
sta hash_paths+2,y hash path table.
jsr copycstr
ldy len
ldy len
beq bumppnum
dey
lda [ptr],y If last character
@ -1051,13 +1065,6 @@ filesdone anop
noprint ld2 1,hash_print Set print flag.
;
; Free memory allocated for ExpandPath output string
;
lda EPoutputPath
ldx EPoutputPath+2
jsl free256
;
; Create the hash table from the file list.
;
@ -1088,6 +1095,11 @@ EPParm dc i'2' pCount = 2
EPinputPath ds 4 ptr to inputPath (GS/OS string)
EPoutputPath ds 4 ptr to outputPath (Result buffer)
; GS/OS result buffer for getting the full length of expanded name
TempResultBuf dc i2'5' Only five bytes total.
TempRBlen ds 2 Value's length returned here.
ds 1 Only 1 byte for value.
eperrstr dc c'rehash: Invalid pathname syntax.',h'0d00'
toomanyerr dc c'rehash: Too many paths specified.',h'0d00'
nopatherr dc c'rehash: PATH string is not set.',h'0d00'

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: history.asm,v 1.4 1998/07/20 16:23:07 tribby Exp $
* $Id: history.asm,v 1.5 1998/08/03 17:30:20 tribby Exp $
*
**************************************************************************
*
@ -65,7 +65,7 @@ histCmd gequ 4
;=========================================================================
InsertHistory START
using HistoryData
using global
@ -85,7 +85,7 @@ space equ histvalptr+4
clc
adc #4+1
pha
jsl ~NEW
~NEW
sta ptr
stx ptr+2
ora ptr+2

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: invoke.asm,v 1.5 1998/07/20 16:23:07 tribby Exp $
* $Id: invoke.asm,v 1.6 1998/08/03 17:30:21 tribby Exp $
*
**************************************************************************
*
@ -77,57 +77,39 @@ end equ sfile+4
phd
tcd
;
; standard input
; Redirect standard input
;
ora2 sfile,sfile+2,@a
beq execa
pei (sfile+2) ;for c2pstr
pei (sfile)
pei (sfile+2)
pei (sfile)
jsr cstrlen
inc a
pea 0
pha
jsl ~NEW
sta RedirectFile
stx RedirectFile+2
phx
pha
jsr c2pstr
stz RedirectDev
stz RedirectApp
Redirect RedirectParm
ora2 sfile,sfile+2,@a If no name provided,
beq execa skip it.
pei (sfile+2) Convert c-string
pei (sfile) filename to
jsr c2gsstr GS/OS string.
sta RedirectFile Store filename pointer
stx RedirectFile+2 in parameter block.
stz RedirectDev stdin devnum = 0.
stz RedirectApp Cannot append.
RedirectGS RedirectParm
php
ph4 RedirectFile
ph4 RedirectFile Free allocated GS/OS string.
jsl nullfree
plp
bcc execa
ldx #^err1 Print error message:
lda #err1 'Error redirecting standard input.'
jmp badbye
bcc execa If RedirectGS failed,
ldx #^err1 print error message:
lda #err1 'Error redirecting standard input.'
jmp badbye and quit.
;
; standard output
; Redirect standard output
;
execa ora2 dfile,dfile+2,@a
beq execb
pei (dfile+2) ;for c2pstr
pei (dfile)
pei (dfile+2)
pei (dfile)
jsr cstrlen
inc a
pea 0
pha
jsl ~NEW
jsr c2gsstr
sta RedirectFile
stx RedirectFile+2
phx
pha
jsr c2pstr
ld2 1,RedirectDev
ld2 1,RedirectDev stdout devnum = 1
mv2 app,RedirectApp
Redirect RedirectParm
RedirectGS RedirectParm
php
ph4 RedirectFile
jsl nullfree
@ -137,30 +119,18 @@ execa ora2 dfile,dfile+2,@a
lda #err2 'Error redirecting standard output.'
jmp badbye
;
; standard error
; Redirect standard error
;
execb ora2 efile,efile+2,@a
beq execc
pei (efile+2) ;for c2pstr
pei (efile)
pei (efile+2)
pei (efile)
jsr cstrlen
inc a
pea 0
pha
jsl ~NEW
jsr c2gsstr
sta RedirectFile
stx RedirectFile+2
phx
pha
jsr c2pstr
ld2 2,RedirectDev
mv2 eapp,RedirectApp
; Make shell call to recirect I/O
Redirect RedirectParm
RedirectGS RedirectParm
php
ph4 RedirectFile
jsl nullfree
@ -170,7 +140,7 @@ execb ora2 efile,efile+2,@a
lda #err3 'Error redirecting standard error.'
jmp badbye
;
; is input piped in?
; Is input piped in?
;
execc lda pipein
beq execd
@ -181,7 +151,7 @@ execc lda pipein
lda pipein
SetInputDevice (#3,@xa)
;
; is output piped?
; Is output piped?
;
execd lda pipeout
beq exece
@ -191,14 +161,18 @@ execd lda pipeout
ldx #0
lda pipeout
SetOutputDevice (#3,@xa)
exece anop
;
; All the file and pipe redirection has been handled. Time to say goodbye.
;
goodbye ldy #0
bra exit
badbye jsr errputs
cop $7F ; get out of the way
ldy #1
exit lda space
sta end-3
lda space+1
@ -213,15 +187,19 @@ exit lda space
rtl
;
; Parameter block for shell call to redirect I/O (ORCA/M manual p.425)
RedirectParm anop
;
RedirectParm dc i2'3' pCount
RedirectDev ds 2 Dev num (0=stdin,1=stdout,2=errout)
RedirectApp ds 2 Append flag (0=delete)
RedirectFile ds 4 File name (GS/OS input string)
;
; Parameter block for GS/OS call to close a file
CloseParm dc i'1'
CloseRef dc i'0'
;
CloseParm dc i'1' pCount
CloseRef dc i'0' refNum
err1 dc c'gsh: Error redirecting standard input.',h'0d00'
err2 dc c'gsh: Error redirecting standard output.',h'0d00'

View File

@ -1,4 +1,4 @@
************************************************************************
**************************************************************************
*
* The GNO Shell Project
*
@ -6,12 +6,13 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: jobs.asm,v 1.4 1998/07/20 16:23:07 tribby Exp $
* $Id: jobs.asm,v 1.5 1998/08/03 17:30:22 tribby Exp $
*
**************************************************************************
*
* JOBS.ASM
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
*
* Job control handling routines
*
@ -184,7 +185,7 @@ done return
;====================================================================
palloc START
using pdata
using global
@ -211,7 +212,7 @@ end equ pid+2
pha
ph4 #p_space
jsl ~NEW
~NEW
sta pp
stx pp+2
@ -271,7 +272,7 @@ in02 anop
inc a
pea 0
pha
jsl ~NEW
~NEW
pei (cmd+2)
pei (cmd)
phx
@ -318,7 +319,7 @@ noprint anop
;====================================================================
pallocpipe START
using pdata
using global
@ -346,7 +347,7 @@ end equ pid+2
pha
ph4 #p_space
jsl ~NEW
~NEW
sta pp
stx pp+2
@ -380,7 +381,7 @@ bg01 ldy #p_flags
inc a
pea 0
pha
jsl ~NEW
~NEW
pei (cmd+2)
pei (cmd)
phx

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: main.asm,v 1.5 1998/07/20 16:23:08 tribby Exp $
* $Id: main.asm,v 1.6 1998/08/03 17:30:22 tribby Exp $
*
**************************************************************************
*
@ -14,6 +14,8 @@
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
*
* Startup portion of shell
*
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | |
* ^ ^ ^ ^ ^ ^
@ -58,7 +60,7 @@ init START
MAIN START
using global
p equ 0
@ -101,7 +103,7 @@ argloop dec argc Decrement argument count.
inc ExecFlag
inc FastFlag
ph4 #1024
jsl ~NEW
~NEW
sta ExecCmd
sta p
stx ExecCmd+2

View File

@ -6,53 +6,153 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: mmdebug.asm,v 1.2 1998/04/24 15:38:33 gdr-ftp Exp $
* $Id: mmdebug.asm,v 1.3 1998/08/03 17:30:23 tribby Exp $
*
**************************************************************************
*
* MMDEBUG.ASM
* By Tim Meekins
* Rewritten by Dave Tribby for GNO 2.0.6
*
* Alternate routines for ~NEW and ~DISPOSE with extra debugging
*
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | |
* ^ ^ ^ ^ ^ ^
**************************************************************************
*
* Interfaces defined in this file:
*
*
**************************************************************************
mcopy /obj/gno/bin/gsh/mmdebug.mac
dummy start ; ends up in .root
dummymmdebug start ; ends up in .root
end
setcom 60
~NEW START
hand equ 0
ptr equ 4
_~NEW name
DB~NEW START
subroutine (4:size),8
hand equ 0 Handle allocated by memory manager
ptr equ hand+4 Pointer dereference of handle
space equ ptr+4
NewHandle (size,~USER_ID,#$C018,#0),hand
lda [hand]
subroutine (4:size),space
lda size If size is 0,
ora size+2
bne newh
brk $A1 allocation error #1.
bra foul
;
; Allocate memory block of requested size using NewHandle
;
newh anop
pha Reserve space for
pha returned handle address.
ph4 size Amount of memory to allocate.
lda ~USER_ID Add the "auxID" tag
eor #$0D00 to the user ID so we
pha can identify our allocations.
pea $C018
pea 0
pea 0
tool $0902 NewHandle (size,~USER_ID,#$C018,#0)
plx Store handle at "hand",
stx hand preserving contents of
plx possible error code
stx hand+2 in accumulator.
bcc deref If there is a MM error,
brk $A2 allocation error #2.
foul stz ptr
stz ptr+2
bra goback
deref lda [hand] Dereference the handle.
sta ptr
ldy #2
lda [hand],y
sta ptr+2
return 4:ptr
;
; Fill memory with recognizable pattern
;
lda #"~~"
ldy size
dec_index dey
dey
bmi full
sta [ptr],y
bra dec_index
full short a In case size was odd,
sta [ptr] be sure the first byte
long a gets the pattern.
goback return 4:ptr Return pointer to caller.
END
~DISPOSE START
DB~DISPOSE START
hand equ 0
checkptr equ 4
_~DISPOSE name
space equ checkptr+4
subroutine (4:ptr),8
subroutine (4:ptr),space
;
; First check: is address > $007FFFFF?
;
lda ptr+2
and #$FF80
beq findit
lda ptr
ldx ptr+2
brk $D1 Deallocate error #1.
bra goback
FindHandle ptr,hand
lda [hand]
sta checkptr
;
; Second check: is there a valid handle to this pointer?
;
findit FindHandle ptr,hand
lda hand Error if FindHandle
ora hand+2 returned 0.
bne ckptr
brk $D2 Deallocate error #2.
bra goback
ckptr lda [hand] Dereference the
sta checkptr found handle.
ldy #2
lda [hand],y
sta checkptr+2
eor ptr+2
eor ptr
eor checkptr
sta checkptr+2
cmp ptr+2 If the pointer isn't
bne errD3 the first byte
lda checkptr of the handle,
cmp ptr there is a problem.
beq chkid
errD3 brk $D3
bra goback
chkid ldy #6 Get User ID word
lda [hand],y from handle header.
eor #$0D00 Remove aux ID of $0D00.
cmp ~USER_ID
beq okay
lda [hand],y
brk $D4 Deallocate error #4.
bra goback
brk $55
okay DisposeHandle hand Deallocate the memory.
bcc goback
brk $D5 Deallocate error #5.
goback return
okay DisposeHandle hand
return
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: prompt.asm,v 1.4 1998/07/20 16:23:08 tribby Exp $
* $Id: prompt.asm,v 1.5 1998/08/03 17:30:23 tribby Exp $
*
**************************************************************************
*
@ -66,8 +66,8 @@ precmd equ prompt
getvar ph4 #promptname
jsl getenv
php
sei ;interrupt free environment
php Turn off interrupts: mutex
sei won't do what we want!
sta promptgsbuf Save pointer to GS/OS result buffer.
stx promptgsbuf+2 If there is no memory to hold it,
@ -107,57 +107,59 @@ done jsr standend
jsr cursoron
donemark2 anop
plp Restore interrupts.
pei (promptgsbuf+2) Free $PROMPT value buffer
pei (promptgsbuf)
jsl nullfree
plp Restore interrupts.
jsr flush
return
special lda [prompt]
;
; Previous character was a "%". Handle special character flags
;
special lda [prompt] Get character following "%".
incad prompt
and #$FF
beq done
cmp #'%'
beq _putchar
cmp #'h'
beq done If end of string, all done.
cmp #'%' If another "%",
beq _putchar print the "%"
cmp #'h' If 'h'
beq phist
cmp #'!'
beq phist
cmp #'t'
cmp #'!' or '!',
beq phist print history number.
cmp #'t' If 't'
beq ptime
cmp #'@'
beq ptime
cmp #'S'
jeq pstandout
cmp #'s'
jeq pstandend
cmp #'U'
jeq punderline
cmp #'u'
jeq punderend
cmp #'d'
cmp #'@' or '@',
beq ptime print time (am/pm format)
cmp #'S' If 'S',
jeq pstandout turn inverse mode on.
cmp #'s' If 's',
jeq pstandend turn inverse mode off.
cmp #'U' If 'U',
jeq punderline turn underline mode on.
cmp #'u' If 'u',
jeq punderend turn underline mode off
cmp #'d' If 'd'
jeq pcwd
cmp #'/'
jeq pcwd
cmp #'c'
cmp #'/' or '/',
jeq pcwd print working directory.
cmp #'c' If 'c'
jeq pcwdend
cmp #'C'
jeq pcwdend
cmp #'.'
jeq pcwdend
cmp #'n'
jeq puser
cmp #'W'
jeq pdate1
cmp #'D'
jeq pdate2
cmp #'~'
jeq ptilde
cmp #'C' or 'C'
jeq pcwdend
cmp #'.' or '.',
jeq pcwdend print final part of wrk dir.
cmp #'n' If 'n',
jeq puser print $USER
cmp #'W' If 'W',
jeq pdate1 print date (mm/dd/yy)
cmp #'D' If 'D',
jeq pdate2 print date (yy-mm-dd)
cmp #'~' If '~',
jeq ptilde print wrk dir with ~ subs.
jmp promptloop If none of these characters, ignore it.
jmp promptloop
;
; Put history number
;
@ -165,6 +167,7 @@ phist lda lasthist
inc a
jsr WriteNum
jmp promptloop
;
; Print current time
;
@ -197,13 +200,14 @@ ptime3 lda #'p'
ptime4 jsr putchar
lda #'m'
jmp _putchar
;
; Set Stand Out
; Set Stand Out (turn on inverse mode)
;
pstandout jsr standout
jmp promptloop
;
; UnSet Stand Out
; UnSet Stand Out (turn off inverse mode)
;
pstandend jsr standend
jmp promptloop
@ -220,108 +224,93 @@ punderend jsr underend
;
; Current working directory
;
pcwd jsl alloc1024
pcwd anop
pea 0
jsl getpfxstr Get value of prefix 0.
sta pfx
stx pfx+2
sta GPpfx
stx GPpfx+2
lda #1024
sta [pfx]
GetPrefix GPParm
ldy #2
lda [pfx],y
clc
adc #3
sta offset
ldy #4
pcwd1 lda [pfx],y
and #$FF
jsr toslash
phy
jsr putchar
ply
iny
cpy offset
bcc pcwd1
ldx pfx+2
lda pfx
jsl free1024
ora pfx+2 If NULL pointer returned,
jeq promptloop an error was reported.
ldy #4 Text starts at byte 4.
pcwd1 lda [pfx],y Get next
and #$FF character.
beq freepfx Done when at end of string.
jsr toslash Convert to slash.
phy Hold index on stack
jsr putchar while printing character.
ply
iny Bump index
bra pcwd1 and stay in loop.
freepfx ph4 pfx Free the current directory buffer.
jsl nullfree
jmp promptloop
;
; Current tail of working directory
; Tail of current working directory
;
pcwdend anop
jsl alloc1024
pea 0
jsl getpfxstr Get value of prefix 0.
sta pfx
stx pfx+2
sta GPpfx
stx GPpfx+2
lda #1024
sta [pfx]
GetPrefix GPParm
ldy #2
lda [pfx],y
clc
adc #3
ora pfx+2 If NULL pointer returned,
jeq promptloop an error was reported.
ldy #2 Get string's length word
lda [pfx],y from bytes 2 & 3.
clc Add 3 to get offset
adc #3 from beginning of buffer.
sta offset
tay
pcwdend1 dey
bmi pcwdend2
lda [pfx],y
and #$FF
cmp #':'
bne pcwdend1
pcwdend1 dey If we've backed up to the beginning,
bmi pcwdend2 we can't go any further!
lda [pfx],y Get next character.
and #$FF
cmp #':' If it's not ':',
bne pcwdend1 keep searching backward.
pcwdend2 iny
cpy offset
beq pcwdend3
jeq freepfx Free the current directory buffer.
lda [pfx],y
and #$FF
cmp #':'
beq pcwdend3
jeq freepfx Free the current directory buffer.
phy
jsr putchar
ply
bra pcwdend2
pcwdend3 ldx pfx+2
lda pfx
jsl free1024
jmp promptloop
;
; Current working directory substituting '~' if necessary
;
ptilde anop
jsl alloc1024
pea 0
jsl getpfxstr Get value of prefix 0.
sta pfx
stx pfx+2
sta GPpfx
stx GPpfx+2
lda #1024
sta [pfx]
GetPrefix GPParm
ldy #2
lda [pfx],y
clc
adc #4
tay
lda #0
sta [pfx],y
pei (pfx+2)
lda pfx
clc
adc #4
ora pfx+2 If NULL pointer returned,
jeq promptloop an error was reported.
lda pfx Otherwise, restore low-order address.
clc Add 4 to start of buffer
adc #4 so it can be treated like
bcc pushad a c-string.
inx
pushad phx
pha
jsl path2tilde
phx
pha
jsr puts
jsl ~DISPOSE
ldx pfx+2
lda pfx
jsl free1024
jmp promptloop
jsl path2tilde Convert $HOME to "~"
phx Push addr onto stack
pha for nullfree.
jsr puts Print tilde string.
jsl nullfree Free the converted string.
jmp freepfx Free the current directory buffer.
;
; Write user name
;
@ -344,6 +333,7 @@ printit jsr puts
jsl nullfree
goploop jmp promptloop
;
; Write date as mm/dd/yy
;
@ -366,6 +356,7 @@ pdate1 ReadTimeHex (@a,year,monday,@a)
xba
jsr WriteNum
jmp promptloop
;
; Write date as yy-mm-dd
;
@ -388,6 +379,7 @@ pdate2 ReadTimeHex (@a,year,monday,@a)
inc a
jsr WriteNum
jmp promptloop
;
; check for \ quote
;
@ -441,16 +433,13 @@ write3 Int2Dec (@a,#num,#4,#0)
; Name of alias to execute before prompt
precmdstr dc c'precmd',h'00'
; Parameter block for GetPrefix GS/OS call
GPParm dc i2'2'
dc i2'0'
GPpfx dc a4'0'
; Names of environment variables
promptname gsstr 'prompt'
username gsstr 'user'
; Default prompt
dfltPrompt dc c'% ',h'00'
num dc c'0000',h'00'
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: shell.asm,v 1.4 1998/07/20 16:23:09 tribby Exp $
* $Id: shell.asm,v 1.5 1998/08/03 17:30:23 tribby Exp $
*
**************************************************************************
*
@ -295,7 +295,9 @@ no_ovf phx
sbc #2 addr of original output buffer.
bcs no_undf
dex
no_undf jsl free256
no_undf phx
pha
jsl nullfree
rts
gshrcName dc c'/gshrc',h'00'
@ -312,35 +314,64 @@ gshrcName dc c'/gshrc',h'00'
;=========================================================================
AppendHome START
outPtr equ 0
len equ 4
subroutine (4:str),6
jsl alloc256 Allocate memory for
stx outPtr1+2 GS/OS output buffer
sta outPtr1 that will hold the
stx outPtr+2 value of $HOME and
sta outPtr the final result.
outPtr equ 0 Pointer into allocated memory
str_len equ outPtr+4 Length of string parameter
buf_len equ str_len+2 Size of GS/OS buffer
space equ buf_len+2
subroutine (4:str),space
lock mutex
;
; Get the variable's length using ReadVariableGS
;
ld4 TempResultBuf,RVresult Use temporary result buf.
ReadVariableGS ReadVar Get length.
;
; Allocate memory for value string
;
pei (str+2) Get length of
pei (str) string to be
jsr cstrlen appended.
sta len
sta str_len
lda #255 Max len is 255 (leave room
sta [outPtr] for C string terminator).
lda TempRBlen Get length of value.
bne notnull If 0,
inc a increment because "@" will be used.
notnull inc2 a Add 4 bytes for result buf len words.
inc2 a
clc Add length of string parameter.
adc str_len
sta buf_len Save result buf length.
inc a Add 1 more for terminating null byte.
pea 0
pha
~NEW Request the memory.
sta RVresult Store address in ReadVariable
stx RVresult+2 parameter block and
sta outPtr direct page pointer.
stx outPtr+2
ora outPtr+2 If address == NULL,
beq exit return NULL to user.
ReadVariableGS rvbl ReadVariable $HOME
lda buf_len Store result buffer length
sta [outPtr] at beginning of buf.
;
; Read the full value into the allocated memory
;
ReadVariableGS ReadVar ReadVariable $HOME
bcs doAtSign If error, use @/
ldy #2
lda [outPtr],y
beq doAtSign ; $HOME not defined?
clc
adc #4 ; turn into a cstring
tay
short m
lda #0
ldy #2 Get length of
lda [outPtr],y GS/OS string.
beq doAtSign If $HOME not defined, use "@".
clc
adc #4 Turn into a c-string
tay by storing a 0 byte
short m after the last $HOME
lda #0 character.
sta [outPtr],y
long m
bra doAppend
@ -351,12 +382,12 @@ len equ 4
doAtSign lda atSign
ldy #4
sta [outPtr],y
lda #1
ldy #2
sta [outPtr],y
lda #1 Set GS/OS buffer
ldy #2 string length word
sta [outPtr],y to 1.
doAppend anop
ldy #0
ldy #4 Start index beyond length words.
short m
lp lda [outPtr],y
beq noSep
@ -369,7 +400,7 @@ lp lda [outPtr],y
noSep lda #':' No separator found; use ":".
foundSep sta [str] Store separator at end of string.
foundSep sta [str] Store sep at start of appended string.
long m
pei (str+2)
@ -388,30 +419,44 @@ pushptr phx
clc Add 2 bytes to address of
lda outPtr GS/OS output buffer to
adc #2 get address if GS/OS
adc #2 get address of GS/OS
bcc no_ovf input string.
inc outPtr+2
no_ovf sta outPtr
lda [outPtr] Adjust string length
clc to include appended
adc len string (parameter).
adc str_len string (parameter).
sta [outPtr]
;
; NOTE: The returned value points to a GS/OS string, two bytes offset
; from the allocated memory for a GS/OS result buffer. When the
; memory is deallocated, the address must be adjusted back.
;
exit unlock mutex
return 4:outPtr
mutex key
atSign dc c'@',i1'0'
;
; Parameter block for Shell call ReadVariable (p 423 in ORCA/M reference)
rvbl dc i2'3' pCount
;
ReadVar anop
dc i2'3' pCount
dc a4'home' address of variable's name
outPtr1 dc a4'0' pointer to result buffer
dc i2'0' value of 'Export' flag (returned)
RVresult ds 4 GS/OS Output buffer ptr
ds 2 export flag (returned)
;
; GS/OS result buffer for getting the full length of the PATH env var.
;
TempResultBuf dc i2'5' Only five bytes total.
TempRBlen ds 2 Value's length returned here.
ds 1 Only 1 byte for value.
;
; "HOME" as a GS/OS string
;
home gsstr 'HOME'
END

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: shellutil.asm,v 1.4 1998/07/20 16:23:09 tribby Exp $
* $Id: shellutil.asm,v 1.5 1998/08/03 17:30:24 tribby Exp $
*
**************************************************************************
*
* SHELLUTIL.ASM
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
*
* Utility functions used by the shell. Mainly string functions.
*
@ -183,171 +184,6 @@ done sta [q],y
END
;=========================================================================
;
; Converts a pascal string to a c string. This allocates memory for the
; new c string.
;
;=========================================================================
p2cstr START
cstr equ 1
space equ cstr+4
p equ space+2
end equ p+4
tsc
sec
sbc #space-1
tcs
phd
tcd
lda [p]
and #$FF
inc a
pea 0
pha
jsl ~NEW
sta cstr
stx cstr+2
lda [p]
incad p
and #$FF
tax
short a
ldy #0
cpx #0
beq done
loop lda [p],y
sta [cstr],y
iny
dex
bne loop
done lda #0
sta [cstr],y
ldx cstr+2
ldy cstr
rep #$21
longa on
lda space
sta end-2
pld
tsc
adc #end-3
tcs
tya
rts
END
;=========================================================================
;
; Converts a c string to a pascal string. Does not allocate memory.
;
;=========================================================================
c2pstr START
space equ 1
p equ space+2
cstr equ p+4
end equ cstr+4
tsc
phd
tcd
short a
ldy #0
loop lda [cstr],y
beq endstr
iny
sta [p],y
bra loop
endstr tya
sta [p]
rep #$21
longa on
lda space
sta end-2
pld
tsc
adc #end-3
tcs
rts
END
;=========================================================================
;
; Converts a c string to a pascal string. Allocates memory for p string.
;
;=========================================================================
c2pstr2 START
p equ 1
space equ p+4
cstr equ space+2
end equ cstr+4
tsc
sec
sbc #space-1
tcs
phd
tcd
pei (cstr+2)
pei (cstr)
jsr cstrlen
inc a
pea 0
pha
jsl ~NEW
sta p
stx p+2
short a
ldy #0
loop lda [cstr],y
beq endstr
iny
sta [p],y
bra loop
endstr tya
sta [p]
ldx p+2
ldy p
rep #$21
longa on
lda space
sta end-2
pld
tsc
adc #end-3
tcs
tya
rts
END
;=========================================================================
;
; Compare two c strings. Return 0 if equal, -1 if less than, +1 greater
@ -406,7 +242,7 @@ done rep #$21
;
;=========================================================================
cmpdcstr START
cmpdcstr START
hold equ 1
space equ hold+2
@ -467,7 +303,7 @@ done anop
;=========================================================================
c2gsstr START
len equ 1
gstr equ len+2
space equ gstr+4
@ -488,7 +324,7 @@ end equ cstr+4
adc #3
pea 0
pha
jsl ~NEW
~NEW
sta gstr
stx gstr+2
incad @xa
@ -523,7 +359,7 @@ end equ cstr+4
;=========================================================================
catcstr START
new equ 1
space equ new+4
q equ space+2
@ -550,7 +386,7 @@ end equ p+4
plx
pea 0
pha
jsl ~NEW
~NEW
sta new
stx new+2
@ -591,13 +427,7 @@ done ldx new+2
;=====================================================================
nullfree START
* lda 6,s DEBUG code: break if
* and #$FF80 address is > $007FFFFF
* beq notbad
* brk $db
*notbad anop
lda 4,s
ora 6,s
bne ok
@ -609,7 +439,7 @@ nullfree START
plx
rtl
ok jml ~DISPOSE
ok ~DISPOSE
END
@ -654,7 +484,7 @@ newline ENTRY
**************************************************************************
getenv START
len equ 1
retval equ len+2
space equ retval+4
@ -692,7 +522,7 @@ notnull inc2 a Add 4 bytes for result buf len words.
inc a Add 1 more for terminating null byte.
pea 0
pha
jsl ~NEW Request the memory.
~NEW Request the memory.
sta RVresult Store address in ReadVariable
stx RVresult+2 parameter block and
sta retval direct page pointer.

View File

@ -7,7 +7,7 @@
* Tim Meekins
* Derek Taubert
*
* $Id: shellvar.asm,v 1.4 1998/07/20 16:23:10 tribby Exp $
* $Id: shellvar.asm,v 1.5 1998/08/03 17:30:24 tribby Exp $
*
**************************************************************************
*
@ -118,7 +118,8 @@ showusage ldx #^Usage
; Show all environment variables
;
showvars anop
jsl alloc256 Allocate 256 bytes
ph4 #261
~NEW Allocate 261 bytes
sta varbuf for name buffer.
stx varbuf+2
ora varbuf+2
@ -128,9 +129,8 @@ showvars anop
stx valbuf+2
ora valbuf+2 If memory was not allocated,
bne startshow
ldx varbuf+2
lda varbuf
jsl free256
ph4 varbuf
jsl nullfree
svwhoops ld2 $201,ErrError report memory error
ErrorGS Err
jmp exit and exit.
@ -138,7 +138,7 @@ svwhoops ld2 $201,ErrError report memory error
startshow anop
lda #1022 Store buffer len == 1022 in value
sta [valbuf] buffer (save 2 bytes at end for 0).
lda #256 Store buffer len == 256 in name
lda #260 Store buffer len == 260 in name
sta [varbuf] buffer.
lock setmutex
mv4 varbuf,idxName Initialize ReadIndexedGS
@ -149,11 +149,18 @@ showloop ReadIndexedGS idxParm Get next indexed variable.
ldy #2 Get length of name.
lda [varbuf],y
beq showdone If 0, we've got all the names.
cmp #254 If len > 253,
cmp #257 If len > 256,
bcs bumpindx we didn't get it.
tay Store 0 at end of
iny4 name string so it
short a can be treated like
lda #0 a c-string.
sta [varbuf],y
long a
ldx idxExport X = variable's export flag.
ldy #2 Y = offset in varname of length word.
ldy #4 Y = offset in varname to text.
jsr prnameval Print varname and varval.
bumpindx inc idxIndex Bump index number.
@ -164,9 +171,8 @@ bumpindx inc idxIndex Bump index number.
;
showdone anop
unlock setmutex Unlock mutual exclusion.
ldx varbuf+2
lda varbuf
jsl free256 Free the name buffer.
ph4 varbuf
jsl nullfree Free the name buffer.
ldx valbuf+2
lda valbuf
jsl free1024 Free the value buffer.
@ -301,7 +307,7 @@ notdef ldx #^error2 'Variable not defined'
bra doneone
def ldx RSexport X = export flag.
ldy #0 Y = offset in varname to length word.
ldy #2 Y = offset in varname to text.
jsr prnameval Print varname and varval.
doneone anop
@ -329,14 +335,10 @@ exit lda space
;
; Utility subroutine to print name and value in varname and varval
; Call with X = export flag, Y = index to length word in varbuf.
; Call with X = export flag, Y = index to text in varbuf.
;
prnameval anop
phy Hold name length offset on stack.
lda [varbuf],y Get length of name.
and #$FF (maximum len is 255)
xba Swap length bytes so result buf
sta [varbuf],y can be treated like a p-string.
cpx #0 If export flag is set,
bne needshift go upshift the name.
ldx exflag If we're listing all vars, it's OK.
@ -346,12 +348,10 @@ prnameval anop
;
; Variable is exported: need to upshift its name:
;
needshift xba
tax Length in X.
iny2 Index to first char in Y.
short a Switch to 1-byte memory access.
needshift short a Switch to 1-byte memory access.
upper lda [varbuf],y Get next character.
beq golong If 0, at end.
cmp #'a' If >= 'a'
bcc noshift and <= 'z',
cmp #'z'+1
@ -359,21 +359,19 @@ upper lda [varbuf],y Get next character.
and #$5F upshift the char.
sta [varbuf],y
noshift iny Bump the index and
dex and decrement the counter,
bne upper staying in upshift loop until done.
bra upper stay in upshift loop until done.
long a Switch back to 1-word access.
golong long a Switch back to 1-word access.
;
; Name is ready for printing
;
nameok ldx varbuf+2
clc
pla Get name length offset from stack.
ina Add one, to get p-string length addr.
pla Get text offset from stack.
adc varbuf Add starting address,
bcc prname
inx adjusting high-order word if needed.
prname jsr putp Print name (p-string)
prname jsr puts Print name
ldx #^showeq
lda #showeq

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: stdio.asm,v 1.3 1998/06/30 17:26:00 tribby Exp $
* $Id: stdio.asm,v 1.4 1998/08/03 17:30:24 tribby Exp $
*
**************************************************************************
*
* STDIO.ASM
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
*
* This is the custom stdio for the shell
*
@ -117,65 +118,6 @@ exit long a SWITCH TO FULL-WORD MEMORY MODE.
END
**************************************************************************
*
* putp - output a p string to standard out
* On entry: A/X = pointer to string
*
**************************************************************************
putp START
using stdout
tay Note: lock destroys Acc
lock mutex Wait for others to leave, and lock.
sty getchar+1 Save low-order bytes of address.
sty cmpchar+1
txa
short a SWITCH TO SINGLE-BYTE MEMORY MODE.
sta getchar+3 Store high-order byte of address.
sta cmpchar+3
ora getchar+2 If string address
ora getchar+1 is 00/0000,
beq exit don't do the write.
ldy index Get current number of chars in stream.
ldx #1 Skip len byte in source string offset.
bra chklen See if there are characters to copy.
getchar lda >$FFFFFF,x Get next character from string.
sta stream,y Store in output stream.
iny Bump the stream and
inx string pointers.
cmp #13 If newline was encountered,
beq _flush go write & flush the stream.
chklen txa
cmpchar cmp >$FFFFFF If we have copied all the chars,
beq check2
bcs done all done.
check2 cpy #512 If stream length < 512,
bcc getchar continue copying characters.
_flush sty index Save length of stream.
phx Hold source string offset on stack.
long a SWITCH TO FULL-WORD MEMORY MODE.
Write WriteParm Write the stream to stdout
Flush flushparm and flush it.
short a SWITCH TO SINGLE-BYTE MEMORY MODE.
plx Restore source string offset to X-reg.
ldy #0 Set stream length to 0.
bra chklen
; Arrive here when null character is encountered.
done sty index Save stream length in global.
exit long a SWITCH TO FULL-WORD MEMORY MODE.
unlock mutex Allow others through.
rts Return to caller.
END
**************************************************************************
*
@ -301,59 +243,6 @@ done sty errindex
END
**************************************************************************
*
* errputp - output a p string to standard error
* On entry: A/X = pointer to string
*
**************************************************************************
errputp START
using stderr
tay ;lock destroys Acc
lock errmutex
sty getchar+1
sty cmpchar+1
txa
short a
sta getchar+3
sta cmpchar+3
ldy errindex
ldx #1
getchar lda >$FFFFFF,x
sta errstream,y
iny
inx
cmp #13
beq _flush
next txa
cmpchar cmp >$FFFFFF
beq check2
bcs done
check2 cpy #256
bcc getchar
_flush sty errindex
phx
long a
Write errWriteParm
short a
plx
ldy #0
bra next
done sty errindex
long a
unlock errmutex
rts
END
**************************************************************************
*
* errflush - flush stderr

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: sv.asm,v 1.4 1998/07/20 16:23:10 tribby Exp $
* $Id: sv.asm,v 1.5 1998/08/03 17:30:25 tribby Exp $
*
**************************************************************************
*
@ -35,7 +35,7 @@ dummysv start ; ends up in .root
**************************************************************************
sv_alloc START
ptr equ 0
space equ ptr+4
@ -48,7 +48,7 @@ space equ ptr+4
asl a
pea 0
pha
jsl ~NEW Allocate the memory
~NEW Allocate the memory
sta ptr and save address in
stx ptr+2 direct page variable.
@ -81,7 +81,7 @@ init sta [ptr],y Set all entries
**************************************************************************
sv_add START
p equ 0
base equ p+4
space equ base+4
@ -106,7 +106,7 @@ space equ base+4
inc a
pea 0
pha
jsl ~NEW Allocate memory for it.
~NEW Allocate memory for it.
sta p Store address in p/p+1.
stx p+2

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: term.asm,v 1.4 1998/07/20 16:23:11 tribby Exp $
* $Id: term.asm,v 1.5 1998/08/03 17:30:25 tribby Exp $
*
**************************************************************************
*
* TERM.ASM
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
*
* Routines for dealing with Termcap under gsh.
*
@ -37,13 +38,13 @@ TIOCGETP gequ $40067408
**************************************************************************
InitTerm START
using termdata
;
; See if $TERM exists
;
ReadVariableGS dummyresult
ReadVariableGS ReadVarPB
lda term_len Get length of $TERM
bne allocate If 0,
@ -52,12 +53,12 @@ InitTerm START
allocate anop Allocate termcap buffers.
ph4 #1024
jsl ~NEW
~NEW
sta bp
stx bp+2
ph4 #1024
jsl ~NEW
~NEW
sta areabuf
stx areabuf+2