Added startup protocol as requested by Devin Reed (PR#78) and Steve Reeves

(PR#85, PR#86):
   For login shells (command line starts with '-'),
	If $PATH doesn't start with ':' or contain a space,
	   change all ":" to " ".
	source /etc/glogin
	source $HOME/glogin
$HOME/gshrc is sourced afterward for both login and non-login shells.

Don't the print number of hashed commands (from "rehash") until all
initialization is completed.

Only pass exported environment variables to child processes, and prevent child
processes from changing parent's environment.

A null command followed by a redirection of stdout, for example
  > /tmp/list
would cause an error message "<garbage> not found" due to incorrect
setting of command buffer pointer.

Filename completion did not work following ">&" or ">" without a trailing
space.

Entabbed all the asm files, saving more than 36,000 bytes.
This commit is contained in:
tribby 1998-09-08 16:53:14 +00:00
parent 2e0ebb5392
commit 1dc5497309
24 changed files with 2868 additions and 2690 deletions

View File

@ -1,6 +1,43 @@
GSH 2.0 UPDATES
^^^^^^^^^^^^^^^
Sep 7 98 [dmt] Changes to this point checked-in to master archive.
Sep 7 98 [dmt] In "gettoken" (cmd.asm), decrement buf (pointer to
command line) when EOL is reached; otherwise if the character
following the command in the buffer is non-zero, the garbage
after the real command will be interpreted as another command.
Test case: "> /tmp/list" would cause "not found" error message.
Sep 6 98 [dmt] Added startup protocol as requested by Devin Reed
(PR#78) and Steve Reeves (PR#85, PR#86):
For login shells (command line starts with '-'),
If $PATH doesn't start with ':' or contain a space,
change all ":" to " ".
source /etc/glogin
source $HOME/glogin
($HOME/gshrc is sourced afterward for both login and non-login).
In rehash built-in command, don't the print number of hashed
until all initialization is completed.
Restored commented-out PushVariablesGS at start of "shell" in
shell.asm to keep subshells from changing parent's environment.
Aug 4 98 [dmt] Fixed defects in wordmatch (edit.asm) related to
recognizing commands versus filenames during tab and ctrl-D
filename completion. Suppose there is a file "filename" in the
current directory and you enter one of the following:
command >& filen
command >filen
and press tab. Instead of getting filename completion, you
would get a beep. In the first case, gsh thought the "&"
was putting the command in the background and filen was the
beginning of a command name rather than a filename. In the
second, gsh included the ">" in the filename match pattern.
Aug 3 98 [dmt] Entabbed all the asm files (saved >36,000 bytes).
Aug 3 98 [dmt] Changes to this point checked-in to master archive.
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

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: alias.asm,v 1.5 1998/08/03 17:30:25 tribby Exp $
* $Id: alias.asm,v 1.6 1998/09/08 16:53:05 tribby Exp $
*
**************************************************************************
*
@ -26,7 +26,7 @@
*
* unalias subroutine (4:argv,2:argc)
* Returns with status=0 in Accumulator
*
*
* initalias jsr/rts with no parameters
*
* expandalias subroutine (4:cmd)
@ -37,7 +37,7 @@
*
* removealias subroutine (4:aliasname)
* return
*
*
* findalias subroutine (4:aliasname),space
* return 4:value
*
@ -170,9 +170,9 @@ setalias ldy #4+2 ;put alias name on stack
add2 argv,#8,argv
dec2 argc
dec2 argc
buildalias lda argc
buildalias lda argc
beq setit
pei (arg+2)
@ -184,7 +184,7 @@ buildalias lda argc
pha
lda [argv]
pha
jsr catcstr
jsr catcstr
stx arg+2
sta arg
jsl nullfree
@ -194,7 +194,7 @@ buildalias lda argc
pei (arg+2)
pei (arg)
ph4 #spacestr
jsr catcstr
jsr catcstr
stx arg+2
sta arg
jsl nullfree
@ -285,7 +285,7 @@ done lda space
lda #0
rtl
rtl
Usage dc c'Usage: unalias name ...',h'0d00'
@ -315,7 +315,7 @@ yahaha sta AliasTable,x
rts
END
END
;=========================================================================
;
@ -324,7 +324,7 @@ yahaha sta AliasTable,x
;=========================================================================
expandalias START
outbuf equ 0
sub equ outbuf+4
word equ sub+4
@ -343,7 +343,8 @@ space equ buf+4
stx word+2
sta word
lda #0
sta [buf] ;In case we're called with empty string
sta [buf] In case we're called with empty string
sta [word]
;
; eat leading spaces
;
@ -427,7 +428,7 @@ next lda [cmd]
if2 @a,eq,#';',nextalias
if2 @a,eq,#'&',nextalias
if2 @a,eq,#'|',nextalias
if2 @a,eq,#'\',backstabber
if2 @a,eq,#'\',backstabber
if2 @a,eq,#"'",singquoter
if2 @a,eq,#'"',doubquoter
bra next
@ -484,7 +485,7 @@ done ldx word+2
;=========================================================================
addalias START
using AliasData
tmp equ 0
@ -535,7 +536,7 @@ replace ldy #8+2
pha
jsl nullfree
pei (aliasval+2)
pei (aliasval)
pei (aliasval)
jsr cstrlen
inc a
pea 0
@ -566,7 +567,7 @@ notfound ph4 #4*3
lda AliasTable+2,x
sta [ptr],y
pei (aliasname+2)
pei (aliasname)
pei (aliasname)
jsr cstrlen
inc a
pea 0
@ -585,7 +586,7 @@ notfound ph4 #4*3
pei (tmp)
jsr copycstr
pei (aliasval+2)
pei (aliasval)
pei (aliasval)
jsr cstrlen
inc a
pea 0
@ -608,7 +609,7 @@ notfound ph4 #4*3
sta AliasTable,x
lda ptr+2
sta AliasTable+2,x
done return
END
@ -644,8 +645,8 @@ space equ ptr+4
adc #AliasTable
sta oldptr
searchloop ora2 ptr,ptr+2,@a
beq done
searchloop ora2 ptr,ptr+2,@a
beq done
ldy #4+2
lda [ptr],y
@ -688,7 +689,7 @@ foundit ldy #2
pei (ptr+2)
pei (ptr)
jsl nullfree
done return
END
@ -721,8 +722,8 @@ space equ value+4
lda AliasTable+2,x
sta ptr+2
searchloop ora2 ptr,ptr+2,@a
beq done
searchloop ora2 ptr,ptr+2,@a
beq done
ldy #4+2
lda [ptr],y
@ -817,34 +818,34 @@ done return 4:value
;
;=========================================================================
hashalias PRIVATE
hashalias PRIVATE
hashval equ 0
space equ hashval+2
hashval equ 0
space equ hashval+2
subroutine (4:p),space
lda #11
sta hashval
subroutine (4:p),space
lda #11
sta hashval
ldy #0
loop asl hashval
lda [p],y
and #$FF
beq done
clc
adc hashval
sta hashval
iny
bra loop
done UDivide (hashval,#VTABSIZE),(@a,@a)
ldy #0
loop asl hashval
lda [p],y
and #$FF
beq done
clc
adc hashval
sta hashval
iny
bra loop
done UDivide (hashval,#VTABSIZE),(@a,@a)
asl2 a ;Make it an index.
sta hashval
asl2 a ;Make it an index.
sta hashval
return 2:hashval
return 2:hashval
END
END
;=========================================================================
;
@ -857,6 +858,6 @@ AliasData DATA
AliasNum dc i2'0'
AliasPtr dc i4'0'
AliasTable ds VTABSIZE*4
AliasTable ds VTABSIZE*4
END
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: bufpool.asm,v 1.4 1998/08/03 17:30:26 tribby Exp $
* $Id: bufpool.asm,v 1.5 1998/09/08 16:53:05 tribby Exp $
*
**************************************************************************
*
@ -30,7 +30,7 @@
* bufpool data:
* pool1024 dc i4'0'
* pool1024mutex key
*
*
**************************************************************************
mcopy /obj/gno/bin/gsh/bufpool.mac
@ -45,7 +45,7 @@ dummybufpool start ; ends up in .root
**************************************************************************
alloc1024 START
using bufpool
lock pool1024mutex
@ -64,7 +64,7 @@ alloc1024 START
lda [1],y
sta pool1024+2
unlock pool1024mutex
pla
pla
plx
pld
rtl
@ -119,5 +119,5 @@ bufpool DATA
pool1024 dc i4'0'
pool1024mutex key
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: builtin.asm,v 1.5 1998/08/03 17:30:26 tribby Exp $
* $Id: builtin.asm,v 1.6 1998/09/08 16:53:05 tribby Exp $
*
**************************************************************************
*
@ -25,12 +25,12 @@
*
* builtin subroutine (2:argc,4:argv)
* Returns completion status in Accumulator
*
*
* IsBuiltin subroutine (4:name)
* return 2:tbl
*
* Remainder are interfaces to builtin commands with interface
* subroutine (4:argv,2:argc)
* subroutine (4:argv,2:argc)
* returns status in accumulator
* cd (chdir is entry as an alternate name)
* clear
@ -173,7 +173,7 @@ space equ tbl+4
subroutine (4:name),space
ld4 builtintbl,tbl
builtinloop ldy #2
builtinloop ldy #2
lda [tbl]
ora [tbl],y
beq nofile
@ -193,7 +193,7 @@ foundit ldy #8 Get the fork/nofork flag
bra foundbuiltin
nofile lda #-1 Set not-found return value.
foundbuiltin sta tbl
foundbuiltin sta tbl
return 2:tbl
@ -211,33 +211,33 @@ BuiltinData DATA
; command. Third value is fork flag (0 to fork, 1 for no fork).
; TABLE MUST BE SORTED BY COMMAND NAME.
;
builtintbl dc a4'aliasname,alias',i2'0'
builtintbl dc a4'aliasname,alias',i2'0'
dc a4'bgname,bg',i2'1'
dc a4'bindkeyname,bindkey',i2'0'
dc a4'cdname,cd',i2'1'
dc a4'chdirname,chdir',i2'1'
dc a4'clearname,clear',i2'1' Changed to unforked
dc a4'cdname,cd',i2'1'
dc a4'chdirname,chdir',i2'1'
dc a4'clearname,clear',i2'1' Changed to unforked
dc a4'cmdname,cmdbi',i2'0'
dc a4'dirsname,dirs',i2'0'
dc a4'echoname,echo',i2'0'
dc a4'echoname,echo',i2'0'
dc a4'editname,edit',i2'1'
dc a4'exitname,exit',i2'1'
dc a4'exportname,export',i2'1'
dc a4'exitname,exit',i2'1'
dc a4'exportname,export',i2'1'
dc a4'fgname,fg',i2'1'
dc a4'hashname,hashbi',i2'0'
dc a4'hname,PrintHistory',i2'0'
dc a4'hname,PrintHistory',i2'0'
dc a4'jobsname,jobs',i2'1'
dc a4'killname,kill',i2'1'
dc a4'killname,kill',i2'1'
dc a4'popdname,popd',i2'1'
dc a4'pfxname,prefix',i2'1'
dc a4'psname,psbi',i2'0'
dc a4'pfxname,prefix',i2'1'
dc a4'psname,psbi',i2'0'
dc a4'pushdname,pushd',i2'1'
dc a4'pwdname,pwd',i2'1'
dc a4'rehashname,rehash',i2'1'
dc a4'setname,set',i2'0'
dc a4'pwdname,pwd',i2'1'
dc a4'rehashname,rehash',i2'1'
dc a4'setname,set',i2'0'
dc a4'setbugname,setdebug',i2'0'
dc a4'setenvname,setenv',i2'0'
dc a4'sourcename,source',i2'1' Changed to unforked
dc a4'sourcename,source',i2'1' Changed to unforked
dc a4'stopname,stop',i2'1'
dc a4'tsetname,tset',i2'1'
dc a4'unaliasname,unalias',i2'1'
@ -246,18 +246,18 @@ builtintbl dc a4'aliasname,alias',i2'0'
dc a4'whichname,which',i2'0'
dc i4'0,0'
aliasname dc c'alias',h'00'
aliasname dc c'alias',h'00'
bgname dc c'bg',h'00'
bindkeyname dc c'bindkey',h'00'
chdirname dc c'chdir',h'00'
cdname dc c'cd',h'00'
clearname dc c'clear',h'00'
chdirname dc c'chdir',h'00'
cdname dc c'cd',h'00'
clearname dc c'clear',h'00'
cmdname dc c'commands',h'00'
dirsname dc c'dirs',h'00'
echoname dc c'echo',h'00'
editname dc c'edit',h'00'
exitname dc c'exit',h'00'
exportname dc c'export',h'00'
exportname dc c'export',h'00'
fgname dc c'fg',h'00'
hashname dc c'hash',h'00'
hname dc c'history',h'00'
@ -268,17 +268,17 @@ popdname dc c'popd',h'00'
psname dc c'ps',h'00'
pushdname dc c'pushd',h'00'
pwdname dc c'pwd',h'00'
rehashname dc c'rehash',h'00'
rehashname dc c'rehash',h'00'
setbugname dc c'setdebug',h'00'
setname dc c'set',h'00'
setname dc c'set',h'00'
setenvname dc c'setenv',h'00'
sourcename dc c'source',h'00'
stopname dc c'stop',h'00'
tsetname dc c'tset',h'00'
unaliasname dc c'unalias',h'00'
unhashname dc c'unhash',h'00'
unsetname dc c'unset',h'00'
whichname dc c'which',h'00'
unaliasname dc c'unalias',h'00'
unhashname dc c'unhash',h'00'
unsetname dc c'unset',h'00'
whichname dc c'which',h'00'
END
@ -327,8 +327,8 @@ end equ argv+4
;
; Illegal parameters: print usage string
;
showusage inc status Return status = 1.
lda [argv]
showusage inc status Return status = 1.
lda [argv]
tax
ldy #2
lda [argv],y
@ -386,7 +386,7 @@ paramcd anop
if2 @a,ne,#'-',setprefix
jmp showusage
setprefix pei (dpg+2)
setprefix pei (dpg+2)
pei (dpg)
jsr c2gsstr
sta PRecPath
@ -515,7 +515,7 @@ exit lda space
lda #0
rtl
rtl
Usage dc c'Usage: clear',h'0d00'
@ -572,7 +572,7 @@ end equ argv+4
; First argument begins with "-"; only legal value is -n
lda [ptr],y Get second
and #$FF character.
and #$FF character.
if2 @a,eq,#'n',gotn If != 'n', it's a bad one.
showusage ldx #^Usage Incorrect parameter usage:
@ -608,7 +608,7 @@ putloop lda [ptr] Get first
lda [ptr] to the next
and #$FF character.
beq doneput If 0, done with this argument.
if2 @a,ne,#'b',esc02 Check for escape codes: "b"
if2 @a,ne,#'b',esc02 Check for escape codes: "b"
ldx #1
jsr moveleft moveleft
bra didit
@ -678,7 +678,7 @@ exit jsr flush Print the buffer.
lda #0
rtl
rtl
Usage dc c'Usage: echo [-n] [strings...]',h'0d00'
@ -721,7 +721,7 @@ end equ argv+4
wait lock pwdmutex
pea 0
jsl getpfxstr Get value of prefix 0.
jsl getpfxstr Get value of prefix 0.
sta ptr
stx ptr+2
@ -757,7 +757,7 @@ exit lda space Deallocate stack space
lda #0 Return status always 0.
rtl
rtl
pwdmutex key
@ -834,7 +834,7 @@ loop add2 argv,#4,argv
;
; was it a built-in?
;
chkbuiltin pei (file+2)
chkbuiltin pei (file+2)
pei (file)
jsl IsBuiltin
cmp #-1
@ -846,7 +846,7 @@ foundbuiltin ldx #^builtstr
;
; See if it was hashed
;
tryhash pei (file+2)
tryhash pei (file+2)
pei (file)
ph4 hash_table
ph4 #hash_paths
@ -885,7 +885,7 @@ showcwd pei (ptr+2)
jsl nullfree
pea 0
jsl getpfxstr Get value of prefix 0.
jsl getpfxstr Get value of prefix 0.
sta ptr
stx ptr+2
@ -940,7 +940,7 @@ exit lda space
lda #0
rtl
rtl
whicherr dc c'Usage: which [file ...]',h'0d00'
builtstr dc c'Shell Built-in Command',h'00'
@ -952,8 +952,8 @@ pwdmutex key
GRec dc i'4'
GRecPath ds 4
ds 2
GRecFileType ds 2
GRecAuxType ds 4
GRecFileType ds 2
GRecAuxType ds 4
END
@ -1072,7 +1072,7 @@ showone ldy #1*4+2 Put pointer to
jsr cstrlen Get length of argument.
tax
Dec2Int (numstr,@x,#0),@a Convert to integer.
Dec2Int (numstr,@x,#0),@a Convert to integer.
cmp #32 If prefix num >= 32,
bcc getpfx
jsr newline just print blank line.
@ -1119,7 +1119,7 @@ setprefix ldy #1*4+2 Put pointer to
Dec2Int (numstr,@x,#0),PRecNum Convert to integer string.
lda PRecNum
lda PRecNum
cmp #32 If prefix num >= 32,
bcs done nothing to do.
@ -1145,7 +1145,7 @@ setprefix ldy #1*4+2 Put pointer to
ErrorGS Err
bra done
ok if2 GRecFT,eq,#$F,ok2 If filetype != $F,
ok if2 GRecFT,eq,#$F,ok2 If filetype != $F,
ldx #^direrr print error message
lda #direrr 'Not a directory'
jsr errputs
@ -1175,7 +1175,7 @@ done unlock mutex
lda #0
rtl
rtl
mutex key
@ -1185,7 +1185,7 @@ usage dc c'Usage: prefix prefixnum prefixname',h'0d00'
bootstr dc c' *: ',h'00'
pfxstr dc c'00: ',h'00'
dirErr dc c'prefix: Not a directory',h'0d00'
;
; Parameter block for GS/OS GetFileInfo call
;
@ -1278,7 +1278,7 @@ exit lda space
lda #0
rtl
rtl
Usage dc c'Usage: ',h'00'
@ -1373,7 +1373,7 @@ loop lda [argv]
and #$FF
if2 @a,eq,#'-',turnoff
if2 @a,eq,#'+',turnon
ldx mode
ldx mode
bne showusage
ldx argc
dex
@ -1511,7 +1511,7 @@ showusage ldx #^usage
jmp return
ok getuid
sta myuid
sta myuid
kvm_open
sta ps
stx ps+2
@ -1730,7 +1730,7 @@ statetbl dc c'defunct '
dc c'waiting '
dc c'paused '
dc c'unknown '
END
**************************************************************************
@ -1870,7 +1870,7 @@ exit return 2:retval
usage dc c'usage: source file [arguments...]',h'0d00'
END
**************************************************************************
*
* COMMANDS: builtin command

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: dir.asm,v 1.5 1998/08/03 17:30:27 tribby Exp $
* $Id: dir.asm,v 1.6 1998/09/08 16:53:07 tribby Exp $
*
**************************************************************************
*
@ -63,7 +63,7 @@ InitDStack START
rts
END
END
**************************************************************************
*
@ -196,7 +196,7 @@ xgoodie jsl dotods
pla
sta dirstack+2,y
jmp gototop
rotate add4 arg,#1,p
pei (p+2)
pei (p)
@ -247,7 +247,7 @@ nextrot pla
bra gototop
godir jsl dotods
pei (arg+2)
pei (arg+2)
pei (arg)
jsl gotodir
bne exit
@ -429,7 +429,7 @@ space equ retval+2
stz retval
pei (dir+2)
pei (dir+2)
pei (dir)
jsr c2gsstr
sta PRecPath
@ -484,9 +484,9 @@ Err dc i2'1' pCount
ErrError ds 2 Error number
dirErr dc c': Not a directory',h'0d00'
END
**************************************************************************
*
* Display the directory stack
@ -519,7 +519,7 @@ loop lda flag
pha
jsr puts
jsl nullfree
bra next
bra next
long ldy idx
lda dirstack+2,y
tax
@ -572,7 +572,7 @@ space equ idx+2
setit lock mutex
pea 0
jsl getpfxstr Get value of prefix 0.
jsl getpfxstr Get value of prefix 0.
sta p
stx p+2
@ -602,7 +602,7 @@ ok clc Source is result
phy
pei (p+2) Destination is first
pei (p) byte of buffer.
jsr copycstr
jsr copycstr
ldy idx Store address of string
lda p in current position
@ -638,7 +638,7 @@ tods dc i'0'
**************************************************************************
path2tilde START
ptr equ 0
newpath equ ptr+4
home equ newpath+4
@ -670,7 +670,7 @@ space equ home+4
beq notfound2 If 0, just copy the rest.
tax Use X to count down HOME chars.
ldy #0 path index is based from 0.
checkhome lda [path],y
checkhome lda [path],y
and #$FF Isolate character in parameter,
beq notfound2 checking for end of string,
jsr tolower converting to lower-case
@ -687,14 +687,14 @@ checkhome lda [path],y
bne notfound there is no match.
pla Pop the parameter character off stack.
dex Decrement $home length counter.
bne checkhome If more, stay in loop.
bne checkhome If more, stay in loop.
;
; First part of parameter matched $HOME
;
cmp #'/' This char = "/"?
beq found yes -- it's a match.
lda [path],y If the following character
lda [path],y If the following character
and #$FF is zero (end of string),
beq found
jsr toslash '/', or ':', we have a match.
@ -703,13 +703,13 @@ checkhome lda [path],y
found lda #'~' Store '~' as first character
sta [ptr] in result buffer, and bump
incad ptr result pointer.
bra copyrest
bra copyrest
;
; 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.
notfound2 ldy #0 Not found: copy from beginning.
;
; Copy remainder of parameter (Y-reg marks start) to destination string
@ -720,13 +720,13 @@ copyloop lda [path],y
cmp #':'
bne copyput
lda #'/'
copyput sta [ptr]
copyput sta [ptr]
long a
incad ptr
short a
iny
bra copyloop
endcopy sta [ptr]
endcopy sta [ptr]
long a
dec ptr If final character
lda [ptr] was "/",
@ -753,7 +753,7 @@ homename gsstr 'home' Env variable name
**************************************************************************
getpfxstr START
p equ 0
space equ p+4
@ -768,11 +768,11 @@ space equ p+4
beq doboot use GetBootVol, not GetPrefix.
sta gpnum Store prefix num in parameter block.
ld4 TempResultBuf,gppath
ld4 TempResultBuf,gppath
GetPrefix gpparm
bra chklen
doboot ld4 TempResultBuf,gbpath
doboot ld4 TempResultBuf,gbpath
GetBootVol gbparm
chklen lda TempRBlen Use that length
@ -807,12 +807,12 @@ memok lda TempRBlen Store result buf
cmp #$FFFF whether to use
beq doboot2 GetPrefix or GetBootVol.
mv4 p,gppath
mv4 p,gppath
GetPrefix gpparm
bcs rpterr
bra done
doboot2 mv4 p,gbpath
doboot2 mv4 p,gbpath
GetBootVol gbparm
bcc done If there was an error,

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: expand.asm,v 1.5 1998/08/03 17:30:28 tribby Exp $
* $Id: expand.asm,v 1.6 1998/09/08 16:53:08 tribby Exp $
*
**************************************************************************
*
@ -34,43 +34,43 @@ dummyexpand start ; ends up in .root
*
**************************************************************************
glob START
glob START
using vardata
count equ 0
gname equ count+2
sepptr equ gname+4
eptr equ sepptr+4
exppath equ eptr+4
filesep equ exppath+4
shallweglob equ filesep+2
wordbuf equ shallweglob+2
ptr equ wordbuf+4
buf equ ptr+4
space equ buf+4
count equ 0
gname equ count+2
sepptr equ gname+4
eptr equ sepptr+4
exppath equ eptr+4
filesep equ exppath+4
shallweglob equ filesep+2
wordbuf equ shallweglob+2
ptr equ wordbuf+4
buf equ ptr+4
space equ buf+4
subroutine (4:cmd),space
subroutine (4:cmd),space
;
; Check for noglob variable and exit if it's set to something.
;
lda varnoglob
beq doglob
beq doglob
; Allocate a buffer, copy the command line into it, and return.
jsl alloc1024
sta buf
stx buf+2
pei (cmd+2)
pei (cmd)
pei (buf+2)
pei (buf)
jsr copycstr
jmp bye
jsl alloc1024
sta buf
stx buf+2
pei (cmd+2)
pei (cmd)
pei (buf+2)
pei (buf)
jsr copycstr
jmp bye
;
; 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
stx buf+2
sta ptr ptr points to next
@ -83,12 +83,12 @@ doglob jsl alloc1024 Create an output buffer.
;
; Find the beginning of the next word
;
findword jsr g_getbyte Get character from command line.
jeq alldone
if2 @a,eq,#' ',passthru
if2 @a,eq,#009,passthru
if2 @a,eq,#013,passthru
if2 @a,eq,#010,passthru
findword jsr g_getbyte Get character from command line.
jeq alldone
if2 @a,eq,#' ',passthru
if2 @a,eq,#009,passthru
if2 @a,eq,#013,passthru
if2 @a,eq,#010,passthru
if2 @a,eq,#';',passthru
if2 @a,eq,#'&',passthru
if2 @a,eq,#'|',passthru
@ -97,98 +97,98 @@ findword jsr g_getbyte Get character from command line.
; It's not a simple pass-through character. See what needs to happen.
stz shallweglob
ldy #0
bra grabbingword
stz shallweglob
ldy #0
bra grabbingword
; For pass-through characters, just copy to output buffer.
passthru jsr g_putbyte
bra findword
passthru jsr g_putbyte
bra findword
;
; single out the next word [y is initialized above]
;
grabword jsr g_getbyte
grabbingword if2 @a,eq,#"'",grabsingle
if2 @a,eq,#'"',grabdouble
if2 @a,eq,#'\',grabslash
if2 @a,eq,#' ',procword
if2 @a,eq,#009,procword
if2 @a,eq,#013,procword
if2 @a,eq,#010,procword
if2 @a,eq,#000,procword
grabword jsr g_getbyte
grabbingword if2 @a,eq,#"'",grabsingle
if2 @a,eq,#'"',grabdouble
if2 @a,eq,#'\',grabslash
if2 @a,eq,#' ',procword
if2 @a,eq,#009,procword
if2 @a,eq,#013,procword
if2 @a,eq,#010,procword
if2 @a,eq,#000,procword
if2 @a,eq,#';',procword
if2 @a,eq,#'&',procword
if2 @a,eq,#'|',procword
if2 @a,eq,#'>',procword
if2 @a,eq,#'<',procword
if2 @a,eq,#'[',grabglob
if2 @a,eq,#']',grabglob
if2 @a,eq,#'*',grabglob
if2 @a,eq,#'?',grabglob
if2 @a,eq,#'[',grabglob
if2 @a,eq,#']',grabglob
if2 @a,eq,#'*',grabglob
if2 @a,eq,#'?',grabglob
; Default action (also completion of some of the other special cases)
grabnext sta [wordbuf],y Save character in word buffer
iny and bump its index.
bra grabword Get next character of word.
grabnext sta [wordbuf],y Save character in word buffer
iny and bump its index.
bra grabword Get next character of word.
; "[", "]", "*", "?"
grabglob ldx #1 Set "shallweglob"
stx shallweglob flag.
bra grabnext Store char in word buf & get next.
grabglob ldx #1 Set "shallweglob"
stx shallweglob flag.
bra grabnext Store char in word buf & get next.
; "\"
grabslash sta [wordbuf],y Save "\" in word buffer
iny and bump its index.
jsr g_getbyte Get next character in cmd line.
beq procword If null byte, word is terminated.
bra grabnext Store char in word buf & get next.
grabslash sta [wordbuf],y Save "\" in word buffer
iny and bump its index.
jsr g_getbyte Get next character in cmd line.
beq procword If null byte, word is terminated.
bra grabnext Store char in word buf & get next.
; '"'
grabsingle sta [wordbuf],y Save char in word buffer
iny and bump its index.
jsr g_getbyte Get next character in cmd line.
beq procword If null byte, word is terminated.
if2 @a,eq,#"'",grabnext If "'", store and grab next char.
bra grabsingle Save new char and stay in this loop.
grabsingle sta [wordbuf],y Save char in word buffer
iny and bump its index.
jsr g_getbyte Get next character in cmd line.
beq procword If null byte, word is terminated.
if2 @a,eq,#"'",grabnext If "'", store and grab next char.
bra grabsingle Save new char and stay in this loop.
; "'"
grabdouble sta [wordbuf],y Save char in word buffer
iny and bump its index.
jsr g_getbyte Get next character in cmd line.
beq procword If null byte, word is terminated.
if2 @a,eq,#'"',grabnext If '"', store and grab next char.
bra grabdouble Save new char and stay in this loop.
grabdouble sta [wordbuf],y Save char in word buffer
iny and bump its index.
jsr g_getbyte Get next character in cmd line.
beq procword If null byte, word is terminated.
if2 @a,eq,#'"',grabnext If '"', store and grab next char.
bra grabdouble Save new char and stay in this loop.
;
; The complete word is in the buffer. Time to process it.
;
procword dec cmd Decrement cmd line pointer.
lda #0 Terminate word buffer with
sta [wordbuf],y a null byte.
procword dec cmd Decrement cmd line pointer.
lda #0 Terminate word buffer with
sta [wordbuf],y a null byte.
;
; Shall we glob? Shall we scream? What happened, to our postwar dream?
;
lda [wordbuf]
and #$FF
if2 @a,eq,#'-',skipdeglob ;This allows '-?' option.
lda shallweglob
bne globword
lda [wordbuf]
and #$FF
if2 @a,eq,#'-',skipdeglob ;This allows '-?' option.
lda shallweglob
bne globword
;
; we didn't glob this word, so copy the word buffer to the output buffer
;
skipdeglob ldy #0
flushloop lda [wordbuf],y
and #$FF
beq doneflush
jsr g_putbyte
iny
bra flushloop
doneflush jmp findword
skipdeglob ldy #0
flushloop lda [wordbuf],y
and #$FF
beq doneflush
jsr g_putbyte
iny
bra flushloop
doneflush jmp findword
;
; Hello, boys and goils, velcome to Tim's Magik Shoppe
@ -224,64 +224,64 @@ globword stz filesep
stx eptr+2
sta sepptr
stx sepptr+2
ldy #0
exploop lda [wordbuf],y
and #$FF
beq endexp
iny
if2 @a,eq,#'\',expslash
if2 @a,eq,#"'",expsingle
if2 @a,eq,#'"',expdouble
if2 @a,eq,#'/',expsep
if2 @a,eq,#':',expsep
expput sta [eptr]
incad eptr
bra exploop
expsep sty filesep
sta [eptr]
incad eptr
mv4 eptr,sepptr
bra exploop
expslash lda [wordbuf],y
iny
and #$FF
beq endexp
bra expput
expsingle lda [wordbuf],y
iny
and #$FF
beq endexp
if2 @a,eq,#"'",exploop
sta [eptr]
incad eptr
bra expsingle
expdouble lda [wordbuf],y
iny
and #$FF
beq endexp
if2 @a,eq,#'"',exploop
sta [eptr]
incad eptr
bra expdouble
ldy #0
exploop lda [wordbuf],y
and #$FF
beq endexp
iny
if2 @a,eq,#'\',expslash
if2 @a,eq,#"'",expsingle
if2 @a,eq,#'"',expdouble
if2 @a,eq,#'/',expsep
if2 @a,eq,#':',expsep
expput sta [eptr]
incad eptr
bra exploop
expsep sty filesep
sta [eptr]
incad eptr
mv4 eptr,sepptr
bra exploop
expslash lda [wordbuf],y
iny
and #$FF
beq endexp
bra expput
expsingle lda [wordbuf],y
iny
and #$FF
beq endexp
if2 @a,eq,#"'",exploop
sta [eptr]
incad eptr
bra expsingle
expdouble lda [wordbuf],y
iny
and #$FF
beq endexp
if2 @a,eq,#'"',exploop
sta [eptr]
incad eptr
bra expdouble
;
; We really didn't mean to expand the filename, so, copy it back again..
;
endexp ldy filesep
copyback lda [wordbuf],y
iny
and #$FF
sta [sepptr]
incad sepptr
cmp #0
bne copyback
endexp ldy filesep
copyback lda [wordbuf],y
iny
and #$FF
sta [sepptr]
incad sepptr
cmp #0
bne copyback
;
; Calculate length by subtracting sepptr from starting address
;
sub2 sepptr,exppath,@a
dec2 a Don't count length word or \0
sub2 sepptr,exppath,@a
dec2 a Don't count length word or \0
dec a
sta [exppath]
sta [exppath]
;
; We now have enough to call InitWildCardGS!!!
; [ let's mutex the rest so we don't have to fix InitWC and NextWC ;-) ]
@ -295,7 +295,7 @@ copyback lda [wordbuf],y
InitWildcardGS initWCparm
ph4 #65 Allocate memory for
~NEW expanded name.
~NEW expanded name.
sta gname Store in direct
stx gname+2 page pointer
sta nWCname and in NextWildcardGS
@ -305,7 +305,7 @@ copyback lda [wordbuf],y
;
; Call shell routine NextWildcardGS to get the next name that matches.
;
WCloop NextWildcardGS nWCparm
WCloop NextWildcardGS nWCparm
ldy #2
lda [gname],y
beq nomore
@ -338,28 +338,28 @@ globoutta lda [gname],y Copy next character
;
; Place blank as separator after name and see if more are expanded.
;
lda #' '
jsr g_putbyte
bra WCloop
lda #' '
jsr g_putbyte
bra WCloop
;
; All of the names (if any) from this pattern have been expanded.
;
nomore anop
nomore anop
unlock glob_mutex
;
; Deallocate path buffers (we should probably alloc once, not each word... )
;
pei (gname+2)
pei (gname)
jsl nullfree
ldx exppath+2
lda exppath
jsl free1024
pei (gname+2)
pei (gname)
jsl nullfree
ldx exppath+2
lda exppath
jsl free1024
lda count If somehing was expanded,
jne findword go find the next word.
jne findword go find the next word.
; Nothing was expanded from the wildcard. If we wanted to act like
; ksh, we could pass the original text by doing a "jmp skipdeglob".
@ -378,32 +378,32 @@ nomore anop
lda #ignored
jsr errputs
jmp findword Go find the next word.
jmp findword Go find the next word.
;
; Goodbye, cruel world, I'm leaving you today, Goodbye, goodbye.
;
alldone jsr g_putbyte
ldx wordbuf+2
lda wordbuf
jsl free1024
alldone jsr g_putbyte
ldx wordbuf+2
lda wordbuf
jsl free1024
bye return 4:buf
bye return 4:buf
;
; Subroutine of glob: get a byte from the original command-line
;
g_getbyte lda [cmd]
incad cmd
and #$FF
rts
g_getbyte lda [cmd]
incad cmd
and #$FF
rts
;
; Subroutine of glob: put special characters. Same as g_putbyte, but
; if it is a special shell character then quote it.
;
g_putspecial and #$7F
g_putspecial and #$7F
if2 @a,eq,#' ',special
if2 @a,eq,#'.',special
if2 @a,eq,#013,special
@ -446,7 +446,7 @@ nWCname ds 4 Pointer to returned path name
nomatch dc c'No match: ',h'00'
ignored dc c' ignored',h'0d00'
END
END
**************************************************************************
*
@ -454,109 +454,109 @@ ignored dc c' ignored',h'0d00'
*
**************************************************************************
expandvars START
expandvars START
; Maximum number of characters in an environment variable or $<
MAXVAL equ 512
ptr equ 1
buf equ ptr+4
dflag equ buf+4
space equ dflag+2
cmd equ space+3
end equ cmd+4
ptr equ 1
buf equ ptr+4
dflag equ buf+4
space equ dflag+2
cmd equ space+3
end equ cmd+4
; subroutine (4:cmd),space
; subroutine (4:cmd),space
tsc
sec
sbc #space-1
tcs
phd
tcd
tsc
sec
sbc #space-1
tcs
phd
tcd
stz dflag Delimiter flag = FALSE.
jsl alloc1024
sta buf
sta ptr
stx buf+2
stx ptr+2
sta buf
sta ptr
stx buf+2
stx ptr+2
loop jsr e_getbyte
jeq done
if2 @a,eq,#"'",quote
if2 @a,eq,#'$',expand
if2 @a,eq,#'~',tilde
if2 @a,eq,#'\',slasher
jsr e_putbyte
bra loop
loop jsr e_getbyte
jeq done
if2 @a,eq,#"'",quote
if2 @a,eq,#'$',expand
if2 @a,eq,#'~',tilde
if2 @a,eq,#'\',slasher
jsr e_putbyte
bra loop
slasher jsr e_putbyte
jsr e_getbyte
jsr e_putbyte
bra loop
slasher jsr e_putbyte
jsr e_getbyte
jsr e_putbyte
bra loop
quote jsr e_putbyte
jsr e_getbyte
jeq done
if2 @a,ne,#"'",quote
jsr e_putbyte
bra loop
quote jsr e_putbyte
jsr e_getbyte
jeq done
if2 @a,ne,#"'",quote
jsr e_putbyte
bra loop
;
; Tilde expansion: use the contents of $home, but make sure the
; path delimiter(s) match what the user wants (either "/" or ":")
;
tilde anop
tilde anop
lock exp_mutex
lda #"oh" Strangely enough,
sta name this spells "home"!
lda #"em"
sta name+2
lda #"oh" Strangely enough,
sta name this spells "home"!
lda #"em"
sta name+2
sta dflag Delimiter flag = TRUE.
ldx #4
ldx #4
jmp getval
;
; Expand an environment variable since a '$' was encountered.
;
expand anop
expand anop
lock exp_mutex
lda #0
sta name
lda #0
sta name
lda [cmd]
and #$FF
if2 @a,eq,#'{',braceexpand
if2 @a,eq,#'<',stdinexpand
ldx #0
nameloop lda [cmd]
and #$FF
beq getval
if2 @a,cc,#'0',getval
if2 @a,cc,#'9'+1,inname
if2 @a,cc,#'A',getval
if2 @a,cc,#'Z'+1,inname
if2 @a,eq,#'_',inname
if2 @a,cc,#'a',getval
if2 @a,cc,#'z'+1,inname
bra getval
inname jsr e_getbyte
ldx #0
nameloop lda [cmd]
and #$FF
beq getval
if2 @a,cc,#'0',getval
if2 @a,cc,#'9'+1,inname
if2 @a,cc,#'A',getval
if2 @a,cc,#'Z'+1,inname
if2 @a,eq,#'_',inname
if2 @a,cc,#'a',getval
if2 @a,cc,#'z'+1,inname
bra getval
inname jsr e_getbyte
cpx #255 Only the first 255 characters
beq nameloop are significant.
sta name,x
inx
bra nameloop
sta name,x
inx
bra nameloop
;
; expand in braces {}
;
braceexpand jsr e_getbyte
braceexpand jsr e_getbyte
ldx #0
braceloop lda [cmd]
braceloop lda [cmd]
and #$FF
beq getval
jsr e_getbyte
@ -570,7 +570,7 @@ braceloop lda [cmd]
;
; get text from standard input
;
stdinexpand jsr e_getbyte
stdinexpand jsr e_getbyte
ReadLine (#value,#MAXVAL,#13,#0),@a
sta valueln
bra chklen
@ -578,15 +578,15 @@ stdinexpand jsr e_getbyte
;
; Get a value for this variable
;
getval stx nameln Save length of name.
ReadVariableGS ReadVarPB Read its value.
getval stx nameln Save length of name.
ReadVariableGS ReadVarPB Read its value.
lda valueln Get value length.
cmp #MAXVAL+1 If > maximum allowed length,
bcs expanded we didn't get anything.
cmp #0
chklen anop
beq expanded If 0, nothing to do
beq expanded If 0, nothing to do
tax Save length in X-reg.
lda dflag If delimiter flag isn't set,
beq storeval go store the variable value
@ -640,34 +640,34 @@ bump_c dex
storeval anop
lda valueln Get length.
tay Save length in Y-reg.
ldx #0 Use X-reg in index value.
putval lda value,x
jsr e_putbyte
inx
ldx #0 Use X-reg in index value.
putval lda value,x
jsr e_putbyte
inx
dey
bne putval
bne putval
expanded unlock exp_mutex
expanded unlock exp_mutex
stz dflag Delimiter flag = FALSE.
jmp loop
jmp loop
done jsr e_putbyte
done jsr e_putbyte
ldx buf+2
ldy buf
ldx buf+2
ldy buf
lda space
sta end-3
lda space+1
sta end-2
pld
tsc
clc
adc #end-4
tcs
lda space
sta end-3
lda space+1
sta end-2
pld
tsc
clc
adc #end-4
tcs
tya
rtl
tya
rtl
e_getbyte lda [cmd]
incad cmd
@ -678,7 +678,7 @@ e_putbyte short a
sta [ptr]
long a
incad ptr
rts
rts
exp_mutex key
@ -686,14 +686,14 @@ exp_mutex key
; GS/OS string to hold variable name
namestr anop
nameln ds 2 Length of name
name ds 256 Room for 255 chars + 0.
name ds 256 Room for 255 chars + 0.
; GS/OS result buffer to hold up to MAXVAL bytes of value
valueresult anop
dc i2'MAXVAL+4' Length of result buffer
valueln ds 2 Length of value
value ds MAXVAL Room for MAXVAL chars
value ds MAXVAL Room for MAXVAL chars
; Parameter block for shell ReadVariableGS calls
@ -703,4 +703,4 @@ RVname dc a4'namestr' Name (pointer to GS/OS string)
RVvalue dc a4'valueresult' Value (ptr to result buf or string)
RVexport ds 2 Export flag
END
END

View File

@ -1970,5 +1970,5 @@ skip&syscnt anop
MACRO
&lab ~DISPOSE
&lab anop
jml ~DISPOSE
jml ~DISPOSE
MEND

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: history.asm,v 1.5 1998/08/03 17:30:20 tribby Exp $
* $Id: history.asm,v 1.6 1998/09/08 16:53:10 tribby Exp $
*
**************************************************************************
*
@ -23,7 +23,7 @@
* Where historyRec is:
*
* [+0] NextHistory: pointer to historyRec
* [+4] HistoryCmd: string of characters
* [+4] HistoryCmd: string of characters
*
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | |
@ -32,7 +32,7 @@
*
* Interfaces defined in this file:
*
* InsertHistory
* InsertHistory
*
* PrevHistory
*
@ -55,8 +55,8 @@ dummyhistory start ; ends up in .root
setcom 60
histNext gequ 0
histCmd gequ 4
histNext gequ 0
histCmd gequ 4
;=========================================================================
;
@ -64,10 +64,10 @@ histCmd gequ 4
;
;=========================================================================
InsertHistory START
using HistoryData
using global
InsertHistory START
using HistoryData
using global
ptr2 equ 0
ptr equ ptr2+4
@ -80,26 +80,26 @@ space equ histvalptr+4
pei (cmd+2)
pei (cmd)
jsr cstrlen
sta len
pea 0
sta len
pea 0
clc
adc #4+1
pha
~NEW
sta ptr
stx ptr+2
ora ptr+2
beq putdone
pha
~NEW
sta ptr
stx ptr+2
ora ptr+2
beq putdone
inc lasthist
inc numhist
inc lasthist
inc numhist
lda historyptr ;Set up linked list pointers
sta [ptr]
ldy #histNext+2
lda historyptr+2
sta [ptr],y
mv4 ptr,historyptr
lda historyptr ;Set up linked list pointers
sta [ptr]
ldy #histNext+2
lda historyptr+2
sta [ptr],y
mv4 ptr,historyptr
pei (cmd+2)
pei (cmd)
@ -141,53 +141,53 @@ pushaddr phx Push address onto stack.
pea 0 Push signedFlag = 0 (unsigned)
Tool $280b Dec2Int.
pla Get result.
sta size
beq alldone
sta size
beq alldone
;
; Follow linked list until we reach size histories
;
mv4 historyptr,ptr
ldy #histNext+2
follow lda [ptr]
tax
ora [ptr],y
beq alldone ;not enough
dec size
beq prune
lda [ptr],y
sta ptr+2
stx ptr
bra follow
mv4 historyptr,ptr
ldy #histNext+2
follow lda [ptr]
tax
ora [ptr],y
beq alldone ;not enough
dec size
beq prune
lda [ptr],y
sta ptr+2
stx ptr
bra follow
;
; we have enough, start pruning
;
prune lda [ptr]
sta ptr2
lda [ptr],y
sta ptr2+2
lda #0
sta [ptr]
sta [ptr],y ;terminate last history
prune lda [ptr]
sta ptr2
lda [ptr],y
sta ptr2+2
lda #0
sta [ptr]
sta [ptr],y ;terminate last history
;
; Dispose remaining
;
dispose lda ptr2
dispose lda ptr2
ora ptr2+2
beq alldone
dec numhist
lda [ptr2]
sta ptr
lda [ptr2],y
sta ptr+2
pei (ptr2+2)
pei (ptr2)
jsl nullfree
lda ptr
sta ptr2
lda ptr+2
sta ptr2+2
ldy #histNext+2
bra dispose
lda [ptr2]
sta ptr
lda [ptr2],y
sta ptr+2
pei (ptr2+2)
pei (ptr2)
jsl nullfree
lda ptr
sta ptr2
lda ptr+2
sta ptr2+2
ldy #histNext+2
bra dispose
alldone pei (histvalptr+2)
pei (histvalptr)
@ -195,9 +195,9 @@ alldone pei (histvalptr+2)
goback return
size ds 2
size ds 2
END
END
;=========================================================================
;
@ -206,23 +206,23 @@ size ds 2
;
;=========================================================================
PrevHistory START
PrevHistory START
using HistoryData
using global
using HistoryData
using global
using termdata
ora2 historyptr,historyptr+2,@a ;If no history, then skip
jeq ctl5a
ora2 historyptr,historyptr+2,@a ;If no history, then skip
jeq ctl5a
ldx cmdloc ;Move cursor to beginning of line
ldx cmdloc ;Move cursor to beginning of line
jsr moveleft
lda cdcap
ora cdcap
beq ctl5b0
tputs (cdcap,#0,#outc)
bra ctl5g
bra ctl5g
ctl5b0 ldx cmdlen ;clear line
ctl5b dex
@ -235,47 +235,47 @@ ctl5b dex
ctl5c ldx cmdlen
jsr moveleft
ctl5g ora2 currenthist,currenthist+2,@a
bne ctl5i ;If not set up for current hist then
lda historyptr+2 ;Set up at start.
ldx historyptr
ldy #2
bra ctl5j
ctl5g ora2 currenthist,currenthist+2,@a
bne ctl5i ;If not set up for current hist then
lda historyptr+2 ;Set up at start.
ldx historyptr
ldy #2
bra ctl5j
ctl5i mv4 currenthist,0 ;Otherwise move to previous history
stz cmdlen
stz cmdloc
ldy #HistNext+2
lda [0]
tax
lda [0],y
ctl5i mv4 currenthist,0 ;Otherwise move to previous history
stz cmdlen
stz cmdloc
ldy #HistNext+2
lda [0]
tax
lda [0],y
ctl5j sta 0+2 ;Save some pointers
stx 0
sta currenthist+2
stx currenthist
ora 0 ;If ptr is 0 then at end, quit
beq ctl5a
ctl5j sta 0+2 ;Save some pointers
stx 0
sta currenthist+2
stx currenthist
ora 0 ;If ptr is 0 then at end, quit
beq ctl5a
ldx #0 ;Display and store command
iny2
ctl5h lda [0],y
ldx #0 ;Display and store command
iny2
ctl5h lda [0],y
and #$FF
sta cmdline,x
sta cmdline,x
beq ctl5ha
inx
iny
bra ctl5h
ctl5ha stx cmdlen
inx
iny
bra ctl5h
ctl5ha stx cmdlen
stx cmdloc
ldx #^cmdline
lda #cmdline
jsr puts
ctl5a rts
ctl5a rts
END
END
;=========================================================================
;
@ -284,37 +284,37 @@ ctl5a rts
;
;=========================================================================
NextHistory START
NextHistory START
using HistoryData
using global
using HistoryData
using global
using termdata
ora2 historyptr,historyptr+2,@a ;No hist, then skip
jeq ctl6a
ora2 historyptr,historyptr+2,@a ;No hist, then skip
jeq ctl6a
stz 4 ;Walk through linked list searching
stz 4+2 ; for hist prior to last hist.
mv4 historyptr,0
ctl6i if2 0,ne,currenthist,ctl6j
if2 0+2,eq,currenthist+2,ctl6k
ctl6j mv4 0,4
ldy #HistNext+2
lda [0]
tax
lda [0],y
sta 0+2
stx 0
bra ctl6i
stz 4 ;Walk through linked list searching
stz 4+2 ; for hist prior to last hist.
mv4 historyptr,0
ctl6i if2 0,ne,currenthist,ctl6j
if2 0+2,eq,currenthist+2,ctl6k
ctl6j mv4 0,4
ldy #HistNext+2
lda [0]
tax
lda [0],y
sta 0+2
stx 0
bra ctl6i
ctl6k ldx cmdloc ;Move cursor to left
ctl6k ldx cmdloc ;Move cursor to left
jsr moveleft
lda cdcap
ora cdcap
beq ctl6b0
tputs (cdcap,#0,#outc)
bra ctl6g
bra ctl6g
ctl6b0 ldx cmdlen ;clear line
ctl6b dex
@ -327,21 +327,21 @@ ctl6b dex
ctl6c ldx cmdlen
jsr moveleft
ctl6g stz cmdlen ;Get hist info.
stz cmdloc
mv4 4,currenthist
ora2 4,4+2,@a
beq ctl6a ;Whoops, back to end, quit
ctl6g stz cmdlen ;Get hist info.
stz cmdloc
mv4 4,currenthist
ora2 4,4+2,@a
beq ctl6a ;Whoops, back to end, quit
ldx #0 ;Output the new command
ldy #4
ctl6h lda [4],y
ldx #0 ;Output the new command
ldy #4
ctl6h lda [4],y
and #$ff
sta cmdline,x
sta cmdline,x
beq ctl6ha
iny
inx
bra ctl6h
iny
inx
bra ctl6h
ctl6ha stx cmdlen
stx cmdloc
@ -349,9 +349,9 @@ ctl6ha stx cmdlen
lda #cmdline
jsr puts
ctl6a rts
ctl6a rts
END
END
;=========================================================================
;
@ -359,15 +359,15 @@ ctl6a rts
;
;=========================================================================
SaveHistory START
SaveHistory START
using HistoryData
using global
using HistoryData
using global
svhisvalptr equ 0
space equ svhisvalptr+4
subroutine ,space
subroutine ,space
lda historyFN
sta DestroyParm+2
@ -409,28 +409,28 @@ pushaddr phx Push address onto stack.
;
; Create and write history to file
;
Destroy DestroyParm
Create CreateParm
jcs done
Open OpenParm
bcs done
mv2 OpenRef,(WriteRef,WriteCRRef,CloseRef)
Destroy DestroyParm
Create CreateParm
jcs done
Open OpenParm
bcs done
mv2 OpenRef,(WriteRef,WriteCRRef,CloseRef)
loop1 mv4 historyptr,0
mv2 size,count
ldy #histNext+2
loop2 lda 0
ora 0+2
beq next
lda [0]
tax
dec count
beq write
lda [0],y
sta 0+2
stx 0
bra loop2
write clc
loop1 mv4 historyptr,0
mv2 size,count
ldy #histNext+2
loop2 lda 0
ora 0+2
beq next
lda [0]
tax
dec count
beq write
lda [0],y
sta 0+2
stx 0
bra loop2
write clc
lda 0
adc #4
tax
@ -441,15 +441,15 @@ write clc
pha
phx
jsr cstrlen
sta WriteReq
Write WriteParm
bcs doneclose
Write WriteCR
bcs doneclose
next dec size
bne loop1
sta WriteReq
Write WriteParm
bcs doneclose
Write WriteCR
bcs doneclose
next dec size
bne loop1
doneclose Close CloseParm
doneclose Close CloseParm
done pei (svhisvalptr+2) Free $SAVEHISTORY value buffer
pei (svhisvalptr)
@ -458,38 +458,38 @@ done pei (svhisvalptr+2) Free $SAVEHISTORY value buffer
goback return
DestroyParm dc i2'1'
dc a4'historyFN'
DestroyParm dc i2'1'
dc a4'historyFN'
CreateParm dc i2'3'
dc a4'historyFN'
dc i2'$C3'
dc i2'0'
CreateParm dc i2'3'
dc a4'historyFN'
dc i2'$C3'
dc i2'0'
OpenParm dc i2'2'
OpenRef ds 2
dc a4'historyFN'
OpenParm dc i2'2'
OpenRef ds 2
dc a4'historyFN'
WriteParm dc i2'4'
WriteRef ds 2
WriteBuf dc a4'buffer'
WriteReq ds 4
ds 4
WriteParm dc i2'4'
WriteRef ds 2
WriteBuf dc a4'buffer'
WriteReq ds 4
ds 4
WriteCR dc i2'4'
WriteCRRef ds 2
dc a4'CRBuf'
dc i4'1'
ds 4
CRBuf dc i1'13'
WriteCR dc i2'4'
WriteCRRef ds 2
dc a4'CRBuf'
dc i4'1'
ds 4
CRBuf dc i1'13'
CloseParm dc i2'1'
CloseRef ds 2
CloseParm dc i2'1'
CloseRef ds 2
size ds 2
count ds 2
size ds 2
count ds 2
END
END
;=========================================================================
;
@ -497,65 +497,65 @@ count ds 2
;
;=========================================================================
ReadHistory START
ReadHistory START
using HistoryData
using global
using HistoryData
using global
lda historyFN
sta OpenParm+4
lda historyFN+2
lda historyFN+2
sta OpenParm+6
lda #0
sta historyptr
sta historyptr+2
lda #0
sta historyptr
sta historyptr+2
Open OpenParm
bcs done
mv2 OpenRef,(ReadRef,NLRef,CloseRef)
NewLine NLParm
bcs doneclose
Open OpenParm
bcs done
mv2 OpenRef,(ReadRef,NLRef,CloseRef)
NewLine NLParm
bcs doneclose
loop anop
Read ReadParm
bcs doneclose
ldy ReadTrans
beq doneclose
dey
loop anop
Read ReadParm
bcs doneclose
ldy ReadTrans
beq doneclose
dey
lda #0
sta buffer,y
ph4 #buffer
jsl InsertHistory
bra loop
jsl InsertHistory
bra loop
doneclose Close CloseParm
doneclose Close CloseParm
done rts
done rts
OpenParm dc i2'2'
OpenRef ds 2
dc a4'historyFN'
OpenParm dc i2'2'
OpenRef ds 2
dc a4'historyFN'
NLParm dc i2'4'
NLRef ds 2
dc i2'$7F'
dc i2'1'
dc a4'NLTable'
NLTable dc i1'13'
NLParm dc i2'4'
NLRef ds 2
dc i2'$7F'
dc i2'1'
dc a4'NLTable'
NLTable dc i1'13'
ReadParm dc i2'4'
ReadRef ds 2
dc a4'buffer'
dc i4'1024'
ReadTrans ds 4
ReadParm dc i2'4'
ReadRef ds 2
dc a4'buffer'
dc i4'1024'
ReadTrans ds 4
CloseParm dc i2'1'
CloseRef ds 2
CloseParm dc i2'1'
CloseRef ds 2
size ds 2
size ds 2
END
END
;=========================================================================
;
@ -578,61 +578,61 @@ InitHistory START
;
;=========================================================================
PrintHistory START
PrintHistory START
using HistoryData
using global
using HistoryData
using global
ptr equ 0
space equ ptr+4
ptr equ 0
space equ ptr+4
subroutine (2:argc,4:argv),space
subroutine (2:argc,4:argv),space
lda historyptr
ora historyptr+2
beq done
lda historyptr
ora historyptr+2
beq done
lda numhist
sta num
loop1 mv4 historyptr,ptr
lda num
bmi done
sta count
loop2 lda count
beq print
ldy #histNext+2
lda [ptr]
tax
lda [ptr],y
sta ptr+2
stx ptr
ora ptr
beq next
dec count
bra loop2
lda numhist
sta num
loop1 mv4 historyptr,ptr
lda num
bmi done
sta count
loop2 lda count
beq print
ldy #histNext+2
lda [ptr]
tax
lda [ptr],y
sta ptr+2
stx ptr
ora ptr
beq next
dec count
bra loop2
print sub2 lasthist,num,@a
Int2Dec (@a,#numbstr,#4,#0)
print sub2 lasthist,num,@a
Int2Dec (@a,#numbstr,#4,#0)
ldx #^numbstr
lda #numbstr
jsr puts
clc
ldx ptr+2
lda ptr
adc #4
ok jsr puts
clc
ldx ptr+2
lda ptr
adc #4
ok jsr puts
jsr newline
next dec num
bra loop1
next dec num
bra loop1
done return 2:#0
done return 2:#0
numbstr dc c'0000: ',h'00'
num ds 2
count ds 2
numbstr dc c'0000: ',h'00'
num ds 2
count ds 2
END
END
;=========================================================================
;
@ -651,4 +651,4 @@ savehistStr gsstr 'SAVEHIST'
histName dc c'/history',i1'0'
historyFN ds 4
END
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: invoke.asm,v 1.6 1998/08/03 17:30:21 tribby Exp $
* $Id: invoke.asm,v 1.7 1998/09/08 16:53:10 tribby Exp $
*
**************************************************************************
*
@ -76,11 +76,12 @@ end equ sfile+4
tsc
phd
tcd
;
; Redirect standard input
;
ora2 sfile,sfile+2,@a If no name provided,
beq execa skip it.
beq execa skip it.
pei (sfile+2) Convert c-string
pei (sfile) filename to
jsr c2gsstr GS/OS string.
@ -118,7 +119,7 @@ execa ora2 dfile,dfile+2,@a
ldx #^err2 Print error message:
lda #err2 'Error redirecting standard output.'
jmp badbye
;
;
; Redirect standard error
;
execb ora2 efile,efile+2,@a
@ -139,12 +140,12 @@ execb ora2 efile,efile+2,@a
ldx #^err3 Print error message:
lda #err3 'Error redirecting standard error.'
jmp badbye
;
;
; Is input piped in?
;
execc lda pipein
beq execd
dup2 (pipein,#1)
dup2 (pipein,#1)
mv2 pipein2,CloseRef
Close CloseParm
ldx #0
@ -170,7 +171,7 @@ goodbye ldy #0
bra exit
badbye jsr errputs
cop $7F ; get out of the way
cop $7F ; get out of the way
ldy #1
exit lda space
@ -185,15 +186,15 @@ exit lda space
cpy #1 Clear/set carry for success/failure.
rtl
rtl
;
; Parameter block for shell call to redirect I/O (ORCA/M manual p.425)
;
RedirectParm dc i2'3' pCount
RedirectDev ds 2 Dev num (0=stdin,1=stdout,2=errout)
RedirectApp ds 2 Append flag (0=delete)
RedirectFile ds 4 File name (GS/OS input string)
RedirectDev ds 2 Dev num (0=stdin,1=stdout,2=errout)
RedirectApp ds 2 Append flag (0=delete)
RedirectFile ds 4 File name (GS/OS input string)
;
; Parameter block for GS/OS call to close a file
@ -204,8 +205,8 @@ CloseRef dc i'0' refNum
err1 dc c'gsh: Error redirecting standard input.',h'0d00'
err2 dc c'gsh: Error redirecting standard output.',h'0d00'
err3 dc c'gsh: Error redirecting standard error.',h'0d00'
END
END
**************************************************************************
*
@ -213,7 +214,7 @@ err3 dc c'gsh: Error redirecting standard error.',h'0d00'
*
**************************************************************************
invoke START
invoke START
using hashdata
using vardata
@ -232,8 +233,8 @@ space equ dir+4
ld2 -1,rtnval
stz biflag ;not a built-in
lda argc Get number of arguments.
bne chknull If != 0 continue with processing.
lda argc Get number of arguments.
bne chknull If != 0 continue with processing.
lda sfile If any of the file pointers
ora sfile+2 are != NULL,
@ -243,25 +244,25 @@ space equ dir+4
ora efile+2
beq nulldone
ldx #^hehstr print error message:
lda #hehstr ' specify a command before redirecting.'
ldx #^spcmdstr print error message:
lda #spcmdstr ' specify a command before redirecting.'
jsr errputs
nulldone jmp done
nulldone jmp done
;
; Check for null command
;
chknull ldy #2 Move command line
lda [argv] pointer to
sta dir dir (4 bytes).
lda [argv],y
sta dir+2 If pointer == NULL
ora dir
beq nulldone all done.
lda [dir] If first character == '\0',
and #$FF
beq nulldone all done.
chknull ldy #2 Move command line
lda [argv] pointer to
sta dir dir (4 bytes).
lda [argv],y
sta dir+2 If pointer == NULL
ora dir
beq nulldone all done.
lda [dir] If first character == '\0',
and #$FF
beq nulldone all done.
;
; check for file
@ -276,37 +277,37 @@ checkfile anop
; Command is not listed in the built-in table. See if it was hashed
pei (dir+2)
pei (dir)
ph4 hash_table
ph4 #hash_paths
jsl search
cmp #0
bne changeit
cpx #0
beq skip
pei (dir+2)
pei (dir)
ph4 hash_table
ph4 #hash_paths
jsl search
cmp #0
bne changeit
cpx #0
beq skip
changeit sta dir
stx dir+2
changeit sta dir
stx dir+2
skip lock mutex2
pei (dir+2)
pei (dir)
skip lock mutex2
pei (dir+2)
pei (dir)
jsr c2gsstr
sta GRecPath
sta ptr
stx GRecPath+2
stx ptr+2
sta GRecPath
sta ptr
stx GRecPath+2
stx ptr+2
GetFileInfo GRec
GetFileInfo GRec
unlock mutex2
jcs notfound
jcs notfound
; File type $B5 is a GS/OS Shell application (EXE)
if2 GRecFileType,eq,#$B5,doExec
if2 GRecFileType,eq,#$B5,doExec
; File type $B3 is a GS/OS application (S16)
if2 @a,eq,#$B3,doExec
if2 @a,eq,#$B3,doExec
ldx vardirexec
bne ft02
@ -314,14 +315,14 @@ skip lock mutex2
jeq doDir Target is a directory; change to it.
; File type $B0 is a source code file (SRC)
ft02 if2 @a,ne,#$B0,badfile
ft02 if2 @a,ne,#$B0,badfile
; Type $B0, Aux $00000006 is a shell command file (EXEC)
if2 GRecAuxType,ne,#6,badfile
if2 GRecAuxType+2,ne,#0,badfile
jmp doShell
if2 GRecAuxType,ne,#6,badfile
if2 GRecAuxType+2,ne,#0,badfile
jmp doShell
badfile ldx dir+2
badfile ldx dir+2
lda dir
jsr errputs
ldx #^err1 Print error message:
@ -330,17 +331,17 @@ badfile ldx dir+2
free pei (ptr+2)
pei (ptr)
jsl nullfree
jmp done
jmp done
;
; launch an executable
;
doExec pei (ptr+2)
pei (ptr)
jsl nullfree
doExec pei (ptr+2)
pei (ptr)
jsl nullfree
jsr prefork
fork #invoke0
jsr postfork
fork #invoke0
jsr postfork
jmp done
@ -417,9 +418,9 @@ invoke0 phk
jsl infork
bcs invoke1
case on
jsl _execve For 2.0.6: call _execve, not execve
case off
case on
jsl _execve For 2.0.6: call _execve, not execve
case off
rtl
invoke1 pla
pla
@ -430,9 +431,9 @@ invoke1 pla
;
; Next command is a directory name, so change to that directory
;
doDir lock cdmutex
mv4 GRecPath,PRecPath
SetPrefix PRec
doDir lock cdmutex
mv4 GRecPath,PRecPath
SetPrefix PRec
unlock cdmutex
stz rtnval Return value: no fork done.
jmp free
@ -440,11 +441,11 @@ doDir lock cdmutex
;
; Next command is a shell command file: fork a shell script
;
doShell inc biflag ;don't free argv...
doShell inc biflag ;don't free argv...
jsr prefork
* int fork2(void *subr, int stack, int prio, char *name, word argc, ...)
pea 0
pea 0
ldy #2
lda [argv],y
pha
@ -453,12 +454,12 @@ doShell inc biflag ;don't free argv...
pea 0
pea 1024
ph4 #exec0
case on
case on
jsl fork2
case off
* fork #exec0
jsr postfork
jsr postfork
jmp free
exec0 ph2 _argc ;for argfree
@ -470,11 +471,11 @@ exec0 ph2 _argc ;for argfree
jsl infork
bcs exec0c
signal (#SIGCHLD,#0)
PushVariablesGS NullPB
PushVariablesGS NullPB
pea 1
jsl ShellExec
jsl ShellExec
jsl argfree
PopVariablesGS NullPB
PopVariablesGS NullPB
rtl
exec0c pla
@ -497,7 +498,7 @@ NullPB dc i2'0' pCount
* File name was found in the built-in table
trybuiltin inc biflag It's a built-in. Which type?
cmp #1 Either fork or don't fork.
cmp #1 Either fork or don't fork.
beq noforkbuiltin
;
@ -505,7 +506,7 @@ trybuiltin inc biflag It's a built-in. Which type?
;
jsr prefork
fork #forkbuiltin
jsr postfork
jsr postfork
jmp done
;
; Control transfers here for a forked built-in command
@ -516,7 +517,7 @@ forkbuiltin cop $7F Give palloc a chance
ph4 _argv
jsl infork
bcs fork0c
jsl builtin
jsl builtin
rtl
; Error reported by infork; clean up stack and return to caller
@ -619,11 +620,11 @@ prefork lock mutex
postfork sta rtnval
lda pipein
beq postfork2
sta CloseRef
sta CloseRef
Close CloseParm
postfork2 lda pipeout
beq postfork3
sta CloseRef
sta CloseRef
Close CloseParm
postfork3 lda rtnval
cmp #-1
@ -646,10 +647,10 @@ postfork4 ldx jobflag
jsl palloc
bra postfork5
postfork4a jsl pallocpipe
postfork5 lda >mutex ;DANGER!!!!! Assumes knowledge of
beq postfork6 ;lock/unlock structure!!!!!!!!
postfork5 lda >mutex ;DANGER!!!!! Assumes knowledge of
beq postfork6 ;lock/unlock structure!!!!!!!!
cop $7F
bra postfork5
bra postfork5
postfork6 rts
;
@ -668,9 +669,9 @@ infork phk
bne invoke0a
tcnewpgrp ttyref
invoke0a settpgrp ttyref
lda _bg ;if in background then reset tty to
lda _bg ;if in background then reset tty to
and #$FF
beq invoke0b ;to the shell process group
beq invoke0b ;to the shell process group
tctpgrp (gshtty,gshpid)
invoke0b ph4 _sfile
@ -691,7 +692,7 @@ invoke0b ph4 _sfile
bne invoke0c
lda _pipeout
beq invoke0d
screate #0
screate #0
putsem sta >$FFFFFF
swait @a
bra invoke0d
@ -712,7 +713,7 @@ invoke0d anop
doneinfork unlock mutex
sec
indone rtl
mutex key
mutex2 key
cdmutex key
@ -734,25 +735,24 @@ _bg dc i2'0'
_jobflag dc i2'0'
_semaphore dc i2'0'
str dc c'[0]',h'0d00'
str dc c'[0]',h'0d00'
err1 dc c': Not executable.',h'0d00'
err2 dc c': Command not found.',h'0d00'
hehstr dc c'heh heh, next time you''ll need to specify a command '
dc c'before redirecting.',h'0d00'
spcmdstr dc c'Specify a command before redirecting.',h'0d00'
deadstr dc c'Cannot fork (too many processes?)',h'0d00' ;try a spoon
; Parameter block for GS/OC call GetFileInfo
GRec dc i'4' pCount (# of parameters)
GRecPath ds 4 pathname (input; ptr to GS/OS string)
ds 2 access (access attributes)
GRecFileType ds 2 fileType (file type attribute)
GRecAuxType ds 4 auxType (auxiliary type attribute)
GRec dc i'4' pCount (# of parameters)
GRecPath ds 4 pathname (input; ptr to GS/OS string)
ds 2 access (access attributes)
GRecFileType ds 2 fileType (file type attribute)
GRecAuxType ds 4 auxType (auxiliary type attribute)
PRec dc i'2'
PRecNum dc i'0'
PRecPath ds 4
PRec dc i'2'
PRecNum dc i'0'
PRecPath ds 4
CloseParm dc i2'1'
CloseRef dc i2'0'

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: jobs.asm,v 1.5 1998/08/03 17:30:22 tribby Exp $
* $Id: jobs.asm,v 1.6 1998/09/08 16:53:10 tribby Exp $
*
**************************************************************************
*
@ -55,21 +55,21 @@ p_space gequ p_command+4 ;space for structure
; p_flags values
;
PRUNNING gequ %0000000000000001 ;running
PSTOPPED gequ %0000000000000010 ;stopped
PNEXITED gequ %0000000000000100 ;normally exited
PSTOPPED gequ %0000000000000010 ;stopped
PNEXITED gequ %0000000000000100 ;normally exited
PAEXITED gequ %0000000000001000 ;abnormally exited
PSIGNALED gequ %0000000000010000 ;terminated by signal != SIGINT
PNOTIFY gequ %0000000000100000 ;notify async when done
PTIME gequ %0000000001000000 ;job times should be printed
PAWAITED gequ %0000000010000000 ;top level is waiting for it
PFOREGND gequ %0000000100000000 ;started in shells pgrp
PDUMPED gequ %0000001000000000 ;process dumped core
PDIAG gequ %0000010000000000 ;diagnostic output also piped out
PPOU gequ %0000100000000000 ;piped output
PREPORTED gequ %0001000000000000 ;status has been reported
PINTERRUPTED gequ %0010000000000000 ;job stopped via interrupt signal
PPTIME gequ %0100000000000000 ;time individual process
PNEEDNOTE gequ %1000000000000000 ;notify as soon as practicle
PAWAITED gequ %0000000010000000 ;top level is waiting for it
PFOREGND gequ %0000000100000000 ;started in shells pgrp
PDUMPED gequ %0000001000000000 ;process dumped core
PDIAG gequ %0000010000000000 ;diagnostic output also piped out
PPOU gequ %0000100000000000 ;piped output
PREPORTED gequ %0001000000000000 ;status has been reported
PINTERRUPTED gequ %0010000000000000 ;job stopped via interrupt signal
PPTIME gequ %0100000000000000 ;time individual process
PNEEDNOTE gequ %1000000000000000 ;notify as soon as practicle
;====================================================================
;
@ -128,7 +128,7 @@ loop sta p
sigsetmask oldsig
sigpause #0
bra waitloop
bra waitloop
loop2 ldy #p_next+2
lda [p],y
tax
@ -185,7 +185,7 @@ done return
;====================================================================
palloc START
using pdata
using global
@ -319,7 +319,7 @@ noprint anop
;====================================================================
pallocpipe START
using pdata
using global
@ -394,7 +394,7 @@ bg01 ldy #p_flags
jsr copycstr
;
; update the current pipeline to know about the last pipe.
;
;
lda pjoblist
ldx pjoblist+2
loop sta p
@ -474,7 +474,7 @@ end equ code+2
plb
stz signum
;
;
; get status for the process that just died
;
ldx #0
@ -545,11 +545,11 @@ stop2 pei (p+2)
pea 0
pei (signum)
jsl pprint
bra done
bra done
kill ldy #p_flags
lda [p],y
bit #PFOREGND ;only set status variable if in
beq zap0 ; foreground
beq zap0 ; foreground
lda waitstatus
jsr setstatus
bra zap
@ -563,7 +563,7 @@ zap ldy #p_index
bit #PFOREGND
beq done
tctpgrp (gshtty,gshpid)
done anop
plb
lda space
@ -578,7 +578,7 @@ done anop
rtl
;
;
; Set $status return variable
;
setstatus ENTRY
@ -586,29 +586,29 @@ setstatus ENTRY
xba Isolate status
and #$FF byte.
cmp #10
bcs digits2or3 If < 10,
adc #'0' Convert to single digit
sta valstat_text and store in value string.
ldx #1 Set length of string to 1.
cmp #10
bcs digits2or3 If < 10,
adc #'0' Convert to single digit
sta valstat_text and store in value string.
ldx #1 Set length of string to 1.
stx valstat
bra set_value
bra set_value
digits2or3 cmp #100 If parameter number
bcs digits3 >= 10 && < 99,
ldx #2 length = 2
bra setit otherwise
digits2or3 cmp #100 If parameter number
bcs digits3 >= 10 && < 99,
ldx #2 length = 2
bra setit otherwise
digits3 ldx #3 length = 3
;
; Store length (2 or 3) and convert number to text
;
setit stx valstat
setit stx valstat
Int2Dec (@a,#valstat_text,valstat,#0)
set_value anop
SetGS SetPB
rts
rts
;
; Parameter block for shell SetGS calls (p 427 in ORCA/M manual)
@ -627,7 +627,7 @@ status gsstr 'status' Name of environment variable
valstat ds 2 Length word
valstat_text dc c'000' Text (up to three digits)
END
END
;====================================================================
;
@ -705,12 +705,12 @@ gotit3 anop
bne gotit3c
jsr newline
ldy #p_flags
lda #0
lda #0
sta [p],y
pei (p+2)
pei (p)
pea 0
pea 0
pea 0
jsl pprint
gotit3c anop
@ -754,7 +754,7 @@ gotit4 ldy #p_friends
pei (p+2)
pei (p)
jsl nullfree
pla
pla
sta P+2
pla
sta p
@ -782,7 +782,7 @@ fmaxloop sta p
ora p+2
beq gotmax
ldy #p_index
lda [p],y
lda [p],y
cmp prev
bcc skipmax
sta prev
@ -846,7 +846,7 @@ done lda space,s
tcs
rts
END
**************************************************************************
@ -1075,7 +1075,7 @@ killnull ldx #^err4
bra done
dokill kill (pid,signum)
cmp #0
cmp #0
beq done
ldx #^err2
lda #err2
@ -1093,7 +1093,7 @@ done lda space
lda #0
rtl
rtl
Usage dc c'Usage: kill [-signum | -signame] [pid | %jobid] ...',h'0d00'
err1 dc c'kill: Invalid signal number.',h'0d00'
@ -1107,37 +1107,37 @@ liststr dc c'sighup sigint sigquit sigill sigtrap sigabrt sigemt '
dc c'sigttou sigio sigxcpu sigusr1 sigusr2',h'0d00'
names dc c'sighup',h'0000' ;1
dc c'sigint',h'0000' ;2
dc c'sigquit',h'00' ;3
dc c'sigill',h'0000' ;4
dc c'sigtrap',h'00' ;5
dc c'sigabrt',h'00' ;6
dc c'sigemt',h'0000' ;7
dc c'sigfpe',h'0000' ;8
dc c'sigkill',h'00' ;9
dc c'sigbus',h'0000' ;10
dc c'sigsegv',h'00' ;11
dc c'sigsys',h'0000' ;12
dc c'sigpipe',h'00' ;13
dc c'sigalrm',h'00' ;14
dc c'sigterm',h'00' ;15
dc c'sigurg',h'0000' ;16
dc c'sigstop',h'00' ;17
dc c'sigtstp',h'00' ;18
dc c'sigcont',h'00' ;19
dc c'sigchld',h'00' ;20
dc c'sigttin',h'00' ;21
dc c'sigttou',h'00' ;22
dc c'sigint',h'0000' ;2
dc c'sigquit',h'00' ;3
dc c'sigill',h'0000' ;4
dc c'sigtrap',h'00' ;5
dc c'sigabrt',h'00' ;6
dc c'sigemt',h'0000' ;7
dc c'sigfpe',h'0000' ;8
dc c'sigkill',h'00' ;9
dc c'sigbus',h'0000' ;10
dc c'sigsegv',h'00' ;11
dc c'sigsys',h'0000' ;12
dc c'sigpipe',h'00' ;13
dc c'sigalrm',h'00' ;14
dc c'sigterm',h'00' ;15
dc c'sigurg',h'0000' ;16
dc c'sigstop',h'00' ;17
dc c'sigtstp',h'00' ;18
dc c'sigcont',h'00' ;19
dc c'sigchld',h'00' ;20
dc c'sigttin',h'00' ;21
dc c'sigttou',h'00' ;22
dc c'sigio',h'000000' ;23
dc c'sigxcpu',h'00' ;24
dc c'sigxcpu',h'00' ;24
dc h'0000000000000000' ;25
dc h'0000000000000000' ;26
dc h'0000000000000000' ;27
dc h'0000000000000000' ;28
dc h'0000000000000000' ;29
dc c'sigusr1',h'00' ;30
dc c'sigusr2',h'00' ;31
dc c'sigusr1',h'00' ;30
dc c'sigusr2',h'00' ;31
END
**************************************************************************
@ -1148,7 +1148,7 @@ names dc c'sighup',h'0000' ;1
fg START
using pdata
using pdata
using global
pid equ 0
@ -1262,7 +1262,7 @@ err03 dc c'fg: No such job.',h'0d00'
bg START
using pdata
using pdata
using global
pid equ 0
@ -1327,7 +1327,7 @@ dofg1 anop
beq dobg0
; lda [p],y
eor #PFOREGND
sta [p],y
sta [p],y
dobg0 anop
; lda [p],y
bit #PSTOPPED
@ -1379,7 +1379,7 @@ err03 dc c'bg: No such job.',h'0d00'
stop START
using pdata
using pdata
using global
pid equ 0
@ -1549,11 +1549,11 @@ stat0 jsr puts
lda signum
beq sig0
if2 @a,ne,#SIGTTIN,sig2
ldx #^sigttinstr
ldx #^sigttinstr
lda #sigttinstr
bra sig1
sig2 if2 @a,ne,#SIGTTOU,sig3
ldx #^sigttoustr
ldx #^sigttoustr
lda #sigttoustr
bra sig1
sig3 ldx #^sigotherstr

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: main.asm,v 1.6 1998/08/03 17:30:22 tribby Exp $
* $Id: main.asm,v 1.7 1998/09/08 16:53:11 tribby Exp $
*
**************************************************************************
*
@ -29,8 +29,8 @@
; Segment for direct-page and stack
stack data STACK ; ends up in main.root
kind $12
stack data STACK ; ends up in main.root
kind $12
; Define direct-page/stack and fill it with question marks it can be
; examined for how much is used.
@ -60,7 +60,7 @@ init START
MAIN START
using global
p equ 0
@ -85,7 +85,7 @@ argloop dec argc Decrement argument count.
beq go_start If none left, ready to start working.
clc
lda argv Point to next
adc #4 argument pointer.
adc #4 argument pointer.
sta argv
ldy #2
lda [argv] Set arg to point to
@ -116,7 +116,7 @@ cmd0 lda [arg],y
sta [p],y
iny
bra cmd0
cmd1 lda #' '
cmd1 lda #' '
sta [p],y
sec ;inc a
tya
@ -126,7 +126,7 @@ cmd1 lda #' '
beq cmd2
clc
lda argv
adc #4
adc #4
sta argv
ldy #2
lda [argv]
@ -166,7 +166,7 @@ nextarg cpy #1
jmp argloop
; Option = "-c": execute shell commands found in file named by next argument
parsec clc
parsec clc
lda argv
adc #4
sta argv

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: mmdebug.asm,v 1.3 1998/08/03 17:30:23 tribby Exp $
* $Id: mmdebug.asm,v 1.5 1998/12/21 23:57:07 tribby Exp $
*
**************************************************************************
*
@ -65,7 +65,7 @@ newh anop
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
@ -130,13 +130,13 @@ ckptr lda [hand] Dereference the
sta checkptr found handle.
ldy #2
lda [hand],y
sta checkptr+2
sta checkptr+2
cmp ptr+2 If the pointer isn't
bne errD3 the first byte
lda checkptr of the handle,
cmp ptr there is a problem.
beq chkid
beq chkid
errD3 brk $D3
bra goback

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: orca.asm,v 1.5 1998/08/03 17:30:22 tribby Exp $
* $Id: orca.asm,v 1.6 1998/09/08 16:53:12 tribby Exp $
*
**************************************************************************
*
@ -58,38 +58,38 @@ space equ outPath+4
lda argc Make sure there are two or
cmp #2 more parameters.
bcs enoughparms Otherwise,
ldx #^enofile report error:
ldx #^enofile report error:
lda #enofile no filename specified
jsr errputs
lda #1
lda #1
bra seterr
; Allocate memory for sFile, inPath, and outPath
enoughparms anop
jsl alloc1024
jsl alloc1024
sta sFile
stx sFile+2
ora sFile+2
beq memerr1
beq memerr1
jsl alloc1024
jsl alloc1024
sta inPath
stx inPath+2
ora inPath+2
beq memerr1
beq memerr1
jsl alloc1024
jsl alloc1024
sta outPath
stx outPath+2
ora outPath+2
bne noerr1
bne noerr1
memerr1 ldx #^enomem Report error:
memerr1 ldx #^enomem Report error:
lda #enomem out of memory
jsr errputs
lda #-1
lda #-1
seterr sta retval
jmp goaway
@ -97,9 +97,9 @@ seterr sta retval
; Ready to start processing the filename(s).
noerr1 anop
stz retval Zero return status
stz sLen and length of source names.
stz sLen and length of source names.
lda #1 Initialize parameter
lda #1 Initialize parameter
sta pnum number to 1.
lda sFile strPtr = sFile + 2
@ -115,7 +115,7 @@ noerr1 anop
; Loop for getting name, converting it to a full path, and
; appending it to sFile
doloop short m Between parameters:
doloop short m Between parameters:
lda #10 Store newline as delimiter
sta [strPtr] character in strPtr.
long m
@ -123,20 +123,20 @@ doloop short m Between parameters:
incad strPtr and pointer.
nodelimit anop
lda pnum Get parameter number
lda pnum Get parameter number
asl a and turn it into an
asl a index to the proper
tay argv pointer.
lda [argv],y Store address in
sta argLoopPtr direct page variable
sta argLoopPtr direct page variable
iny2 argLoopPtr.
lda [argv],y
sta argLoopPtr+2
lda inPath Get address of text field
lda inPath Get address of text field
clc in inPath.
adc #2
sta inLoopPtr
sta inLoopPtr
lda inPath+2
adc #0
sta inLoopPtr+2
@ -147,22 +147,22 @@ nodelimit anop
whileloop lda [argLoopPtr],y Get next character of name.
and #$00FF If it's the terminating null,
beq donewhile done copying.
beq donewhile done copying.
sta [inLoopPtr],y Store character (and null byte)
iny
cpy #255 If < 255,
bcc whileloop stay in loop.
cpy #255 If < 255,
bcc whileloop stay in loop.
ldx #^einval Print error:
ldx #^einval Print error:
lda #einval invalid argument (filename too long)
jsr errputs
lda #2
lda #2
bra seterr
donewhile tya Set length of GS/OS string inPath.
donewhile tya Set length of GS/OS string inPath.
sta [inPath]
lda #1024 Set max len of result buffer outPath.
lda #1024 Set max len of result buffer outPath.
sta [outPath]
; Set up GS/OS ExpandPath parameter buffer and make call.
@ -180,14 +180,14 @@ donewhile tya Set length of GS/OS string inPath.
sta pathLen and store in pathLen.
clc
adc sLen If accumulated length is
cmp #MAXPARMBUF beyond the maximum,
bcs doloopend don't add this name.
cmp #MAXPARMBUF beyond the maximum,
bcs doloopend don't add this name.
sta sLen Store accumulated length in sLen.
pei (pathLen) Append outPath string
pei (outPath+2) to the end of sFile's text.
lda outPath
pei (outPath+2) to the end of sFile's text.
lda outPath
clc
adc #4
pha
@ -195,7 +195,7 @@ donewhile tya Set length of GS/OS string inPath.
pei (strPtr)
jsl rmemcpy
lda strPtr Add pathLen to strPtr.
lda strPtr Add pathLen to strPtr.
clc
adc pathLen
sta strPtr
@ -203,28 +203,28 @@ donewhile tya Set length of GS/OS string inPath.
adc #0
sta strPtr+2
doloopend inc pnum pnum++
lda pnum if pnum < argc,
cmp argc
doloopend inc pnum pnum++
lda pnum if pnum < argc,
cmp argc
jcc doloop continue processing filenames.
; All of the arguments have been processed.
lda sLen Save length in
sta [sFile] GS/OS buffer.
sta [sFile] GS/OS buffer.
; Set up shell SetLInfo parameter buffer and make call.
mv4 sFile,gl_sFile
mv4 sFile,gl_sFile
SetLInfoGS gl Set the edit environment.
ph4 #editorvar Get value of environment
jsl getenv variable "editor".
sta editcommand
stx editcommand+2
ora editcommand+2
ora editcommand+2
bne goteditvar If $editor is not defined,
ph4 #defedit use default value.
ph4 #defedit use default value.
bra execit
goteditvar anop Add 4 to value returned by getenv
@ -239,7 +239,7 @@ nobump anop
pha
execit ph2 #0 Tells execute we're called by system
jsl execute
sta retval
sta retval
lda editcommand If getenv allocated it,
ora editcommand+2
@ -247,28 +247,28 @@ execit ph2 #0 Tells execute we're called by system
pei (editcommand+2) free the "editcommand" string.
pei (editcommand)
jsl nullfree
jsl nullfree
; See which GS/OS buffers need to be deallocated
goaway lda sFile
goaway lda sFile
ora sFile+2
beq donedealloc
ldx sFile+2
lda sFile
jsl free1024
jsl free1024
lda inPath
ora inPath+2
beq donedealloc
lda inPath
ora inPath+2
beq donedealloc
ldx inPath+2
lda inPath
jsl free1024
lda outPath
ora outPath+2
beq donedealloc
lda outPath
ora outPath+2
beq donedealloc
ldx outPath+2
lda outPath
jsl free1024
@ -276,7 +276,7 @@ goaway lda sFile
; Return to caller with status set to value in retval
donedealloc return 2:retval
donedealloc return 2:retval
; Parameter block for GS/OS ExpandPath call (p. 140 in GS/OS Reference)

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: prompt.asm,v 1.5 1998/08/03 17:30:23 tribby Exp $
* $Id: prompt.asm,v 1.6 1998/09/08 16:53:12 tribby Exp $
*
**************************************************************************
*
@ -28,7 +28,7 @@ dummyprompt start ; ends up in .root
setcom 60
WritePrompt START
WritePrompt START
using HistoryData
@ -46,7 +46,7 @@ year equ hour
monday equ minute
precmd equ prompt
subroutine (0:dummy),space
subroutine (0:dummy),space
ph4 #precmdstr If "precmd" alias is defined,
jsl findalias
@ -66,8 +66,8 @@ precmd equ prompt
getvar ph4 #promptname
jsl getenv
php Turn off interrupts: mutex
sei won't do what we want!
php Turn off interrupts: mutex
sei won't do what we want!
sta promptgsbuf Save pointer to GS/OS result buffer.
stx promptgsbuf+2 If there is no memory to hold it,
@ -76,12 +76,12 @@ getvar ph4 #promptname
ldx #^dfltPrompt
lda #dfltPrompt
jsr puts print the default prompt
bra donemark2 and exit.
bra donemark2 and exit.
;
; Prompt string begins in result buffer after the two length words
;
parseprompt anop
parseprompt anop
clc
lda promptgsbuf
adc #4
@ -90,20 +90,20 @@ parseprompt anop
adc #0
sta prompt+2
promptloop lda [prompt]
promptloop lda [prompt]
incad prompt
and #$FF
beq done
cmp #'%'
beq special
cmp #'!'
jeq phist
and #$FF
beq done
cmp #'%'
beq special
cmp #'!'
jeq phist
cmp #'\'
jeq quoteit
_putchar jsr putchar
bra promptloop
_putchar jsr putchar
bra promptloop
done jsr standend
done jsr standend
jsr cursoron
donemark2 anop
@ -118,115 +118,115 @@ donemark2 anop
;
; Previous character was a "%". Handle special character flags
;
special lda [prompt] Get character following "%".
special lda [prompt] Get character following "%".
incad prompt
and #$FF
beq done If end of string, all done.
cmp #'%' If another "%",
beq _putchar print the "%"
cmp #'h' If 'h'
beq phist
cmp #'!' or '!',
beq phist print history number.
cmp #'t' If 't'
beq ptime
cmp #'@' or '@',
beq ptime print time (am/pm format)
cmp #'S' If 'S',
jeq pstandout turn inverse mode on.
cmp #'s' If 's',
jeq pstandend turn inverse mode off.
cmp #'U' If 'U',
jeq punderline turn underline mode on.
cmp #'u' If 'u',
jeq punderend turn underline mode off
cmp #'d' If 'd'
jeq pcwd
cmp #'/' or '/',
jeq pcwd print working directory.
cmp #'c' If 'c'
jeq pcwdend
cmp #'C' or 'C'
jeq pcwdend
cmp #'.' or '.',
jeq pcwdend print final part of wrk dir.
cmp #'n' If 'n',
jeq puser print $USER
cmp #'W' If 'W',
jeq pdate1 print date (mm/dd/yy)
cmp #'D' If 'D',
jeq pdate2 print date (yy-mm-dd)
and #$FF
beq done If end of string, all done.
cmp #'%' If another "%",
beq _putchar print the "%"
cmp #'h' If 'h'
beq phist
cmp #'!' or '!',
beq phist print history number.
cmp #'t' If 't'
beq ptime
cmp #'@' or '@',
beq ptime print time (am/pm format)
cmp #'S' If 'S',
jeq pstandout turn inverse mode on.
cmp #'s' If 's',
jeq pstandend turn inverse mode off.
cmp #'U' If 'U',
jeq punderline turn underline mode on.
cmp #'u' If 'u',
jeq punderend turn underline mode off
cmp #'d' If 'd'
jeq pcwd
cmp #'/' or '/',
jeq pcwd print working directory.
cmp #'c' If 'c'
jeq pcwdend
cmp #'C' or 'C'
jeq pcwdend
cmp #'.' or '.',
jeq pcwdend print final part of wrk dir.
cmp #'n' If 'n',
jeq puser print $USER
cmp #'W' If 'W',
jeq pdate1 print date (mm/dd/yy)
cmp #'D' If 'D',
jeq pdate2 print date (yy-mm-dd)
cmp #'~' If '~',
jeq ptilde print wrk dir with ~ subs.
jmp promptloop If none of these characters, ignore it.
jmp promptloop If none of these characters, ignore it.
;
; Put history number
;
phist lda lasthist
inc a
jsr WriteNum
jmp promptloop
phist lda lasthist
inc a
jsr WriteNum
jmp promptloop
;
; Print current time
;
ptime ReadTimeHex (minute,hour,@a,@a)
lda hour
and #$FF
if2 @a,cc,#13,ptime2
sub2 @a,#12,@a
ptime2 if2 @a,ne,#0,ptime2b
ptime ReadTimeHex (minute,hour,@a,@a)
lda hour
and #$FF
if2 @a,cc,#13,ptime2
sub2 @a,#12,@a
ptime2 if2 @a,ne,#0,ptime2b
lda #12
ptime2b jsr WriteNum
ptime2b jsr WriteNum
lda #':'
jsr putchar
lda minute
xba
and #$FF
pha
cmp #10
bcs ptime2a
lda minute
xba
and #$FF
pha
cmp #10
bcs ptime2a
lda #'0'
jsr putchar
ptime2a pla
jsr WriteNum
lda hour
and #$FF
if2 @a,cs,#12,ptime3
ptime5 lda #'a'
bra ptime4
ptime3 lda #'p'
ptime4 jsr putchar
ptime2a pla
jsr WriteNum
lda hour
and #$FF
if2 @a,cs,#12,ptime3
ptime5 lda #'a'
bra ptime4
ptime3 lda #'p'
ptime4 jsr putchar
lda #'m'
jmp _putchar
;
; Set Stand Out (turn on inverse mode)
;
pstandout jsr standout
pstandout jsr standout
jmp promptloop
;
; UnSet Stand Out (turn off inverse mode)
;
pstandend jsr standend
pstandend jsr standend
jmp promptloop
;
; Set Underline
;
punderline jsr underline
punderline jsr underline
jmp promptloop
;
; UnSet Underline
;
punderend jsr underend
punderend jsr underend
jmp promptloop
;
;
; Current working directory
;
pcwd anop
pea 0
jsl getpfxstr Get value of prefix 0.
jsl getpfxstr Get value of prefix 0.
sta pfx
stx pfx+2
@ -234,8 +234,8 @@ pcwd anop
jeq promptloop an error was reported.
ldy #4 Text starts at byte 4.
pcwd1 lda [pfx],y Get next
and #$FF character.
pcwd1 lda [pfx],y Get next
and #$FF character.
beq freepfx Done when at end of string.
jsr toslash Convert to slash.
phy Hold index on stack
@ -246,50 +246,50 @@ pcwd1 lda [pfx],y Get next
freepfx ph4 pfx Free the current directory buffer.
jsl nullfree
jmp promptloop
jmp promptloop
;
; Tail of current working directory
;
pcwdend anop
pcwdend anop
pea 0
jsl getpfxstr Get value of prefix 0.
jsl getpfxstr Get value of prefix 0.
sta pfx
stx pfx+2
ora pfx+2 If NULL pointer returned,
jeq promptloop an error was reported.
ldy #2 Get string's length word
ldy #2 Get string's length word
lda [pfx],y from bytes 2 & 3.
clc Add 3 to get offset
clc Add 3 to get offset
adc #3 from beginning of buffer.
sta offset
tay
pcwdend1 dey If we've backed up to the beginning,
bmi pcwdend2 we can't go any further!
lda [pfx],y Get next character.
and #$FF
cmp #':' If it's not ':',
bne pcwdend1 keep searching backward.
pcwdend2 iny
cpy offset
jeq freepfx Free the current directory buffer.
lda [pfx],y
and #$FF
cmp #':'
jeq freepfx Free the current directory buffer.
phy
pcwdend1 dey If we've backed up to the beginning,
bmi pcwdend2 we can't go any further!
lda [pfx],y Get next character.
and #$FF
cmp #':' If it's not ':',
bne pcwdend1 keep searching backward.
pcwdend2 iny
cpy offset
jeq freepfx Free the current directory buffer.
lda [pfx],y
and #$FF
cmp #':'
jeq freepfx Free the current directory buffer.
phy
jsr putchar
ply
bra pcwdend2
ply
bra pcwdend2
;
; Current working directory substituting '~' if necessary
;
ptilde anop
ptilde anop
pea 0
jsl getpfxstr Get value of prefix 0.
jsl getpfxstr Get value of prefix 0.
sta pfx
stx pfx+2
@ -297,7 +297,7 @@ ptilde anop
jeq promptloop an error was reported.
lda pfx Otherwise, restore low-order address.
clc Add 4 to start of buffer
clc Add 4 to start of buffer
adc #4 so it can be treated like
bcc pushad a c-string.
inx
@ -311,10 +311,10 @@ pushad phx
jmp freepfx Free the current directory buffer.
;
;
; Write user name
;
puser ph4 #username Get value of $USER
puser ph4 #username Get value of $USER
jsl getenv
sta usergsbuf If buffer wasn't allocated
stx usergsbuf+2
@ -324,7 +324,7 @@ puser ph4 #username Get value of $USER
clc
lda usergsbuf Text begins after
adc #4 four bytes of
bcc printit length words.
bcc printit length words.
inx
printit jsr puts
@ -337,56 +337,56 @@ goploop jmp promptloop
;
; Write date as mm/dd/yy
;
pdate1 ReadTimeHex (@a,year,monday,@a)
lda monday
and #$FF00
xba
inc a
jsr WriteNum
pdate1 ReadTimeHex (@a,year,monday,@a)
lda monday
and #$FF00
xba
inc a
jsr WriteNum
lda #'/'
jsr putchar
lda monday
and #$FF
inc a
jsr WriteNum
lda monday
and #$FF
inc a
jsr WriteNum
lda #'/'
jsr putchar
lda year
and #$FF00
xba
jsr WriteNum
jmp promptloop
lda year
and #$FF00
xba
jsr WriteNum
jmp promptloop
;
; Write date as yy-mm-dd
;
pdate2 ReadTimeHex (@a,year,monday,@a)
lda year
and #$FF00
xba
jsr WriteNum
pdate2 ReadTimeHex (@a,year,monday,@a)
lda year
and #$FF00
xba
jsr WriteNum
lda #'-'
jsr putchar
lda monday
and #$FF00
xba
inc a
jsr WriteNum
lda monday
and #$FF00
xba
inc a
jsr WriteNum
lda #'-'
jsr putchar
lda monday
and #$FF
inc a
jsr WriteNum
jmp promptloop
lda monday
and #$FF
inc a
jsr WriteNum
jmp promptloop
;
; check for \ quote
;
quoteit lda [prompt]
quoteit lda [prompt]
incad prompt
and #$FF
jeq done
and #$FF
jeq done
cmp #'n'
beq newline
cmp #'r'
@ -402,29 +402,29 @@ tab lda #9
jmp _putchar
backspace lda #8
jmp _putchar
;
;
; Write a number between 0 and 9,999
;
WriteNum cmp #10
bcs write1
adc #'0'
WriteNum cmp #10
bcs write1
adc #'0'
jmp putchar
write1 cmp #100
bcs write2
Int2Dec (@a,#num+2,#2,#0)
write1 cmp #100
bcs write2
Int2Dec (@a,#num+2,#2,#0)
ldx #^num+2
lda #num+2
jmp puts
write2 cmp #1000
bcs write3
Int2Dec (@a,#num+1,#3,#0)
write2 cmp #1000
bcs write3
Int2Dec (@a,#num+1,#3,#0)
ldx #^num+1
lda #num+1
jmp puts
write3 Int2Dec (@a,#num,#4,#0)
write3 Int2Dec (@a,#num,#4,#0)
ldx #^num
lda #num
jmp puts
@ -434,12 +434,12 @@ write3 Int2Dec (@a,#num,#4,#0)
precmdstr dc c'precmd',h'00'
; Names of environment variables
promptname gsstr 'prompt'
promptname gsstr 'prompt'
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
* Tim Meekins
*
* $Id: shell.asm,v 1.5 1998/08/03 17:30:23 tribby Exp $
* $Id: shell.asm,v 1.6 1998/09/08 16:53:13 tribby Exp $
*
**************************************************************************
*
@ -25,11 +25,11 @@
*
* shell subroutine (0:dummy)
* NOTE: gnoloop is an entry defined in shell.
*
*
* AppendHome subroutine (4:str)
* return 4:outPtr
*
* DoLogin jsr with no parameters
* Dogshrc jsr with no parameters
*
* signal2 subroutine (4:fubar)
*
@ -48,33 +48,35 @@ SIGINT gequ 2
SIGTSTP gequ 18
SIGCHLD gequ 20
cmdbuflen gequ 1024
cmdbuflen gequ 1024
**************************************************************************
*
* shell: entry point for acting upon commands
*
**************************************************************************
case on
shell start
case off
case on
shell start
case off
using global
using global
using pdata
using HistoryData
using termdata
p equ 0
space equ p+4
using termdata
using hashdata
p equ 0 General pointer
cflag equ p+4 Flag: set when path converted
space equ cflag+2
subroutine (0:dummy),space
tsc Save stack pointer
sta cmdcontext in cmdcontext
tdc and direct page reg
sta cmddp ind cmddp.
sta cmddp in cmddp.
* PushVariables 0
PushVariablesGS NullPB Save environment variables.
Open ttyopen Open tty,
bcc settty checking for error.
@ -94,8 +96,8 @@ settty mv2 ttyref,gshtty
lda FastFlag If FastFlag is set,
bne fastskip1 skip copyright message.
lda gshpid ; only print the copyright msg
cmp #2 ; if not using login
lda gshpid Only print the copyright msg
cmp #2 if not using login
bne fastskip1
ldx #^gnostr
lda #gnostr
@ -119,17 +121,94 @@ fastskip1 anop
jsr initalias Set all AliasTable entries to 0.
jsr InitDStack Zero out directory stack.
jsr InitVars Set value of all env var flags.
;
; Check for login shell (argv[0] starts with '-')
;
mv4 ~COMMANDLINE,p Copy commandline addr to dir page.
ldy #8 Skip over shell identifier
lda [p],y to get first char of
and #$FF command name.
cmp #'-' If not '-',
bne nologin_init skip over login initialization.
; Change ":" to " " in $PATH if it doesn't start with ":" or contain a " "
ph4 #pathname Get $PATH environment variable string
jsl getenv
sta p Save address of allocated buffer.
stx p+2 in direct page variable
ora p+2 If null,
beq nopathconv no need to convert
stz cflag Initialize conversion flag = false.
ldy #4 Index over GS/OS length fields.
short m Use 8-bit mode.
lda [p],y
beq endpathconv If null string, or
cmp #':' if first character is ':',
beq endpathconv don't do the conversion.
bumpit iny
lda [p],y
beq endpathconv If at end of string, all done.
cmp #' ' If $PATH contains a space,
bne chkcolon
stz cflag abort the conversion.
bra endpathconv
chkcolon cmp #':' If next character is ':',
bne bumpit
lda #' ' change it to ' ', and
sta [p],y
sta cflag set conversion flag = true.
bra bumpit
endpathconv long m Back to 16-bit mode.
lda cflag If there was no conversion,
beq freepath skip the setting of $PATH.
clc Address of $PATH as a GS/OS
lda p output string is 2 bytes
adc #2 beyond the input string
sta SetValue starting address.
lda p+2
adc #0
sta SetValue+2
SetGS SetPB Set $PATH to the converted value.
freepath ph4 p Free the $PATH C string.
jsl nullfree
nopathconv anop
; Read and execute /etc/glogin
ph4 #etcglogin path = "/etc/glogin"
lda #0
pha argc = 0
pha argv = NULL
pha
pha jobflag = 0
jsl ShellExec
; Read and execute $HOME/glogin
jsr Doglogin
;
; Initialization that is not specific to login shells
;
nologin_init anop
lda FastFlag If fast startup flag isn't set,
bne fastskip2
jsr InitHistory Init: historyFN->"$HOME/history",
jsr ReadHistory read in history from disk,
jsr DoLogin and read $HOME/gshrc.
jsr ReadHistory read in history from disk,
jsr Dogshrc and read $HOME/gshrc.
jsr newline
fastskip2 anop
fastskip2 anop
lda didReadTerm
bne didit
jsr readterm
didit jsl hashpath ;hash $path
didit anop
jsl hashpath Hash $PATH.
ld2 1,hash_print Set hash print flag.
;
; Check for command-line arguments -c and -e
@ -162,9 +241,22 @@ cmdskip lda ExecFlag
ph4 ExecCmd
ph2 #0
jsl Execute
jmp done1
jmp done1
execskip anop
;
; Parameter block for shell SetGS calls (p 427 in ORCA/M manual)
;
SetPB dc i2'3' pCount
dc i4'pathname' Name (pointer to GS/OS string)
SetValue ds 4 Value (pointer to GS/OS string)
dc i2'1' Export flag
pathname gsstr 'path' GS/OS string
etcglogin dc c'/etc/glogin',h'00'
execskip anop
****************************************************************
*
@ -174,47 +266,47 @@ execskip anop
stz lastabort
gnoloop entry
gnoloop entry
;
; Set the fundamental registers.
;
phk Copy Program Bank register
plb into Data Bank register.
lda cmdcontext Set Stack Pointer and
tcs Direct Page register
lda cmdcontext Set Stack Pointer and
tcs Direct Page register
lda cmddp to values saved when
tcd entering shell.
jsl WritePrompt Print prompt.
jsr GetCmdLine Get response.
bcs done
jsl WritePrompt Print prompt.
jsr GetCmdLine Get response.
bcs done
jsr newline
lda cmdlen Check for empty string.
beq gnoloop
lda cmdlen Check for empty string.
beq gnoloop
jsr cursoron
jsr newlineX
jsr flush
ph4 #cmdline
ph4 #cmdline
ph2 #0
jsl execute
jsl execute
lda exit_requested
bne done1
jsr newlineX
jsr newlineX
stz lastabort
bra gnoloop
bra gnoloop
;
; shut down gsh
;
done jsr newline
done jsr newline
jsr newlineX
done1 ora2 pjoblist,pjoblist+2,@a
done1 ora2 pjoblist,pjoblist+2,@a
beq done2
lda lastabort
lda lastabort
bne donekiller
inc lastabort
stz exit_requested
@ -227,22 +319,22 @@ done1 ora2 pjoblist,pjoblist+2,@a
donekiller jsl jobkiller
done2 lda FastFlag
bne fastskip5
jsl SaveHistory
fastskip5 jsr dispose_hash
jsl SaveHistory
fastskip5 jsr dispose_hash
quit PopVariablesGS NullPB
Quit QuitParm
Quit QuitParm
QuitParm dc i'0'
QuitParm dc i'0'
; Null parameter block used for shell calls PushVariables
; (ORCA/M manual p.420) and PopVariablesGS (p. 419)
NullPB dc i2'0' pCount
gnostr dc h'0d',c'GNO/Shell 2.0.6',h'0d'
dc c'Copyright 1991-1993, Procyon, Inc. & Tim Meekins. '
dc c'ALL RIGHTS RESERVED',h'0d'
dc h'0d00'
gnostr dc h'0d',c'GNO/Shell 2.0.6',h'0d'
dc c'Copyright 1991-1993, Procyon, Inc. & Tim Meekins. '
dc c'ALL RIGHTS RESERVED',h'0d'
dc h'0d00'
stopstr dc c'gsh: There are stopped jobs.',h'0d00'
ttyopen dc i2'2'
@ -254,21 +346,28 @@ exitstr dc c'000000',h'0d00'
lastabort ds 2
END
END
;=========================================================================
;
; Interpret the login file (gshrc).
; If $HOME is set, we presume the gshrc file is there. If not,
; If $HOME is set, we presume the gshrc file is there. If not,
; or if an error occurs getting the $HOME variable, we use
; @:gshrc.
;
;=========================================================================
DoLogin START
Dogshrc START
ph4 #gshrcName
jsl AppendHome
bra doit
; Alternate entry point: execute $HOME/glogin
Doglogin ENTRY
ph4 #gloginName
doit jsl AppendHome
phx Save pointer to GS/OS input
pha string for later.
@ -301,13 +400,14 @@ no_undf phx
rts
gshrcName dc c'/gshrc',h'00'
gloginName dc c'/glogin',h'00'
END
END
;=========================================================================
;
; Append a C string to the value of the $HOME variable. If $HOME is
; Append a C string to the value of the $HOME variable. If $HOME is
; not set, then it appends the C string to the string '@/'. Returns
; a pointer to a GS/OS input string.
;
@ -326,7 +426,7 @@ space equ buf_len+2
;
; Get the variable's length using ReadVariableGS
;
ld4 TempResultBuf,RVresult Use temporary result buf.
ld4 TempResultBuf,RVresult Use temporary result buf.
ReadVariableGS ReadVar Get length.
;
@ -362,12 +462,12 @@ notnull inc2 a Add 4 bytes for result buf len words.
; Read the full value into the allocated memory
;
ReadVariableGS ReadVar ReadVariable $HOME
bcs doAtSign If error, use @/
bcs doAtSign If error, use @/
ldy #2 Get length of
lda [outPtr],y GS/OS string.
beq doAtSign If $HOME not defined, use "@".
clc
clc
adc #4 Turn into a c-string
tay by storing a 0 byte
short m after the last $HOME
@ -380,22 +480,22 @@ notnull inc2 a Add 4 bytes for result buf len words.
; $HOME is null string or not defined. Use @
;
doAtSign lda atSign
ldy #4
ldy #4
sta [outPtr],y
lda #1 Set GS/OS buffer
ldy #2 string length word
ldy #2 string length word
sta [outPtr],y to 1.
doAppend anop
doAppend anop
ldy #4 Start index beyond length words.
short m
lp lda [outPtr],y
beq noSep
beq noSep
cmp #':'
beq foundSep
cmp #'/'
beq foundSep
iny
iny
bra lp
noSep lda #':' No separator found; use ":".
@ -424,7 +524,7 @@ pushptr phx
inc outPtr+2
no_ovf sta outPtr
lda [outPtr] Adjust string length
lda [outPtr] Adjust string length
clc to include appended
adc str_len string (parameter).
sta [outPtr]
@ -449,7 +549,7 @@ ReadVar anop
RVresult ds 4 GS/OS Output buffer ptr
ds 2 export flag (returned)
;
; GS/OS result buffer for getting the full length of the PATH env var.
; GS/OS result buffer for getting the full length of the HOME env var.
;
TempResultBuf dc i2'5' Only five bytes total.
TempRBlen ds 2 Value's length returned here.
@ -468,23 +568,23 @@ home gsstr 'HOME'
;
;=========================================================================
global DATA
global DATA
ID ds 2
GSOSDP ds 2
cmdloc ds 2
cmdlen ds 2
cmdline ds cmdbuflen
ID ds 2
GSOSDP ds 2
cmdloc ds 2
cmdlen ds 2
cmdline ds cmdbuflen
buffer ds 256
wordlen ds 2
wordbuf ds 256
nummatch ds 2
matchbuf ds 512*4
cmdcontext ds 2
cmdcontext ds 2
cmddp ds 2
gshtty ds 2
gshpid ds 2
exit_requested dc i'0' ;!=0 if exit
gshpid ds 2
exit_requested dc i'0' ;!=0 if exit
signalled dc i'0'
FastFlag dc i'0'
@ -494,7 +594,7 @@ CmdArgC ds 2
ExecFlag dc i'0'
ExecCmd ds 4
END
END
;=========================================================================
;

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: shellutil.asm,v 1.5 1998/08/03 17:30:24 tribby Exp $
* $Id: shellutil.asm,v 1.6 1998/09/08 16:53:13 tribby Exp $
*
**************************************************************************
*
@ -34,7 +34,7 @@ dummyshellutil start ; ends up in .root
;
;=========================================================================
tolower START
tolower START
cmp #'A'
bcc done
@ -43,7 +43,7 @@ tolower START
adc #'a'-'A'
done rts
END
END
;=========================================================================
;
@ -51,14 +51,14 @@ done rts
;
;=========================================================================
toslash START
toslash START
cmp #':'
bne done
lda #'/'
done rts
END
END
;=========================================================================
;
@ -66,42 +66,42 @@ done rts
;
;=========================================================================
lowercstr START
lowercstr START
space equ 1
p equ space+2
end equ p+4
space equ 1
p equ space+2
end equ p+4
tsc
phd
tcd
tsc
phd
tcd
short a
short a
ldy #-1
loop iny
lda [p],y
beq done
ldy #-1
loop iny
lda [p],y
beq done
cmp #'A'
bcc loop
cmp #'Z'+1
bcs loop
adc #'a'-'A'
sta [p],y
bra loop
sta [p],y
bra loop
done rep #$21
done rep #$21
longa on
lda space
sta end-2
pld
tsc
adc #end-3
tcs
lda space
sta end-2
pld
tsc
adc #end-3
tcs
rts
rts
END
END
;=========================================================================
;
@ -109,38 +109,38 @@ done rep #$21
;
;=========================================================================
cstrlen START
cstrlen START
space equ 1
p equ space+2
end equ p+4
space equ 1
p equ space+2
end equ p+4
tsc
phd
tcd
tsc
phd
tcd
short a
short a
ldy #0
loop lda [p],y
beq done
iny
bra loop
ldy #0
loop lda [p],y
beq done
iny
bra loop
done rep #$21
done rep #$21
longa on
lda space
sta end-2
pld
tsc
adc #end-3
tcs
lda space
sta end-2
pld
tsc
adc #end-3
tcs
tya
tya
rts
rts
END
END
;=========================================================================
;
@ -149,40 +149,40 @@ done rep #$21
;
;=========================================================================
copycstr START
copycstr START
space equ 1
q equ space+2
p equ q+4
end equ p+4
space equ 1
q equ space+2
p equ q+4
end equ p+4
tsc
phd
tcd
tsc
phd
tcd
short a
short a
ldy #0
loop lda [p],y
beq done
sta [q],y
iny
bra loop
ldy #0
loop lda [p],y
beq done
sta [q],y
iny
bra loop
done sta [q],y
done sta [q],y
rep #$21
rep #$21
longa on
lda space
sta end-2
pld
tsc
adc #end-3
tcs
lda space
sta end-2
pld
tsc
adc #end-3
tcs
rts
rts
END
END
;=========================================================================
;
@ -190,31 +190,31 @@ done sta [q],y
;
;=========================================================================
cmpcstr START
cmpcstr START
space equ 1
q equ space+2
p equ q+4
end equ p+4
space equ 1
q equ space+2
p equ q+4
end equ p+4
tsc
phd
tcd
tsc
phd
tcd
short a
short a
ldx #0
ldy #0
strloop lda [p],y
beq strchk
cmp [q],y
bne notequal
iny
bra strloop
ldx #0
ldy #0
strloop lda [p],y
beq strchk
cmp [q],y
bne notequal
iny
bra strloop
strchk lda [q],y
beq done
strchk lda [q],y
beq done
lessthan dex
bra done
@ -222,19 +222,19 @@ lessthan dex
notequal bcc lessthan
inx
done rep #$21
done rep #$21
longa on
lda space
sta end-2
pld
tsc
adc #end-3
tcs
lda space
sta end-2
pld
tsc
adc #end-3
tcs
txa
rts
txa
rts
END
END
;=========================================================================
;
@ -244,37 +244,37 @@ done rep #$21
cmpdcstr START
hold equ 1
space equ hold+2
q equ space+2
p equ q+4
end equ p+4
hold equ 1
space equ hold+2
q equ space+2
p equ q+4
end equ p+4
tsc
sec
sbc #space-1
tcs
phd
tcd
tsc
sec
sbc #space-1
tcs
phd
tcd
ldx #0
ldy #0
strloop lda [q],y
and #$FF
jsr tolower
sta hold
lda [p],y
and #$FF
beq strchk
jsr tolower
cmp hold
bne notequal
iny
bra strloop
ldx #0
ldy #0
strloop lda [q],y
and #$FF
jsr tolower
sta hold
lda [p],y
and #$FF
beq strchk
jsr tolower
cmp hold
bne notequal
iny
bra strloop
strchk lda hold
beq done
strchk lda hold
beq done
lessthan dex
bra done
@ -282,19 +282,19 @@ lessthan dex
notequal bcc lessthan
inx
done anop
lda space
sta end-2
pld
tsc
clc
adc #end-3
tcs
done anop
lda space
sta end-2
pld
tsc
clc
adc #end-3
tcs
txa
rts
txa
rts
END
END
;=========================================================================
;
@ -302,55 +302,55 @@ done anop
;
;=========================================================================
c2gsstr START
len equ 1
gstr equ len+2
space equ gstr+4
cstr equ space+2
end equ cstr+4
c2gsstr START
len equ 1
gstr equ len+2
space equ gstr+4
cstr equ space+2
end equ cstr+4
tsc
sec
sbc #space-1
tcs
phd
tcd
tsc
sec
sbc #space-1
tcs
phd
tcd
pei (cstr+2)
pei (cstr)
jsr cstrlen
sta len
pei (cstr+2)
pei (cstr)
jsr cstrlen
sta len
adc #3
pea 0
pha
~NEW
sta gstr
stx gstr+2
pea 0
pha
~NEW
sta gstr
stx gstr+2
incad @xa
incad @xa
pei (cstr+2)
pei (cstr)
phx
pha
jsr copycstr
lda len
sta [gstr]
pei (cstr+2)
pei (cstr)
phx
pha
jsr copycstr
lda len
sta [gstr]
ldx gstr+2
ldy gstr
ldx gstr+2
ldy gstr
lda space
sta end-2
pld
tsc
adc #end-3
tcs
lda space
sta end-2
pld
tsc
adc #end-3
tcs
tya
rts
tya
rts
END
END
;=========================================================================
;
@ -358,20 +358,20 @@ end equ cstr+4
;
;=========================================================================
catcstr START
catcstr START
new equ 1
space equ new+4
q equ space+2
p equ q+4
end equ p+4
space equ new+4
q equ space+2
p equ q+4
end equ p+4
tsc
sec
sbc #space-1
tcs
phd
tcd
tsc
sec
sbc #space-1
tcs
phd
tcd
pei (p+2)
pei (p)
@ -405,20 +405,20 @@ copy2 lda [q]
incad q
bra copy2
done ldx new+2
done ldx new+2
ldy new
lda space
sta end-2
pld
tsc
clc
adc #end-3
tcs
lda space
sta end-2
pld
tsc
clc
adc #end-3
tcs
tya
rts
tya
rts
END
END
;=====================================================================
;
@ -427,11 +427,11 @@ done ldx new+2
;=====================================================================
nullfree START
lda 4,s
ora 6,s
bne ok
lda 2,s
lda 2,s
sta 6,s
lda 1,s
sta 5,s
@ -450,13 +450,13 @@ ok ~DISPOSE
;
;=====================================================================
newlineX START
newlineX START
using vardata
lda varnewline
beq newline
rts
rts
;=====================================================================
;
@ -464,7 +464,7 @@ newlineX START
;
;=====================================================================
newline ENTRY
newline ENTRY
lda #13
jmp putchar
@ -484,7 +484,7 @@ newline ENTRY
**************************************************************************
getenv START
len equ 1
retval equ len+2
space equ retval+4
@ -505,7 +505,7 @@ end equ var+4
; Get the variable's length using ReadVariableGS
; Set up parameter block:
mv4 var,RVname Addr of name, from user.
ld4 TempResultBuf,RVresult Use temporary result buf.
ld4 TempResultBuf,RVresult Use temporary result buf.
ReadVariableGS ReadVar Get length.
;
; Allocate memory for value string
@ -565,7 +565,7 @@ exit unlock mutex
tya
rtl
mutex key
; Parameter block for shell ReadVariableGS call (p 423 in ORCA/M manual)
@ -604,6 +604,6 @@ lp1 lda [src],y
sta [dest],y
dey
dey
bpl lp1
bpl lp1
done return
END

View File

@ -7,7 +7,7 @@
* Tim Meekins
* Derek Taubert
*
* $Id: shellvar.asm,v 1.5 1998/08/03 17:30:24 tribby Exp $
* $Id: shellvar.asm,v 1.6 1998/09/08 16:53:13 tribby Exp $
*
**************************************************************************
*
@ -135,7 +135,7 @@ svwhoops ld2 $201,ErrError report memory error
ErrorGS Err
jmp exit and exit.
startshow anop
startshow anop
lda #1022 Store buffer len == 1022 in value
sta [valbuf] buffer (save 2 bytes at end for 0).
lda #260 Store buffer len == 260 in name
@ -153,7 +153,7 @@ showloop ReadIndexedGS idxParm Get next indexed variable.
bcs bumpindx we didn't get it.
tay Store 0 at end of
iny4 name string so it
iny4 name string so it
short a can be treated like
lda #0 a c-string.
sta [varbuf],y
@ -212,7 +212,7 @@ orcastyle add2 argv,#4,argv Point to next argument.
ldy #2
lda [argv],y
pha
lda [argv] Create GS/OS string
lda [argv] Create GS/OS string
pha that contains the value.
bra set1 Complete operation in UNIX-style code.
@ -220,7 +220,7 @@ orcastyle add2 argv,#4,argv Point to next argument.
; UNIX style set. Uses two arguments separated by "=".
; When we get here, Y-reg = index of "=" character.
;
unixstyle cpy #0
unixstyle cpy #0
bne unix0
ldx #^error1
lda #error1 Print error message:
@ -248,7 +248,7 @@ set1 jsr c2gsstr Convert value to GS/OS string.
lda exflag Set export flag in parameter block.
sta RSexport
SetGS ReadSetVar Set variable value & export flag.
pei (arg+2)
@ -288,10 +288,10 @@ showonevar anop
stx varbuf+2
sta RSname
stx RSname+2
stz RSexport
ReadVariableGS ReadSetVar Read value of variable.
ReadVariableGS ReadSetVar Read value of variable.
lda RSexport If export flag is set, it's defined.
bne def
@ -314,7 +314,7 @@ doneone anop
ldx valbuf+2
lda valbuf
jsl free1024 Free valbuf.
ph4 varbuf
ph4 varbuf
jsl nullfree Free varbuf.
@ -331,7 +331,7 @@ exit lda space
lda #0 Return status = 0.
rtl
rtl
;
; Utility subroutine to print name and value in varname and varval
@ -502,7 +502,7 @@ done lda space
lda #0
rtl
rtl
expmutex key
@ -596,7 +596,7 @@ done lda space
lda #0
rtl
rtl
unsmutex key
@ -704,7 +704,7 @@ up9 anop
bne done
lda flag
sta varoldpmode
done return
END
@ -741,7 +741,7 @@ loop phx Hold onto value table index.
set sta evvaltbl,x Save flag in variable.
inx2 Bump index.
cpx evvaltblsz If not at end,
bcc loop stay in loop.
bcc loop stay in loop.
unlock gvmutex Mutual exclusion unlock.

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: stdio.asm,v 1.4 1998/08/03 17:30:24 tribby Exp $
* $Id: stdio.asm,v 1.5 1998/09/08 16:53:14 tribby Exp $
*
**************************************************************************
*
@ -77,7 +77,7 @@ puts START
tay Note: lock destroys Acc
lock mutex Wait for others to leave, and lock.
sty getchar+1 Save low-order bytes of address.
sty getchar+1 Save low-order bytes of address.
txa
short a SWITCH TO SINGLE-BYTE MEMORY MODE.
@ -102,12 +102,12 @@ getchar lda >$FFFFFF,x Get next character from string.
_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
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 getchar Continue copying characters.
bra getchar Continue copying characters.
; Arrive here when null character is encountered.
done sty index Save stream length in global.
@ -116,7 +116,7 @@ exit long a SWITCH TO FULL-WORD MEMORY MODE.
unlock mutex Allow others through.
rts Return to caller.
END
END
**************************************************************************
@ -129,12 +129,12 @@ flush START
using stdout
lock mutex
lock mutex
lda index
beq skip
Write WriteParm
Write WriteParm
Flush flushparm
stz index
stz index
skip unlock mutex
rts
@ -175,9 +175,9 @@ errputchar START
using stderr
tay ;lock destroys Acc
tay ;lock destroys Acc
lock errmutex
tya
tya
and #$FF
ldx errindex
sta errstream,x
@ -187,7 +187,7 @@ errputchar START
cpx #256
bcc done
_flush stx errindex
Write errWriteParm
Write errWriteParm
ldx #0
done stx errindex
unlock errmutex
@ -206,16 +206,16 @@ errputs START
using stderr
tay ;lock destroys Acc
tay ;lock destroys Acc
lock errmutex
sty getchar+1
sty getchar+1
txa
short a
sta getchar+3
ldy errindex
ldx #0
ldx #0
getchar lda >$FFFFFF,x
beq done
@ -230,18 +230,18 @@ getchar lda >$FFFFFF,x
_flush sty errindex
phx
long a
Write errWriteParm
Write errWriteParm
short a
plx
ldy #0
bra getchar
bra getchar
done sty errindex
long a
unlock errmutex
rts
END
END
**************************************************************************
*
@ -253,9 +253,9 @@ errflush START
using stderr
lock errmutex
Write errWriteParm
stz errindex
lock errmutex
Write errWriteParm
stz errindex
unlock errmutex
rts
@ -301,7 +301,7 @@ getchar START
readloop Read inReadParm
bcc okread
ldy #-1 ;return EOF on ALL errors
jmp done2
jmp done2
okread stz inindex
lda insize

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: sv.asm,v 1.5 1998/08/03 17:30:25 tribby Exp $
* $Id: sv.asm,v 1.6 1998/09/08 16:53:14 tribby Exp $
*
**************************************************************************
*
@ -22,7 +22,7 @@
**************************************************************************
mcopy /obj/gno/bin/gsh/sv.mac
dummysv start ; ends up in .root
end
@ -35,7 +35,7 @@ dummysv start ; ends up in .root
**************************************************************************
sv_alloc START
ptr equ 0
space equ ptr+4
@ -81,7 +81,7 @@ init sta [ptr],y Set all entries
**************************************************************************
sv_add START
p equ 0
base equ p+4
space equ base+4
@ -107,7 +107,7 @@ space equ base+4
pea 0
pha
~NEW Allocate memory for it.
sta p Store address in p/p+1.
sta p Store address in p/p+1.
stx p+2
pei (string+2) Copy the string into
@ -115,7 +115,7 @@ space equ base+4
phx
pha
jsr copycstr
bra doit else
bra doit else
asis mv4 string,p Just copy address to p/p+1.
@ -260,7 +260,7 @@ foocol anop
;
; find the index for each column...
;
;
lda #0
tax
clc
@ -476,7 +476,7 @@ nextloop inc i
jmp forloop
;
; swap(v, left, last)
;
;
endloop lda left
asl a
asl a
@ -526,7 +526,7 @@ endloop lda left
pha
pei (right)
jsl _qsort
exit return
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* Tim Meekins
*
* $Id: term.asm,v 1.5 1998/08/03 17:30:25 tribby Exp $
* $Id: term.asm,v 1.6 1998/09/08 16:53:14 tribby Exp $
*
**************************************************************************
*
@ -38,7 +38,7 @@ TIOCGETP gequ $40067408
**************************************************************************
InitTerm START
using termdata
;
@ -54,7 +54,7 @@ allocate anop Allocate termcap buffers.
ph4 #1024
~NEW
sta bp
sta bp
stx bp+2
ph4 #1024
@ -108,7 +108,7 @@ forward_char equ 4
up_history equ 5
down_history equ 6
lda #1
lda #1
sta didReadTerm
ph4 #termname
@ -147,7 +147,7 @@ noentry anop
ok jsl nullfree Free buffer allocated by getenv.
lda #1
sta termok
mv4 areabuf,area
mv4 areabuf,area
tgetstr (#isid,#area)
jsr puts
@ -187,24 +187,24 @@ ok jsl nullfree Free buffer allocated by getenv.
tgetstr (#usid,#area)
sta uscap
stx uscap+2
tgetstr (#klid,#area)
phx
phx
pha
ph2 #backward_char
jsl bindkeyfunc
tgetstr (#krid,#area)
phx
phx
pha
ph2 #forward_char
jsl bindkeyfunc
tgetstr (#kuid,#area)
phx
phx
pha
ph2 #up_history
jsl bindkeyfunc
tgetstr (#kdid,#area)
phx
phx
pha
ph2 #down_history
jsl bindkeyfunc
@ -252,7 +252,7 @@ sg_flags dc i2'0'
hold_term_val ds 4
END
**************************************************************************
*
* outc for outputting characters by termcap
@ -512,7 +512,7 @@ termdata DATA
didReadTerm dc i2'0'
termok dc i2'0'
insertflag dc i2'1'
insertflag dc i2'1'
bp ds 4
areabuf ds 4
@ -532,4 +532,4 @@ vicap ds 4
vscap ds 4
END