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. # 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. # Devin Reade, February 1998.
# #
@ -28,8 +28,8 @@ SRCS = $(MAINSRC) \
orca.asm \ orca.asm \
edit.asm \ edit.asm \
term.asm \ term.asm \
bufpool.asm bufpool.asm \
# unused: mmdebug.asm mmdebug.asm
# Note: STACK variable does not control size of stack/direct-page segment # Note: STACK variable does not control size of stack/direct-page segment
# since this is assembly language. Edit stack segment in main.asm # since this is assembly language. Edit stack segment in main.asm
@ -41,9 +41,12 @@ SRCS = $(MAINSRC) \
# ltermcap library from GNO v2.0.4. # ltermcap library from GNO v2.0.4.
# #
# LDADD = -ltermcap # LDADD = -ltermcap
LDLIBS += -l/trenco3/lib.206/ltermcap ###LDLIBS += -l/trenco3/lib.206/ltermcap
###LDLIBS += -l/h1/orca/libraries/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. # Make sure our macro files get built before trying to assemble source files.
# LOCAL_SETUP = macros # LOCAL_SETUP = macros

View File

@ -1,6 +1,43 @@
GSH 2.0 UPDATES 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, Jul 19 98 [dmt] Changed edit.asm to use ReadIndexedGS, InitWildcardGS,
NextWildcardGS, instead of their obsolete counterparts. NextWildcardGS, instead of their obsolete counterparts.

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * ALIAS.ASM
* By Tim Meekins * 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 * 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 pha
ph4 #2 ph4 #2
jsl ~NEW ~NEW
sta arg sta arg
stx arg+2 stx arg+2
lda #0 lda #0
@ -323,7 +324,7 @@ yahaha sta AliasTable,x
;========================================================================= ;=========================================================================
expandalias START expandalias START
outbuf equ 0 outbuf equ 0
sub equ outbuf+4 sub equ outbuf+4
word equ sub+4 word equ sub+4
@ -333,7 +334,7 @@ space equ buf+4
subroutine (4:cmd),space subroutine (4:cmd),space
ph4 #1024 ph4 #1024
jsl ~NEW ~NEW
stx buf+2 stx buf+2
sta buf sta buf
stx outbuf+2 stx outbuf+2
@ -483,7 +484,7 @@ done ldx word+2
;========================================================================= ;=========================================================================
addalias START addalias START
using AliasData using AliasData
tmp equ 0 tmp equ 0
@ -539,7 +540,7 @@ replace ldy #8+2
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta tmp sta tmp
stx tmp+2 stx tmp+2
ldy #8 ldy #8
@ -555,7 +556,7 @@ replace ldy #8+2
bra done bra done
notfound ph4 #4*3 notfound ph4 #4*3
jsl ~NEW ~NEW
sta ptr sta ptr
stx ptr+2 stx ptr+2
ldy #2 ldy #2
@ -570,7 +571,7 @@ notfound ph4 #4*3
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta tmp sta tmp
stx tmp+2 stx tmp+2
ldy #4 ldy #4
@ -589,7 +590,7 @@ notfound ph4 #4*3
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta tmp sta tmp
stx tmp+2 stx tmp+2
ldy #8 ldy #8

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * BUFPOOL
* By Tim Meekins * By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6 (256-byte buffer code removed)
* *
* This is the buffer pool * This is the buffer pool
* *
@ -23,14 +24,10 @@
* Interfaces defined in this file: * Interfaces defined in this file:
* The alloc routines are a jsl without any stack params. * The alloc routines are a jsl without any stack params.
* Pointer to requested buffer is returned in X/A registers. * Pointer to requested buffer is returned in X/A registers.
* alloc256
* free256
* alloc1024 * alloc1024
* free1024 * free1024
* *
* bufpool data: * bufpool data:
* pool256 dc i4'0'
* pool256mutex key
* pool1024 dc i4'0' * pool1024 dc i4'0'
* pool1024mutex key * pool1024mutex key
* *
@ -41,86 +38,6 @@
dummybufpool start ; ends up in .root dummybufpool start ; ends up in .root
end 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 * get a buffer of size 1024
@ -128,7 +45,7 @@ free256 START
************************************************************************** **************************************************************************
alloc1024 START alloc1024 START
using bufpool using bufpool
lock pool1024mutex lock pool1024mutex
@ -154,7 +71,7 @@ alloc1024 START
allocbuf unlock pool1024mutex allocbuf unlock pool1024mutex
ph4 #1024 ph4 #1024
jsl ~NEW ~NEW
rtl rtl
END END
@ -200,8 +117,6 @@ free1024 START
bufpool DATA bufpool DATA
pool256 dc i4'0'
pool256mutex key
pool1024 dc i4'0' pool1024 dc i4'0'
pool1024mutex key pool1024mutex key

View File

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

View File

@ -1,4 +1,4 @@
*********************************************************************** **************************************************************************
* *
* The GNO Shell Project * The GNO Shell Project
* *
@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 command START
pipefds equ 1 pipefds equ 1
errappend equ pipefds+2 errappend equ pipefds+2
errfile equ errappend+2 errfile equ errappend+2
@ -359,7 +359,7 @@ end equ waitpid+4
tcd tcd
ph4 #1024 Allocate 1024 bytes ph4 #1024 Allocate 1024 bytes
jsl ~NEW and pointer in cmdline. ~NEW and pointer in cmdline.
sta cmdline sta cmdline
stx cmdline+2 stx cmdline+2
lda #0 Initialize to null C string. lda #0 Initialize to null C string.
@ -370,7 +370,7 @@ end equ waitpid+4
stx word+2 stx word+2
ph4 #MAXARG*4 ph4 #MAXARG*4
jsl ~NEW ~NEW
sta argv sta argv
stx argv+2 stx argv+2
@ -421,7 +421,7 @@ word1 pei (word+2)
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta temp sta temp
stx temp+2 stx temp+2
ora temp+2 ora temp+2
@ -771,7 +771,7 @@ free2 pei (argv+2)
************************************************************************** **************************************************************************
ShellExec START ShellExec START
using vardata using vardata
using global using global
@ -857,27 +857,27 @@ set_value anop
vars_set unlock mutex vars_set unlock mutex
ph4 #4 ;Close parms ph4 #4 ;Close parms
jsl ~NEW ~NEW
sta CRec sta CRec
stx CRec+2 stx CRec+2
ph4 #10 ;Open parms ph4 #10 ;Open parms
jsl ~NEW ~NEW
sta ORec sta ORec
stx ORec+2 stx ORec+2
ph4 #12 ;NewLine parms ph4 #12 ;NewLine parms
jsl ~NEW ~NEW
sta NRec sta NRec
stx NRec+2 stx NRec+2
ph4 #16 ;Read parms ph4 #16 ;Read parms
jsl ~NEW ~NEW
sta RRec sta RRec
stx RRec+2 stx RRec+2
ph4 #1000 ;data buffer ph4 #1000 ;data buffer
jsl ~NEW ~NEW
sta data sta data
stx data+2 stx data+2

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * path2tilde
* *
* getpfxstr
*
************************************************************************** **************************************************************************
mcopy /obj/gno/bin/gsh/dir.mac mcopy /obj/gno/bin/gsh/dir.mac
@ -552,60 +554,68 @@ space equ idx+2
subroutine (0:dummy),space subroutine (0:dummy),space
lda tods lda tods Get index number.
asl a asl a Multiply by four
asl a asl a to get byte offset.
sta idx sta idx Store in idx
tay tay and Y-register.
lda dirstack,y lda dirstack,y If there is an address
ora dirstack+2,y ora dirstack+2,y in this position,
beq setit beq setit
lda dirstack+2,y lda dirstack+2,y
pha pha
lda dirstack,y lda dirstack,y
pha pha
jsl nullfree jsl nullfree free it.
setit lock mutex setit lock mutex
jsl alloc256
sta gppath pea 0
stx gppath+2 jsl getpfxstr Get value of prefix 0.
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
sta p sta p
stx p+2 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 ldy #2 If length of returned
lda p lda [p],y GS/OS string is 0,
sta dirstack,y 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 lda p+2
sta dirstack+2,y sta dirstack+2,y
done unlock mutex
return return
mutex key mutex key
gpparm dc i2'2'
dc i2'0'
gppath dc i4'0'
END END
************************************************************************** **************************************************************************
@ -628,7 +638,7 @@ tods dc i'0'
************************************************************************** **************************************************************************
path2tilde START path2tilde START
ptr equ 0 ptr equ 0
newpath equ ptr+4 newpath equ ptr+4
home equ newpath+4 home equ newpath+4
@ -636,26 +646,24 @@ space equ home+4
subroutine (4:path),space subroutine (4:path),space
pei (path+2) pei (path+2) Get length of
pei (path) pei (path) path string
jsr cstrlen jsr cstrlen parameter.
inc2 a inc2 a Add 2, and allocate
pea 0 pea 0 memory for result string.
pha pha
jsl ~NEW ~NEW
sta newpath sta newpath
stx newpath+2 stx newpath+2
sta ptr sta ptr
stx ptr+2 stx ptr+2
jsl alloc256 Allocate 256 byte GS/OS result buf. ph4 #homename Get $HOME environment variable.
jsl getenv
sta home sta home
stx home+2 stx home+2
sta ReadName ora home+2 If buffer wasn't allocated
stx ReadName+2 jeq notfound2 cannot search for $HOME.
lda #256 Set buffer length word.
sta [home]
ReadVariableGS ReadVar Read $home environment variable.
ldy #2 Get result length word. ldy #2 Get result length word.
lda [home],y lda [home],y
@ -667,7 +675,7 @@ checkhome lda [path],y
beq notfound2 checking for end of string, beq notfound2 checking for end of string,
jsr tolower converting to lower-case jsr tolower converting to lower-case
jsr toslash and changing ":" to "/". 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 iny4 $home has 4 bytes of length info
lda [home],y that need to be indexed over. lda [home],y that need to be indexed over.
dey2 Take back 3 of the offset, dey2 Take back 3 of the offset,
@ -681,23 +689,31 @@ checkhome lda [path],y
dex Decrement $home length counter. dex Decrement $home length counter.
bne checkhome If more, stay in loop. 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 beq found
lda [path],y jsr toslash '/', or ':', we have a match.
and #$FF
beq found
jsr toslash
cmp #'/' cmp #'/'
bne notfound2 bne notfound2
found lda #'~' Store '~' as first character
found lda #'~' sta [ptr] in result buffer, and bump
sta [ptr] incad ptr result pointer.
incad ptr
bra copyrest 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 copyrest short a
copyloop lda [path],y copyloop lda [path],y
beq endcopy beq endcopy
@ -710,28 +726,135 @@ copyput sta [ptr]
short a short a
iny iny
bra copyloop bra copyloop
endcopy sta [ptr] endcopy sta [ptr]
long a long a
dec ptr dec ptr If final character
lda [ptr] lda [ptr] was "/",
cmp #'/' cmp #'/'
bne skipshorten bne skipshorten
lda #0 lda #0 obliterate it.
sta [ptr] sta [ptr]
skipshorten ldx home+2 skipshorten pei (home+2) Free memory allocated
lda home pei (home) for the value of $HOME.
jsl free256 jsl nullfree
return 4:newpath 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 homename gsstr 'home' Env variable name
END 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 * Jawaid Bazyar
* Tim Meekins * 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 wordmatch START
using global using global
using hashdata using hashdata
using BuiltInData using BuiltInData
@ -1114,7 +1114,7 @@ gv02a anop
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW Request memory to hold name. ~NEW Request memory to hold name.
sta 0 sta 0
stx 0+2 stx 0+2
ply Get matchbuf offset from stack. ply Get matchbuf offset from stack.
@ -1140,7 +1140,7 @@ gv01 lda NameText-1,y Get next byte of name.
nextvar inc idxIndex nextvar inc idxIndex
jmp varloop jmp varloop
vardone rts vardone rts Return from wordmatch
; ;
; Match by file names; start by moving wordgs_text + trailing "*" to a GS/OS string ; 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 iny Get length of name + 1
pea 0 pea 0
phy phy
jsl ~NEW Request memory to hold name. ~NEW Request memory to hold name.
ply Get matchbuf offset from stack. ply Get matchbuf offset from stack.
sta matchbuf,y Store allocated memory's sta matchbuf,y Store allocated memory's
txa address in matchbuf array. txa address in matchbuf array.
@ -1265,7 +1265,7 @@ isdir lda nummatch
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
ply ply
sta 8 sta 8
stx 10 stx 10
@ -1277,9 +1277,9 @@ isdir lda nummatch
txa txa
sta matchbuf+2,y sta matchbuf+2,y
jsr copycstr jsr copycstr
pei (2) pei (2) Free entry that was
pei (0) pei (0) allocated in non-directory
jsl nullfree jsl nullfree section of code.
ldy NameLen ldy NameLen
lda sepstyle lda sepstyle
sta [8],y sta [8],y
@ -1350,7 +1350,7 @@ hl0 inx
pha pha
pea 0 pea 0
phx phx
jsl ~NEW ~NEW
ply ply
pei (q+2) pei (q+2)
pei (q) pei (q)
@ -1401,7 +1401,7 @@ bl0 inx
pha pha
pea 0 pea 0
phx phx
jsl ~NEW ~NEW
ply ply
pei (q+2) pei (q+2)
pei (q) pei (q)
@ -1416,7 +1416,7 @@ binext add2 p,#10,p
bra bilup bra bilup
bidone anop bidone anop
done rts done rts Return from wordmatch.
startpos ds 2 startpos ds 2
cmdflag ds 2 cmdflag ds 2
@ -1570,7 +1570,7 @@ vt100key dc 65i2'undefined_char,0,0' ;^@ ... @
************************************************************************** **************************************************************************
bindkeyfunc START bindkeyfunc START
using keybinddata using keybinddata
p equ 0 p equ 0
@ -1608,7 +1608,7 @@ addb adc #0
beq next beq next
phy phy
ph4 #128*6 ph4 #128*6
jsl ~NEW ~NEW
sta p sta p
stx p+2 stx p+2
ldy #128*6-2 ldy #128*6-2
@ -1678,7 +1678,7 @@ done return
************************************************************************** **************************************************************************
bindkey START bindkey START
str equ 0 str equ 0
func equ str+4 func equ str+4
arg equ func+2 arg equ func+2
@ -1769,7 +1769,7 @@ foundit pla
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta str sta str
stx str+2 stx str+2
pei (arg+2) pei (arg+2)

View File

@ -1,4 +1,4 @@
*********************************************************************** **************************************************************************
* *
* The GNO Shell Project * The GNO Shell Project
* *
@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 glob START
using vardata using vardata
count equ 0 count equ 0
@ -70,14 +70,15 @@ space equ buf+4
; ;
; noglob isn't set, so now we can actually start. ; noglob isn't set, so now we can actually start.
; ;
doglob jsl alloc1024 ;create an output buffer doglob jsl alloc1024 Create an output buffer.
sta buf sta buf
sta ptr stx buf+2
stx buf+2 sta ptr ptr points to next
stx ptr+2 stx ptr+2 position in buf.
jsl alloc1024 ;create a word buffer
sta wordbuf jsl alloc1024 Create a word buffer.
stx wordbuf+2 sta wordbuf
stx wordbuf+2
; ;
; Find the beginning of the next word ; Find the beginning of the next word
@ -193,14 +194,14 @@ doneflush jmp findword
; Hello, boys and goils, velcome to Tim's Magik Shoppe ; Hello, boys and goils, velcome to Tim's Magik Shoppe
; ;
; Ok, here's the plan: ; Ok, here's the plan:
; 1. We give _InitWildcard a PATHNAME. ; 1. We give InitWildcardGS a PATHNAME.
; 2. _NextWildcard returns a FILENAME. ; 2. NextWildcardGS returns a FILENAME.
; 3. We need to expand to the command-line the full pathname. ; 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 ; 4. Therefore, we must put aside the prefix, and cat each file returned
; from _NextWildcard to the saved prefix, but, we must still pass ; from NextWildcardGS to the saved prefix, but, we must still pass
; the entire path to _InitWildcard. ; the entire path to InitWildcardGS.
; 5. This solves our problem with quoting. Expand the quotes before ; 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 ; to will still have the quotes in it, so that the tokenizer can deal
; with it. Whew! ; with it. Whew!
; ;
@ -212,16 +213,18 @@ doneflush jmp findword
; Expand out the quoted stuff, and keep an eye out for that ubiquitous last ; Expand out the quoted stuff, and keep an eye out for that ubiquitous last
; filename separator... then we can isolate him! ; filename separator... then we can isolate him!
; ;
globword stz filesep globword stz filesep
jsl alloc1024 jsl alloc1024 Alloc buffer for wildcard pattern.
sta eptr sta exppath
stx eptr+2 stx exppath+2
sta exppath
stx exppath+2
incad eptr ;leave room for pascal length
mv4 eptr,sepptr
incad @xa Leave room for length word
incad @xa
sta eptr
stx eptr+2
sta sepptr
stx sepptr+2
ldy #0 ldy #0
exploop lda [wordbuf],y exploop lda [wordbuf],y
and #$FF and #$FF
@ -273,66 +276,65 @@ copyback lda [wordbuf],y
cmp #0 cmp #0
bne copyback 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 sub2 sepptr,exppath,@a
dec2 a ;don't count length byte or \0! dec2 a Don't count length word or \0
short a dec a
sta [exppath] sta [exppath]
long a
; ;
; We now have enough to call _InitWildCard!!! ; We now have enough to call InitWildCardGS!!!
; [ let's mutex the rest so we don't have to fix _InitWC and _NextWC ;-) ] ; [ let's mutex the rest so we don't have to fix InitWC and NextWC ;-) ]
; ;
lock glob_mutex lock glob_mutex
; ;
; Call shell routine InitWildcard to initialize the filename pattern ; Call shell routine InitWildcardGS to initialize the filename pattern
; ;
stz count stz count
mv4 exppath,initWCparm mv4 exppath,initWCpath
Init_Wildcard initWCparm 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 WCloop NextWildcardGS nWCparm
jsl ~NEW ldy #2
sta gname lda [gname],y
stx gname+2 beq nomore
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
; ;
; Keep count of how many paths are expanded ; Keep count of how many paths are expanded
; ;
inc count inc count
; ;
; Copy the original path (up to file separator) to output buffer ; Copy the original path (up to file separator) to output buffer
; ;
ldy #0 ldy #0
outtahere if2 @y,eq,filesep,globout outtahere if2 @y,eq,filesep,globout
lda [wordbuf],y lda [wordbuf],y
jsr g_putspecial jsr g_putspecial
iny iny
bra outtahere bra outtahere
; ;
; Copy the expanded filename to output buffer ; Copy the expanded filename to output buffer
; ;
globout lda [gname] globout ldy #2 Get returned length
and #$FF lda [gname],y from GS/OS buffer.
tax tax
ldy #1 ldy #4
globoutta lda [gname],y globoutta lda [gname],y Copy next character
jsr g_putspecial jsr g_putspecial into buffer.
iny iny
dex dex
bne globoutta bne globoutta
; ;
; Place blank as separator after name and see if more are expanded. ; Place blank as separator after name and see if more are expanded.
; ;
@ -345,6 +347,7 @@ globoutta lda [gname],y
; ;
nomore anop nomore anop
unlock glob_mutex
; ;
; Deallocate path buffers (we should probably alloc once, not each word... ) ; Deallocate path buffers (we should probably alloc once, not each word... )
; ;
@ -354,7 +357,6 @@ nomore anop
ldx exppath+2 ldx exppath+2
lda exppath lda exppath
jsl free1024 jsl free1024
unlock glob_mutex
lda count If somehing was expanded, lda count If somehing was expanded,
jne findword go find the next word. jne findword go find the next word.
@ -428,12 +430,18 @@ g_putbyte short a
glob_mutex key 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!!!) 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' nomatch dc c'No match: ',h'00'
ignored dc c' ignored',h'0d00' ignored dc c' ignored',h'0d00'
@ -563,7 +571,7 @@ braceloop lda [cmd]
; get text from standard input ; get text from standard input
; ;
stdinexpand jsr e_getbyte stdinexpand jsr e_getbyte
ReadLine (#value,#MAXVAL,#13,#1),@a ReadLine (#value,#MAXVAL,#13,#0),@a
sta valueln sta valueln
bra chklen bra chklen

View File

@ -651,108 +651,6 @@
dc i4'&a2' dc i4'&a2'
mend 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 ; Debugging
; ------------------ ; ------------------
@ -786,33 +684,15 @@ pastName&SYSCNT anop
; Data Structures ; Data Structures
; ------------------ ; ------------------
******************** *****************************
* dosin * GSStr: GS/OS output string
******************** *****************************
macro
&l dosin &adr
&l dc i"l:~&sysname&syscnt"
~&sysname&syscnt dc c"&adr"
mend
********************
* GSStr
********************
MACRO MACRO
&lab GSStr &string &lab GSStr &string
&lab dc i2'L:&string' &lab dc i2'L:&string'
dc c"&string" dc c"&string"
mend mend
********************
* Str
********************
MACRO
&lab Str &string
&lab dc i1'L:&string'
dc c"&string"
mend
; ------------------ ; ------------------
; Branch ; Branch
; ------------------ ; ------------------
@ -2047,7 +1927,7 @@ pastName&SYSCNT anop
******************** ********************
MACRO MACRO
&lab breakpoint &flag &lab breakpoint &flag
lda check4debug &lab lda check4debug
and #$80 and #$80
beq *+4 beq *+4
brk &flag brk &flag
@ -2072,3 +1952,23 @@ pastName&SYSCNT anop
.done .done
skip&syscnt anop skip&syscnt anop
MEND 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 * 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" #define PROG "gsh"
@ -16,7 +16,7 @@
resource rVersion (1, purgeable3) { resource rVersion (1, purgeable3) {
{ 2, 0, 0, /* Version 2.0.0 */ { 2, 0, 0, /* Version 2.0.0 */
development, /* development|alpha|beta|final|release */ development, /* development|alpha|beta|final|release */
2 }, /* non-final release number */ 3 }, /* non-final release number */
verUS, /* Country */ verUS, /* Country */
PROG, /* Program name */ PROG, /* Program name */
DESC DESC

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * HASH.ASM
* By Tim Meekins & Greg Thompson * By Tim Meekins & Greg Thompson
* Modified by Dave Tribby for GNO 2.0.6
* *
* Command hashing routines * Command hashing routines
* *
@ -179,7 +180,7 @@ tmp ds 2
************************************************************************** **************************************************************************
dohash START dohash START
using hashdata using hashdata
h equ 1 h equ 1
@ -221,7 +222,7 @@ mktsize asl a
asl a asl a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta table sta table
stx table+2 stx table+2
; ;
@ -300,7 +301,7 @@ hashloop pei (files+2)
; table[h] = (tablenode *)malloc(sizeof(tablenode)) ; table[h] = (tablenode *)malloc(sizeof(tablenode))
; ;
gotit ph4 #tn_size gotit ph4 #tn_size
jsl ~NEW ~NEW
sta temp sta temp
stx temp+2 stx temp+2
ldy h ldy h
@ -358,7 +359,7 @@ done anop
************************************************************************** **************************************************************************
search START search START
ptr equ 1 ptr equ 1
full_path equ ptr+4 full_path equ ptr+4
qh equ full_path+4 qh equ full_path+4
@ -438,7 +439,7 @@ found lda [ptr]
adc #33 Add 33 (max prog name size + 1) adc #33 Add 33 (max prog name size + 1)
pea 0 pea 0
pha pha
jsl ~NEW Allocate memory, ~NEW Allocate memory,
sta full_path storing address at sta full_path storing address at
stx full_path+2 functional return value. stx full_path+2 functional return value.
@ -553,137 +554,132 @@ done return
************************************************************************** **************************************************************************
dir_search START dir_search START
using hashdata using hashdata
temp2 equ 0 temp2 equ 0
temp equ temp2+4 temp equ temp2+4
entry equ temp+4 entry equ temp+4
numEntries equ entry+2 numEntries equ entry+2
ptr equ numEntries+2 ptr equ numEntries+2
space equ ptr+4 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 ; Open directory name passed as 1st parameter
; ;
ld2 3,ORec ld2 3,ORec
pei (dir+2) Turn "dir" c-string into pei (dir+2) Turn "dir" c-string into
pei (dir) a GS/OS string, allocated pei (dir) a GS/OS string, allocated
jsr c2gsstr via ~NEW. jsr c2gsstr via ~NEW.
sta ORecPath sta ORecPath
stx ORecPath+2 stx ORecPath+2
phx Put GS/OS string addr on stack phx Put GS/OS string addr on stack
pha so it can be deallocated. pha so it can be deallocated.
Open ORec Open that file. Open ORec Open that file.
bcc goodopen If there was an error, bcc goodopen If there was an error,
jsl nullfree Free the GS/OS string jsl nullfree Free the GS/OS string
jmp exit and exit. 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 ; Set up parameter block for GetDirEntry
; ;
mv2 ORecRef,DRecRef Copy the file ref num from open. mv2 ORecRef,DRecRef Copy the file ref num from open.
stz DRecBase Zero the base and stz DRecBase Zero the base and
stz DRecDisp displacement. stz DRecDisp displacement.
jsl alloc256 Get 256 bytes for name. GetDirEntry DRec Make DirEntry call.
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 DRecEntry,numEntries Save number of entries. mv2 DRecEntry,numEntries Save number of entries.
ld2 1,(DRecBase,DRecDisp) ld2 1,(DRecBase,DRecDisp)
stz entry # processed entries = 0. stz entry # processed entries = 0.
;
loop lda entry If number of processed entries ; Process each entry in the directory
cmp numEntries equals the total number, ;
jge done we are all done. loop lda entry If number of processed entries
GetDirEntry DRec 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) ; 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) ; 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) ; Check for filetype $B0, subtype $0006: Shell command file (EXEC)
cmp #$B0 cmp #$B0
bne nextfile bne nextfile
lda DRecAuxType lda DRecAuxType
cmp #$06 cmp #$06
bne nextfile bne nextfile
lda DRecAuxType+2 lda DRecAuxType+2
bne nextfile bne nextfile
; ;
; This directory entry points to an executable file. ; This directory entry points to an executable file.
; Included it in the file list. ; Included it in the file list.
; ;
goodfile inc hash_numexe Bump the (global) # files. 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. ldx TempRBlen Get length word from GS/OS string
lda [files],y short a
sta temp stz TempRBname,x Store terminating null byte.
ldy #fn_next+2 long a
lda [files],y
sta temp+2
ph4 #fn_size temp2 = new entry. ph4 #TempRBname
jsl ~NEW jsr lowercstr Convert name to lower case.
sta temp2
stx temp2+2
ldy #fn_next files->next = temp2 ph4 #TempRBname Push src addr for copycstr.
sta [files],y
ldy #fn_next+2 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 txa
pha pha
sta [files],y sta [files],y
lda temp2 lda temp2
clc clc
adc #fn_name adc #fn_name
pha pha
jsr copycstr jsr copycstr Copy string into entry.
lda dirNum temp2->dirnum = dirNum lda dirNum temp2->dirnum = dirNum
sta [temp2] sta [temp2]
ldy #fn_next temp2->next = temp ldy #fn_next temp2->next = temp
lda temp lda temp
sta [temp2],y sta [temp2],y
ldy #fn_next+2 ldy #fn_next+2
lda temp+2 lda temp+2
sta [temp2],y sta [temp2],y
nextfile inc entry Bump entry number nextfile inc entry Bump entry number
jmp loop and stay in the loop. jmp loop and stay in the loop.
; ;
; Done adding entries to the hash table from this directory ; Done adding entries to the hash table from this directory
; ;
done ldx DRecName+2 Free the Name buffer. done anop
lda DRecName
jsl free256
ld2 1,ORec ORec.pCount = 1 ld2 1,ORec ORec.pCount = 1
Close ORec Close ORec
exit return exit return
@ -700,7 +696,7 @@ DRecRef ds 2 refNum
DRecFlag ds 2 flags: extended/not DRecFlag ds 2 flags: extended/not
DRecBase dc i'0' base: displacement is absolute entry # DRecBase dc i'0' base: displacement is absolute entry #
DRecDisp dc i'0' displacement: get tot # active entries 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 DRecEntry ds 2 entryNum: entry # whose info is rtrned
DRecFileType ds 2 fileType DRecFileType ds 2 fileType
DRecEOF ds 4 eof: # bytes in data fork DRecEOF ds 4 eof: # bytes in data fork
@ -710,6 +706,12 @@ DRecMod ds 8 modDateTime
DRecAccess ds 2 access attribute DRecAccess ds 2 access attribute
DRecAuxType ds 4 auxType 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 END
************************************************************************** **************************************************************************
@ -719,7 +721,7 @@ DRecAuxType ds 4 auxType
************************************************************************** **************************************************************************
hashpath START hashpath START
using hashdata using hashdata
using vardata using vardata
@ -749,23 +751,13 @@ end equ space+3
; Allocate special file node ; Allocate special file node
; ;
ph4 #fn_size ph4 #fn_size
jsl ~NEW ~NEW
sta hash_files sta hash_files
sta files sta files
stx hash_files+2 stx hash_files+2
stx 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 ; Initialize counters and pointers
; ;
lda #0 lda #0
@ -779,7 +771,7 @@ end equ space+3
sta [files],y sta [files],y
sta [files] sta [files]
; ;
; Determine length of $PATH environment variable string ; Get value of $PATH environment variable string
; ;
ph4 #pathname ph4 #pathname
jsl getenv jsl getenv
@ -911,55 +903,77 @@ storeit phy Push source index onto stack
long a Restore long accumulator. long a Restore long accumulator.
; ;
; Convert the input pathname into the corresponding ; Convert the input pathname into the corresponding full pathname with
; full pathname with colons as separators. ; 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 bcc epok
ldx #^eperrstr Print error message: ldx #^eperrstr Print error message:
lda #eperrstr "Invalid pathname syntax." lda #eperrstr "Invalid pathname syntax."
jsr errputs 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. 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 ldy #2
lda EPoutputPath portion of result buffer. lda [ptr],y Get length of text
adc #2 sta len
sta ptr tay
lda EPoutputPath+2 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 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 pha
sta ptr phy
stx ptr+2 pei (ptr+2) Destination is first
pei (ptr) byte of buffer.
jsr copycstr
lda ptr
ldy pathnum ldy pathnum
sta hash_paths,y Store address of this 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. sta hash_paths+2,y hash path table.
jsr copycstr ldy len
ldy len
beq bumppnum beq bumppnum
dey dey
lda [ptr],y If last character lda [ptr],y If last character
@ -1051,13 +1065,6 @@ filesdone anop
noprint ld2 1,hash_print Set print flag. 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. ; 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) EPinputPath ds 4 ptr to inputPath (GS/OS string)
EPoutputPath ds 4 ptr to outputPath (Result buffer) 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' eperrstr dc c'rehash: Invalid pathname syntax.',h'0d00'
toomanyerr dc c'rehash: Too many paths specified.',h'0d00' toomanyerr dc c'rehash: Too many paths specified.',h'0d00'
nopatherr dc c'rehash: PATH string is not set.',h'0d00' nopatherr dc c'rehash: PATH string is not set.',h'0d00'

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 InsertHistory START
using HistoryData using HistoryData
using global using global
@ -85,7 +85,7 @@ space equ histvalptr+4
clc clc
adc #4+1 adc #4+1
pha pha
jsl ~NEW ~NEW
sta ptr sta ptr
stx ptr+2 stx ptr+2
ora ptr+2 ora ptr+2

View File

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

View File

@ -1,4 +1,4 @@
************************************************************************ **************************************************************************
* *
* The GNO Shell Project * The GNO Shell Project
* *
@ -6,12 +6,13 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * JOBS.ASM
* By Tim Meekins * By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
* *
* Job control handling routines * Job control handling routines
* *
@ -184,7 +185,7 @@ done return
;==================================================================== ;====================================================================
palloc START palloc START
using pdata using pdata
using global using global
@ -211,7 +212,7 @@ end equ pid+2
pha pha
ph4 #p_space ph4 #p_space
jsl ~NEW ~NEW
sta pp sta pp
stx pp+2 stx pp+2
@ -271,7 +272,7 @@ in02 anop
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
pei (cmd+2) pei (cmd+2)
pei (cmd) pei (cmd)
phx phx
@ -318,7 +319,7 @@ noprint anop
;==================================================================== ;====================================================================
pallocpipe START pallocpipe START
using pdata using pdata
using global using global
@ -346,7 +347,7 @@ end equ pid+2
pha pha
ph4 #p_space ph4 #p_space
jsl ~NEW ~NEW
sta pp sta pp
stx pp+2 stx pp+2
@ -380,7 +381,7 @@ bg01 ldy #p_flags
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
pei (cmd+2) pei (cmd+2)
pei (cmd) pei (cmd)
phx phx

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6 * 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 * Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | | * | | | | | |
* ^ ^ ^ ^ ^ ^ * ^ ^ ^ ^ ^ ^
@ -58,7 +60,7 @@ init START
MAIN START MAIN START
using global using global
p equ 0 p equ 0
@ -101,7 +103,7 @@ argloop dec argc Decrement argument count.
inc ExecFlag inc ExecFlag
inc FastFlag inc FastFlag
ph4 #1024 ph4 #1024
jsl ~NEW ~NEW
sta ExecCmd sta ExecCmd
sta p sta p
stx ExecCmd+2 stx ExecCmd+2

View File

@ -6,53 +6,153 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 mcopy /obj/gno/bin/gsh/mmdebug.mac
dummy start ; ends up in .root dummymmdebug start ; ends up in .root
end end
setcom 60 setcom 60
~NEW START DB~NEW START
hand equ 0
ptr equ 4
_~NEW name
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 subroutine (4:size),space
lda [hand]
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 sta ptr
ldy #2 ldy #2
lda [hand],y lda [hand],y
sta ptr+2 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 END
~DISPOSE START
DB~DISPOSE START
hand equ 0 hand equ 0
checkptr equ 4 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] ; Second check: is there a valid handle to this pointer?
sta checkptr ;
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 ldy #2
lda [hand],y lda [hand],y
sta checkptr+2 sta checkptr+2
eor ptr+2
eor ptr cmp ptr+2 If the pointer isn't
eor checkptr 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 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 END

View File

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

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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. sbc #2 addr of original output buffer.
bcs no_undf bcs no_undf
dex dex
no_undf jsl free256 no_undf phx
pha
jsl nullfree
rts rts
gshrcName dc c'/gshrc',h'00' gshrcName dc c'/gshrc',h'00'
@ -312,35 +314,64 @@ gshrcName dc c'/gshrc',h'00'
;========================================================================= ;=========================================================================
AppendHome START AppendHome START
outPtr equ 0
len equ 4
subroutine (4:str),6
jsl alloc256 Allocate memory for outPtr equ 0 Pointer into allocated memory
stx outPtr1+2 GS/OS output buffer str_len equ outPtr+4 Length of string parameter
sta outPtr1 that will hold the buf_len equ str_len+2 Size of GS/OS buffer
stx outPtr+2 value of $HOME and space equ buf_len+2
sta outPtr the final result.
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+2) Get length of
pei (str) string to be pei (str) string to be
jsr cstrlen appended. jsr cstrlen appended.
sta len sta str_len
lda #255 Max len is 255 (leave room lda TempRBlen Get length of value.
sta [outPtr] for C string terminator). 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 @/ bcs doAtSign If error, use @/
ldy #2 ldy #2 Get length of
lda [outPtr],y lda [outPtr],y GS/OS string.
beq doAtSign ; $HOME not defined? beq doAtSign If $HOME not defined, use "@".
clc clc
adc #4 ; turn into a cstring adc #4 Turn into a c-string
tay tay by storing a 0 byte
short m short m after the last $HOME
lda #0 lda #0 character.
sta [outPtr],y sta [outPtr],y
long m long m
bra doAppend bra doAppend
@ -351,12 +382,12 @@ len equ 4
doAtSign lda atSign doAtSign lda atSign
ldy #4 ldy #4
sta [outPtr],y sta [outPtr],y
lda #1 lda #1 Set GS/OS buffer
ldy #2 ldy #2 string length word
sta [outPtr],y sta [outPtr],y to 1.
doAppend anop doAppend anop
ldy #0 ldy #4 Start index beyond length words.
short m short m
lp lda [outPtr],y lp lda [outPtr],y
beq noSep beq noSep
@ -369,7 +400,7 @@ lp lda [outPtr],y
noSep lda #':' No separator found; use ":". 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 long m
pei (str+2) pei (str+2)
@ -388,30 +419,44 @@ pushptr phx
clc Add 2 bytes to address of clc Add 2 bytes to address of
lda outPtr GS/OS output buffer to 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. bcc no_ovf input string.
inc outPtr+2 inc outPtr+2
no_ovf sta outPtr no_ovf sta outPtr
lda [outPtr] Adjust string length lda [outPtr] Adjust string length
clc to include appended clc to include appended
adc len string (parameter). adc str_len string (parameter).
sta [outPtr] sta [outPtr]
; ;
; NOTE: The returned value points to a GS/OS string, two bytes offset ; 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 ; from the allocated memory for a GS/OS result buffer. When the
; memory is deallocated, the address must be adjusted back. ; memory is deallocated, the address must be adjusted back.
; ;
exit unlock mutex
return 4:outPtr return 4:outPtr
mutex key
atSign dc c'@',i1'0' atSign dc c'@',i1'0'
;
; Parameter block for Shell call ReadVariable (p 423 in ORCA/M reference) ; 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 dc a4'home' address of variable's name
outPtr1 dc a4'0' pointer to result buffer RVresult ds 4 GS/OS Output buffer ptr
dc i2'0' value of 'Export' flag (returned) 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' home gsstr 'HOME'
END END

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * SHELLUTIL.ASM
* By Tim Meekins * By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
* *
* Utility functions used by the shell. Mainly string functions. * Utility functions used by the shell. Mainly string functions.
* *
@ -183,171 +184,6 @@ done sta [q],y
END 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 ; 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 hold equ 1
space equ hold+2 space equ hold+2
@ -467,7 +303,7 @@ done anop
;========================================================================= ;=========================================================================
c2gsstr START c2gsstr START
len equ 1 len equ 1
gstr equ len+2 gstr equ len+2
space equ gstr+4 space equ gstr+4
@ -488,7 +324,7 @@ end equ cstr+4
adc #3 adc #3
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta gstr sta gstr
stx gstr+2 stx gstr+2
incad @xa incad @xa
@ -523,7 +359,7 @@ end equ cstr+4
;========================================================================= ;=========================================================================
catcstr START catcstr START
new equ 1 new equ 1
space equ new+4 space equ new+4
q equ space+2 q equ space+2
@ -550,7 +386,7 @@ end equ p+4
plx plx
pea 0 pea 0
pha pha
jsl ~NEW ~NEW
sta new sta new
stx new+2 stx new+2
@ -591,13 +427,7 @@ done ldx new+2
;===================================================================== ;=====================================================================
nullfree START nullfree START
* lda 6,s DEBUG code: break if
* and #$FF80 address is > $007FFFFF
* beq notbad
* brk $db
*notbad anop
lda 4,s lda 4,s
ora 6,s ora 6,s
bne ok bne ok
@ -609,7 +439,7 @@ nullfree START
plx plx
rtl rtl
ok jml ~DISPOSE ok ~DISPOSE
END END
@ -654,7 +484,7 @@ newline ENTRY
************************************************************************** **************************************************************************
getenv START getenv START
len equ 1 len equ 1
retval equ len+2 retval equ len+2
space equ retval+4 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. inc a Add 1 more for terminating null byte.
pea 0 pea 0
pha pha
jsl ~NEW Request the memory. ~NEW Request the memory.
sta RVresult Store address in ReadVariable sta RVresult Store address in ReadVariable
stx RVresult+2 parameter block and stx RVresult+2 parameter block and
sta retval direct page pointer. sta retval direct page pointer.

View File

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

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * STDIO.ASM
* By Tim Meekins * By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
* *
* This is the custom stdio for the shell * This is the custom stdio for the shell
* *
@ -117,65 +118,6 @@ exit long a SWITCH TO FULL-WORD MEMORY MODE.
END 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 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 * errflush - flush stderr

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 sv_alloc START
ptr equ 0 ptr equ 0
space equ ptr+4 space equ ptr+4
@ -48,7 +48,7 @@ space equ ptr+4
asl a asl a
pea 0 pea 0
pha pha
jsl ~NEW Allocate the memory ~NEW Allocate the memory
sta ptr and save address in sta ptr and save address in
stx ptr+2 direct page variable. stx ptr+2 direct page variable.
@ -81,7 +81,7 @@ init sta [ptr],y Set all entries
************************************************************************** **************************************************************************
sv_add START sv_add START
p equ 0 p equ 0
base equ p+4 base equ p+4
space equ base+4 space equ base+4
@ -106,7 +106,7 @@ space equ base+4
inc a inc a
pea 0 pea 0
pha pha
jsl ~NEW Allocate memory for it. ~NEW Allocate memory for it.
sta p Store address in p/p+1. sta p Store address in p/p+1.
stx p+2 stx p+2

View File

@ -6,12 +6,13 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * 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 * TERM.ASM
* By Tim Meekins * By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6
* *
* Routines for dealing with Termcap under gsh. * Routines for dealing with Termcap under gsh.
* *
@ -37,13 +38,13 @@ TIOCGETP gequ $40067408
************************************************************************** **************************************************************************
InitTerm START InitTerm START
using termdata using termdata
; ;
; See if $TERM exists ; See if $TERM exists
; ;
ReadVariableGS dummyresult ReadVariableGS ReadVarPB
lda term_len Get length of $TERM lda term_len Get length of $TERM
bne allocate If 0, bne allocate If 0,
@ -52,12 +53,12 @@ InitTerm START
allocate anop Allocate termcap buffers. allocate anop Allocate termcap buffers.
ph4 #1024 ph4 #1024
jsl ~NEW ~NEW
sta bp sta bp
stx bp+2 stx bp+2
ph4 #1024 ph4 #1024
jsl ~NEW ~NEW
sta areabuf sta areabuf
stx areabuf+2 stx areabuf+2