mirror of
https://github.com/GnoConsortium/gno.git
synced 2025-02-22 08:29:09 +00:00
Changed many invocations from old shell interface routines (Read_Variable,
Set_Variable, Export, etc.) to new ones (ReadVariableGS, SetGS, ExportGS, etc.) in many places; there are still a few more to change. This change removed the 256-character limit on strings retrieved by these routines, such as the value of environment variables. (PR # 9). At startup do not set $TERM to gnocon if it is already set. Removed the df command (from builtin.asm). Defined macro incad to increment a 4-byte address, checking for overflow; replaced instances of "inc ptr" with "incad ptr". Changed column offset table to use a 1-word rather than 1-byte entry. This resolves PR#14 (hash wouldn't print beyond first 256 filenames). Fixed defect in unalias (alias.asm) where the double quote portion of the scanner would look for a terminating single quote. This resolves PR#69. Changed default order for copying files in $PATH dirs into executable list, so earlier paths files are found first. Added environment variable flag $OLDPATHMODE to make gsh behave in the old (backwards order) way when necessary. Discard duplicate filenames when hashing. Fix PR#73: directory in $PATH with escaped space (\ ) is not searched.
This commit is contained in:
parent
615d7ab922
commit
d534981038
@ -1,21 +1,13 @@
|
||||
Last updated: June 19, 1998 By: Dave Tribby
|
||||
Last updated: July 5, 1998 By: Dave Tribby
|
||||
|
||||
For more bug reports, see also http://www.gno.org/~gno/bugs.html
|
||||
|
||||
Completed items are reported in file UpdateLog.
|
||||
|
||||
|
||||
Initialize internal shell variables to match environment variables
|
||||
(echo, nodirexec, nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof)
|
||||
when shell first starts.
|
||||
|
||||
Gsh requires the v2.0.4 ltermcap to link. Termcap has changed in v2.0.6,
|
||||
and gsh should be updated to reflect this.
|
||||
|
||||
When building the EXE hash table, duplicate entries oughta should be ignored.
|
||||
|
||||
Make PATH's use consistent with forward parsing.
|
||||
|
||||
Identify limits built into gsh and how they can be changed; for example,
|
||||
size of $PATH <= 256; max programs in hash table = 256.
|
||||
|
||||
@ -39,6 +31,10 @@ Allow ~user construct (call routines to get user's home directory)
|
||||
|
||||
recursive aliases.
|
||||
|
||||
In expandvars (expand.asm):
|
||||
Add error checking if out buf gets too big (> 1024)
|
||||
Get rid of fixed buffers
|
||||
|
||||
[ -- below this line...probably not -- ]
|
||||
|
||||
write new memory management.
|
||||
|
@ -1,6 +1,65 @@
|
||||
GSH 2.0 UPDATES
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Jul 19 98 [dmt] Changed edit.asm to use ReadIndexedGS, InitWildcardGS,
|
||||
NextWildcardGS, instead of their obsolete counterparts.
|
||||
|
||||
Jul 18 98 [dmt] Changed Set_Variable, Export, UnsetVariable in cmd.asm,
|
||||
shellvar.asm, jobs.asm, and term.asm to use new shell interface
|
||||
(SetGS, ExportGS, UnsetVariableGS).
|
||||
In InitTerm (term.asm), do not set TERM to gnocon if it is
|
||||
already set.
|
||||
|
||||
Jul 17 98 [dmt] Changed final Read_Variable call (in edit.asm) to use
|
||||
getenv instead. Changed ReadVariableGS calls in hash.asm
|
||||
and builtin.asm to also use getenv.
|
||||
|
||||
Jul 16 98 [dmt] Changed Read_Variable calls in history.asm and prompt.asm
|
||||
to use getenv instead.
|
||||
|
||||
Jul 15 98 [dmt] Changed getenv (shellutil.asm) to use ReadVariableGS
|
||||
instead of Read_Variable to get value. getenv's input parameter
|
||||
is now a pointer to a GS/OS string (not a C-string), and it
|
||||
returns a pointer to a GS/OS result buffer with a terminating
|
||||
null byte added. This interface change affected calls to
|
||||
getenv in orca.asm and term.asm.
|
||||
|
||||
Jul 14 98 [dmt] Changed expandvars (expand.asm) to use ReadVariableGS
|
||||
to get the value of an environment variable, allowing values
|
||||
over 256 characters in length.
|
||||
|
||||
Jul 13 98 [dmt] Rewrote shellvar.asm to use newer shell calls to access
|
||||
environment variables, so that they can be > 256 characters.
|
||||
Combined set and setenv into the same routine, with different
|
||||
entry points.
|
||||
|
||||
Jul 12 98 [dmt] In rehash command (hash.asm), read the PATH environment
|
||||
variable with ReadVariableGS instead of Read_Variable, allowing
|
||||
detection of true length and total length > 256 (PR # 9).
|
||||
|
||||
Jul 9 98 [dmt] Removed the df command (from builtin.asm).
|
||||
Defined macro incad to increment a 4-byte address, checking
|
||||
for overflow; replaced instances of "inc ptr" with "incad ptr".
|
||||
|
||||
Jul 8 98 [dmt] Changed column offset table to use a 1-word rather
|
||||
than 1-byte entry. This resolves PR#14 (hash wouldn't
|
||||
print beyond first 256 filenames).
|
||||
|
||||
Jul 7 98 [dmt] Fixed defect in unalias (alias.asm) where the double
|
||||
quote portion of the scanner would look for a terminating
|
||||
single quote. This resolves PR#69.
|
||||
|
||||
Jul 5 98 [dmt] Changed default order for copying files in $PATH dirs
|
||||
into executable list, so earlier paths files are found first.
|
||||
Added environment variable flag $OLDPATHMODE to make gsh
|
||||
behave in the old (backwards order) way when necessary.
|
||||
Discard duplicate filenames when hashing.
|
||||
Fix PR#73: directory in $PATH with escaped space (\ ) is
|
||||
not searched. Needed to remove the "\" before sending
|
||||
pathname to ExpandPathGS.
|
||||
|
||||
Jun 29 98 [dmt] Changes up to this point checked-in to master archive.
|
||||
|
||||
Jun 28 98 [dmt] Added InitVar routine to shellvar.asm to read values
|
||||
of all environment variables tracked in vardata.
|
||||
|
||||
@ -25,7 +84,7 @@ Jun 21 98 [dmt] Added loop to execute(), in cmd.asm, to extract a single
|
||||
b) Odd things randomly happened when tab was the first
|
||||
character of multiple consecutive lines.
|
||||
|
||||
Jun 20 98 [dmt] Changed pointer arithmetic from dec or inc to acd or sbc
|
||||
Jun 20 98 [dmt] Changed pointer arithmetic from dec or inc to adc or sbc
|
||||
to allow for boundary condition in shell.asm.
|
||||
In ShellExec (cmd.asm), save status from call to execute and
|
||||
pass back to caller in Accumulator.
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: alias.asm,v 1.3 1998/06/30 17:25:07 tribby Exp $
|
||||
* $Id: alias.asm,v 1.4 1998/07/20 16:23:01 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -20,23 +20,30 @@
|
||||
*
|
||||
* Interfaces defined in this file:
|
||||
*
|
||||
* alias
|
||||
* alias subroutine (4:argv,2:argc)
|
||||
* Returns with status=0 in Accumulator
|
||||
*
|
||||
* unalias
|
||||
* unalias subroutine (4:argv,2:argc)
|
||||
* Returns with status=0 in Accumulator
|
||||
*
|
||||
* initalias jsr/rts with no parameters
|
||||
*
|
||||
* initalias
|
||||
* expandalias subroutine (4:cmd)
|
||||
* return 4:buf
|
||||
*
|
||||
* expandalias
|
||||
* addalias subroutine (4:aliasname,4:aliasval)
|
||||
* return
|
||||
*
|
||||
* addalias
|
||||
* removealias subroutine (4:aliasname)
|
||||
* return
|
||||
*
|
||||
* findalias subroutine (4:aliasname),space
|
||||
* return 4:value
|
||||
*
|
||||
* removealias
|
||||
* startalias jsl/rtl with no parameters
|
||||
*
|
||||
* findalias
|
||||
*
|
||||
* startalias
|
||||
*
|
||||
* nextalias
|
||||
* nextalias subroutine (4:p)
|
||||
* return 2:hashvalz
|
||||
*
|
||||
*
|
||||
**************************************************************************
|
||||
@ -76,13 +83,16 @@ end equ argv+4
|
||||
phd
|
||||
tcd
|
||||
|
||||
lda argc
|
||||
lda argc How many arguments were provided?
|
||||
dec a
|
||||
beq showall
|
||||
beq showall None -- show all alias names.
|
||||
dec a
|
||||
beq showone
|
||||
jmp setalias
|
||||
beq showone One -- show a single name.
|
||||
jmp setalias More -- set an alias.
|
||||
|
||||
;
|
||||
; Show all aliases
|
||||
;
|
||||
showall jsl startalias
|
||||
showloop jsl nextalias
|
||||
sta arg
|
||||
@ -110,6 +120,9 @@ showloop jsl nextalias
|
||||
|
||||
noshow jmp exit
|
||||
|
||||
;
|
||||
; Show a single alias
|
||||
;
|
||||
showone ldy #4+2
|
||||
lda [argv],y
|
||||
tax
|
||||
@ -117,8 +130,8 @@ showone ldy #4+2
|
||||
ldy #4
|
||||
lda [argv],y
|
||||
pha
|
||||
jsr puts
|
||||
lda #':'
|
||||
jsr puts Print name.
|
||||
lda #':' Print ": ".
|
||||
jsr putchar
|
||||
lda #' '
|
||||
jsr putchar
|
||||
@ -128,14 +141,18 @@ showone ldy #4+2
|
||||
ora arg+2
|
||||
beq notthere
|
||||
lda arg
|
||||
jsr puts
|
||||
jsr newline
|
||||
jmp exit
|
||||
notthere ldx #^noalias
|
||||
lda #noalias
|
||||
jsr puts Print alias value.
|
||||
jsr newline Print newline.
|
||||
jmp exit All done.
|
||||
|
||||
notthere ldx #^noalias Print message:
|
||||
lda #noalias 'Alias not defined'
|
||||
jsr puts
|
||||
jmp exit
|
||||
|
||||
;
|
||||
; Set an alias name
|
||||
;
|
||||
setalias ldy #4+2 ;put alias name on stack
|
||||
lda [argv],y
|
||||
pha
|
||||
@ -202,7 +219,7 @@ exit lda space
|
||||
adc #end-4
|
||||
tcs
|
||||
|
||||
lda #0
|
||||
lda #0 Return status always 0.
|
||||
|
||||
rtl
|
||||
|
||||
@ -413,6 +430,9 @@ next lda [cmd]
|
||||
if2 @a,eq,#"'",singquoter
|
||||
if2 @a,eq,#'"',doubquoter
|
||||
bra next
|
||||
;
|
||||
; "\" found
|
||||
;
|
||||
backstabber lda [cmd]
|
||||
inc cmd
|
||||
sta [outbuf]
|
||||
@ -420,6 +440,9 @@ backstabber lda [cmd]
|
||||
and #$FF
|
||||
beq done
|
||||
bra next
|
||||
;
|
||||
; "'" found
|
||||
;
|
||||
singquoter lda [cmd]
|
||||
inc cmd
|
||||
sta [outbuf]
|
||||
@ -428,15 +451,21 @@ singquoter lda [cmd]
|
||||
beq done
|
||||
if2 @a,ne,#"'",singquoter
|
||||
bra next
|
||||
;
|
||||
; '"' found
|
||||
;
|
||||
doubquoter lda [cmd]
|
||||
inc cmd
|
||||
sta [outbuf]
|
||||
inc outbuf
|
||||
and #$FF
|
||||
beq done
|
||||
if2 @a,ne,#"'",singquoter
|
||||
if2 @a,ne,#'"',doubquoter
|
||||
bra next
|
||||
|
||||
|
||||
;
|
||||
; ";", "|", or "&" found: it's another command
|
||||
;
|
||||
nextalias jmp eatleader
|
||||
|
||||
done ldx word+2
|
||||
@ -793,7 +822,7 @@ hashval equ 0
|
||||
space equ hashval+2
|
||||
|
||||
subroutine (4:p),space
|
||||
|
||||
|
||||
lda #11
|
||||
sta hashval
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: builtin.asm,v 1.3 1998/06/30 17:25:12 tribby Exp $
|
||||
* $Id: builtin.asm,v 1.4 1998/07/20 16:23:01 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -39,7 +39,6 @@
|
||||
* which
|
||||
* prefix
|
||||
* rehash (unhash is entry as an alternate name)
|
||||
* df
|
||||
* exit
|
||||
* setdebug
|
||||
* psbi (command name is "ps")
|
||||
@ -138,7 +137,8 @@ ourproc jsl >$FFFFFF ;might want to mutex this!!!!!!
|
||||
pei (argv)
|
||||
jsl argfree
|
||||
|
||||
done anop
|
||||
done ldy val Y-reg = return value.
|
||||
|
||||
lda space
|
||||
sta end-3
|
||||
lda space+1
|
||||
@ -148,9 +148,9 @@ done anop
|
||||
clc
|
||||
adc #end-4
|
||||
tcs
|
||||
tya
|
||||
|
||||
lda val
|
||||
tya Accumulator = return value.
|
||||
|
||||
rtl
|
||||
|
||||
END
|
||||
@ -219,7 +219,6 @@ builtintbl dc a4'aliasname,alias',i2'0'
|
||||
dc a4'chdirname,chdir',i2'1'
|
||||
dc a4'clearname,clear',i2'1' Changed to unforked
|
||||
dc a4'cmdname,cmdbi',i2'0'
|
||||
dc a4'dfname,df',i2'0'
|
||||
dc a4'dirsname,dirs',i2'0'
|
||||
dc a4'echoname,echo',i2'0'
|
||||
dc a4'editname,edit',i2'1'
|
||||
@ -256,7 +255,6 @@ cdname dc c'cd',h'00'
|
||||
clearname dc c'clear',h'00'
|
||||
cmdname dc c'commands',h'00'
|
||||
dirsname dc c'dirs',h'00'
|
||||
dfname dc c'df',h'00'
|
||||
echoname dc c'echo',h'00'
|
||||
editname dc c'edit',h'00'
|
||||
exitname dc c'exit',h'00'
|
||||
@ -299,7 +297,8 @@ chdir ENTRY
|
||||
|
||||
dpg equ 1 Direct page pointer.
|
||||
buf equ dpg+4 Buffer address to be freed.
|
||||
space equ buf+4
|
||||
status equ buf+4 Status returned from command.
|
||||
space equ status+2
|
||||
argc equ space+3
|
||||
argv equ argc+2
|
||||
end equ argv+4
|
||||
@ -318,6 +317,8 @@ end equ argv+4
|
||||
stz buf Clear the pointer to
|
||||
stz buf+2 allocated buffer.
|
||||
|
||||
stz status Assume good status.
|
||||
|
||||
lda argc Number of parameters
|
||||
dec a determines type of cd...
|
||||
beq cdhome either to $HOME
|
||||
@ -327,7 +328,8 @@ end equ argv+4
|
||||
;
|
||||
; Illegal parameters: print usage string
|
||||
;
|
||||
showusage lda [argv]
|
||||
showusage inc status Return status = 1.
|
||||
lda [argv]
|
||||
tax
|
||||
ldy #2
|
||||
lda [argv],y
|
||||
@ -336,11 +338,11 @@ showusage lda [argv]
|
||||
lda [argv],y
|
||||
and #$FF
|
||||
beq cdusage
|
||||
ldx #^Usage2
|
||||
ldx #^Usage2 Print chdir usage
|
||||
lda #Usage2
|
||||
jsr errputs
|
||||
jmp exit
|
||||
cdusage ldx #^Usage
|
||||
cdusage ldx #^Usage Print cd usage
|
||||
lda #Usage
|
||||
jsr errputs
|
||||
jmp exit
|
||||
@ -348,21 +350,13 @@ cdusage ldx #^Usage
|
||||
;
|
||||
; Set prefix to $home
|
||||
;
|
||||
cdhome ph4 #256 Allocate 256 bytes for result buf.
|
||||
jsl ~NEW
|
||||
sta buf
|
||||
stx buf+2
|
||||
sta ReadName
|
||||
stx ReadName+2
|
||||
ora ReadName+2 If both address bytes are 0,
|
||||
bne madeit
|
||||
lda #$201
|
||||
jmp ohshit we have a problem...
|
||||
|
||||
madeit lda #256 Set length of GS/OS result buffer
|
||||
sta [buf]
|
||||
|
||||
ReadVariableGS ReadVar Read value of $home
|
||||
cdhome anop
|
||||
ph4 #home Get value of $HOME
|
||||
jsl getenv
|
||||
sta buf If GS/OS result buffer
|
||||
stx buf+2 wasn't allocated,
|
||||
ora buf+2
|
||||
jeq exit there's no more to do.
|
||||
|
||||
clc Calculate address
|
||||
lda buf of GS/OS input string
|
||||
@ -374,10 +368,6 @@ madeit lda #256 Set length of GS/OS result buffer
|
||||
sta PRecPath+2
|
||||
sta GRecPath+2
|
||||
|
||||
ldy #2
|
||||
lda [buf],y Get string length word.
|
||||
beq done If 0, bail out.
|
||||
|
||||
bra getinfo
|
||||
|
||||
;
|
||||
@ -434,13 +424,13 @@ ok2 SetPrefix PRec
|
||||
;
|
||||
; Deallocate buffer (if necessary), unlock mutex, cleanup stack, and leave
|
||||
;
|
||||
done ora2 buf,buf+2,@a
|
||||
beq exit
|
||||
ph4 buf
|
||||
done ph4 buf
|
||||
jsl nullfree
|
||||
|
||||
exit unlock cdmutex
|
||||
|
||||
ldy status Put return status in Y-reg
|
||||
|
||||
lda space
|
||||
sta end-3
|
||||
lda space+1
|
||||
@ -451,7 +441,7 @@ exit unlock cdmutex
|
||||
adc #end-4
|
||||
tcs
|
||||
|
||||
lda #0
|
||||
tay Put return status in Accumulator.
|
||||
|
||||
rtl
|
||||
|
||||
@ -468,13 +458,6 @@ GRecPath ds 4 Pointer to input pathname
|
||||
GRecAcc ds 2 access (result)
|
||||
GRecFT ds 2 fileType (result)
|
||||
|
||||
; Parameter block for shell ReadVariableGS call (p 423 in ORCA/M manual)
|
||||
ReadVar anop
|
||||
dc i2'3' pCount
|
||||
dc a4'home' Pointer to name
|
||||
ReadName ds 4 GS/OS Output buffer ptr: value
|
||||
ds 2 export flag
|
||||
|
||||
home gsstr 'home' Env variable name
|
||||
|
||||
; Parameter block for shell ErrorGS call (p 393 in ORCA/M manual)
|
||||
@ -607,8 +590,9 @@ gotn iny
|
||||
dec argc Decrement argument counter.
|
||||
jeq done Done if no more arguments.
|
||||
|
||||
* Beginning of main processing loop of echo parameters.
|
||||
|
||||
;
|
||||
; Beginning of main processing loop of echo parameters.
|
||||
;
|
||||
loop add2 argv,#4,argv Bump argument pointer.
|
||||
ldy #2
|
||||
lda [argv],y Set ptr to argv (next argument)
|
||||
@ -621,7 +605,7 @@ putloop lda [ptr] Get first
|
||||
jeq doneput done with this argument.
|
||||
cmp #'\' If != "\"
|
||||
jne putit go save in print buffer.
|
||||
inc ptr Escape character found; point
|
||||
incad ptr Escape character found; point
|
||||
lda [ptr] to the next
|
||||
and #$FF character.
|
||||
beq doneput If 0, done with this argument.
|
||||
@ -658,13 +642,13 @@ escloop lda [ptr],y
|
||||
adc 1,s
|
||||
sta val
|
||||
pla
|
||||
inc ptr
|
||||
incad ptr
|
||||
bra escloop
|
||||
|
||||
putval lda val Get numeric escape code.
|
||||
|
||||
putit jsr putchar Save character in accumulator.
|
||||
didit inc ptr Point to next char in arg
|
||||
didit incad ptr Point to next char in arg
|
||||
jmp putloop and go process it.
|
||||
|
||||
doneput dec argc Decrement argument counter.
|
||||
@ -1268,266 +1252,6 @@ Usage dc c'Usage: ',h'00'
|
||||
|
||||
END
|
||||
|
||||
**************************************************************************
|
||||
*
|
||||
* DF: builtin command
|
||||
* syntax: df
|
||||
*
|
||||
* displays volumes and free space
|
||||
*
|
||||
**************************************************************************
|
||||
|
||||
df START
|
||||
|
||||
using FSTData
|
||||
|
||||
space equ 1
|
||||
argc equ space+3
|
||||
argv equ argc+2
|
||||
end equ argv+4
|
||||
|
||||
tsc
|
||||
phd
|
||||
tcd
|
||||
|
||||
lock mutex
|
||||
|
||||
lda argc
|
||||
dec a
|
||||
beq showall
|
||||
|
||||
ldx #^Usage
|
||||
lda #Usage
|
||||
jsr errputs
|
||||
bra exit
|
||||
|
||||
showall ldx #^hdr
|
||||
lda #hdr
|
||||
jsr puts
|
||||
ld2 1,DIDevNum
|
||||
allloop DInfo DIParm
|
||||
bcs exit
|
||||
jsr showdev
|
||||
inc DIDevNum
|
||||
bra allloop
|
||||
|
||||
exit unlock mutex
|
||||
lda space
|
||||
sta end-3
|
||||
lda space+1
|
||||
sta end-2
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #end-4
|
||||
tcs
|
||||
|
||||
lda #0
|
||||
|
||||
rtl
|
||||
|
||||
showdev lda #'.'
|
||||
jsr putchar
|
||||
lda #'d'
|
||||
jsr putchar
|
||||
lda DIdevnum
|
||||
cmp #10
|
||||
bcs dev10
|
||||
clc
|
||||
adc #'0'
|
||||
jsr putchar
|
||||
lda #' '
|
||||
jsr putchar
|
||||
bra endnum
|
||||
dev10 UDivide (DIdevnum,#10),(@a,@x)
|
||||
phx
|
||||
clc
|
||||
adc #'0'
|
||||
jsr putchar
|
||||
pla
|
||||
clc
|
||||
adc #'0'
|
||||
jsr putchar
|
||||
endnum lda #' '
|
||||
jsr putchar
|
||||
|
||||
Volume VolParm
|
||||
jcc okdev
|
||||
lda DIid
|
||||
cmp #$20
|
||||
bcc okdid
|
||||
lda #0
|
||||
okdid asl2 a
|
||||
tay
|
||||
ldx idtbl+2,y
|
||||
lda idtbl,y
|
||||
jsr puts
|
||||
short a
|
||||
ldy devname
|
||||
lda #' '
|
||||
dev5 cpy #17
|
||||
bcs dev6
|
||||
sta devname+2,y
|
||||
iny
|
||||
bra dev5
|
||||
dev6 lda #16
|
||||
sta devname+1
|
||||
long a
|
||||
ldx #^devname+1
|
||||
lda #devname+1
|
||||
jsr putp
|
||||
lda #' '
|
||||
jsr putchar
|
||||
|
||||
jmp newline
|
||||
|
||||
okdev ldy volname
|
||||
short a
|
||||
lda #' '
|
||||
dev1 cpy #17
|
||||
bcs dev2
|
||||
sta volname+2,y
|
||||
iny
|
||||
bra dev1
|
||||
dev2 lda #16
|
||||
sta volname+1
|
||||
ldy devname
|
||||
lda #' '
|
||||
dev3 cpy #17
|
||||
bcs dev4
|
||||
sta devname+2,y
|
||||
iny
|
||||
bra dev3
|
||||
dev4 lda #16
|
||||
sta devname+1
|
||||
long a
|
||||
|
||||
ldx #^volname+1
|
||||
lda #volname+1
|
||||
jsr putp
|
||||
lda #' '
|
||||
jsr putchar
|
||||
ldx #^devname+1
|
||||
lda #devname+1
|
||||
jsr putp
|
||||
lda #' '
|
||||
jsr putchar
|
||||
Long2Dec (VolFree,#numbuf,#7,#0)
|
||||
ldx #^numbuf
|
||||
lda #numbuf
|
||||
jsr puts
|
||||
Long2Dec (VolTot,#numbuf,#7,#0)
|
||||
ldx #^numbuf
|
||||
lda #numbuf
|
||||
jsr puts
|
||||
;
|
||||
; [(total - free) * 100] / total
|
||||
;
|
||||
lda VolFree
|
||||
ora VolFree+2
|
||||
beq put100
|
||||
clc ;why clc, need to investigate :)
|
||||
lda VolTot
|
||||
sbc VolFree
|
||||
tax
|
||||
lda VolTot+2
|
||||
sbc VolFree+2
|
||||
LongMul (@ax,#100),(@ax,@y)
|
||||
LongDivide (@xa,VolTot),(@ax,@y)
|
||||
Long2Dec (@xa,#capbuf+3,#3,#0)
|
||||
ldx #^capbuf
|
||||
lda #capbuf
|
||||
jsr puts
|
||||
bra putsys
|
||||
|
||||
put100 ldx #^cap100buf
|
||||
lda #cap100buf
|
||||
jsr puts
|
||||
|
||||
putsys lda VolSysID
|
||||
cmp #$E
|
||||
bcc oksys
|
||||
lda #0
|
||||
oksys asl2 a
|
||||
tay
|
||||
ldx FSTtable+2,y
|
||||
lda FSTtable,y
|
||||
jsr puts
|
||||
jmp newline
|
||||
|
||||
hdr dc c'.d## Volume Device Free Total Capacity System',h'0d'
|
||||
dc c'---- ---------------- ---------------- ------- ------- -------- -----------',h'0d00'
|
||||
|
||||
Usage dc c'Usage: df',h'0d00'
|
||||
numbuf dc c' ',h'00'
|
||||
capbuf dc c' % ',h'00'
|
||||
cap100buf dc c' 100% ',h'00'
|
||||
|
||||
mutex key
|
||||
|
||||
DIParm dc i2'8'
|
||||
DIDevNum ds 2
|
||||
dc a4'devbuf'
|
||||
dc i2'0'
|
||||
dc i4'0'
|
||||
dc i2'0'
|
||||
dc i2'0'
|
||||
dc i2'0'
|
||||
DIid dc i2'0'
|
||||
|
||||
VolParm dc i2'5'
|
||||
dc a4'devname'
|
||||
dc a4'volbuf'
|
||||
VolTot ds 4
|
||||
VolFree ds 4
|
||||
VolSysID ds 2
|
||||
|
||||
devbuf dc i'35'
|
||||
devname ds 33
|
||||
volbuf dc i'260'
|
||||
volname ds 258
|
||||
|
||||
idtbl dc a4'id00,id01,id02,id03,id04,id05,id06,id07,id08'
|
||||
dc a4'id09,id0a,id0b,id0c,id0d,id0e,id0f,id10,idff'
|
||||
dc a4'id12,id13,id14,id15,id16,id17,id18,id19,id1a'
|
||||
dc a4'id1b,id1c,id1d,id1e,id1f'
|
||||
dc a4'idff'
|
||||
|
||||
idff dc c'<unknown> ',h'00'
|
||||
id00 dc c'Apple 5.25 Drive ',h'00'
|
||||
id01 dc c'Profile 5MB ',h'00'
|
||||
id02 dc c'Profile 10MB ',h'00'
|
||||
id03 dc c'Apple 3.5 Drive ',h'00'
|
||||
id04 dc c'SCSI ',h'00'
|
||||
id05 dc c'SCSI Hard Drive ',h'00'
|
||||
id06 dc c'SCSI Tape Drive ',h'00'
|
||||
id07 dc c'SCSI CD-ROM ',h'00'
|
||||
id08 dc c'SCSI Printer ',h'00'
|
||||
id09 dc c'Serial Modem ',h'00'
|
||||
id0a dc c'Console Driver ',h'00'
|
||||
id0b dc c'Serial Printer ',h'00'
|
||||
id0c dc c'Serial LaserWrit ',h'00'
|
||||
id0d dc c'AppleTalk LaserW ',h'00'
|
||||
id0e dc c'RAM Disk ',h'00'
|
||||
id0f dc c'ROM Disk ',h'00'
|
||||
id10 dc c'File Server ',h'00'
|
||||
id12 dc c'Apple Desktop Bu ',h'00'
|
||||
id13 dc c'Hard Drive ',h'00'
|
||||
id14 dc c'Floppy Drive ',h'00'
|
||||
id15 dc c'Tape Drive ',h'00'
|
||||
id16 dc c'Character dev dr ',h'00'
|
||||
id17 dc c'MFM-encoded ',h'00'
|
||||
id18 dc c'AppleTalk net ',h'00'
|
||||
id19 dc c'Sequential dev ',h'00'
|
||||
id1a dc c'SCSI Scanner ',h'00'
|
||||
id1b dc c'Scanner ',h'00'
|
||||
id1c dc c'LaserWriter SC ',h'00'
|
||||
id1d dc c'AppleTalk Main ',h'00'
|
||||
id1e dc c'AppleTalk fsd ',h'00'
|
||||
id1f dc c'AppleTalk RPM ',h'00'
|
||||
|
||||
END
|
||||
|
||||
**************************************************************************
|
||||
*
|
||||
* FST descriptions
|
||||
@ -1572,7 +1296,7 @@ space equ 0
|
||||
|
||||
subroutine (4:argv,2:argc),space
|
||||
|
||||
inc exitamundo
|
||||
inc exit_requested
|
||||
|
||||
return 2:#0
|
||||
|
||||
@ -1649,7 +1373,7 @@ done setdebug newdebug
|
||||
mv2 newdebug,globaldebug
|
||||
return return 2:#0
|
||||
|
||||
findflag inc arg
|
||||
findflag incad arg
|
||||
ldy #0
|
||||
findloop phy
|
||||
lda nametbl,y
|
||||
@ -1997,60 +1721,69 @@ space equ p+4
|
||||
|
||||
subroutine (4:argv,2:argc),space
|
||||
|
||||
ph2 t_size
|
||||
jsl sv_alloc
|
||||
ph2 t_size Get size of hash table.
|
||||
jsl sv_alloc Allocate a string vector array.
|
||||
sta sv
|
||||
stx sv+2
|
||||
|
||||
lda hash_table
|
||||
ora hash_table+2
|
||||
beq exit
|
||||
mv4 hash_table,p
|
||||
lda hash_numexe
|
||||
beq doneadd
|
||||
ldy #0
|
||||
ldx t_size
|
||||
beq doneadd
|
||||
lda hash_table If no hash table
|
||||
ora hash_table+2 has been allocated,
|
||||
beq exit exit.
|
||||
|
||||
mv4 hash_table,p Move address to dir pg variable.
|
||||
lda hash_numexe Get the number of executable files.
|
||||
beq doneadd Done if 0.
|
||||
;
|
||||
; loop through every hashed file and add it the string vector
|
||||
;
|
||||
addloop lda [p],y
|
||||
sta q
|
||||
ldy #0 Y is index into the next entry.
|
||||
ldx t_size X is the number of entries left.
|
||||
beq doneadd
|
||||
addloop lda [p],y Get next hash table entry.
|
||||
sta q
|
||||
iny
|
||||
iny
|
||||
lda [p],y
|
||||
sta q+2
|
||||
iny
|
||||
iny
|
||||
ora q
|
||||
beq skip
|
||||
phy
|
||||
ora q If this entry isn't used,
|
||||
beq skip skip to the next one.
|
||||
|
||||
phy Hold the Y and X regs on stack.
|
||||
phx
|
||||
pei (sv+2)
|
||||
pei (sv)
|
||||
pei (q+2)
|
||||
pei (sv+2) Insert string in table entry
|
||||
pei (sv) into the string vector.
|
||||
clc
|
||||
lda q
|
||||
inc a
|
||||
inc a
|
||||
adc #2 (Note: tn_name in hash.asm == 2)
|
||||
tax
|
||||
lda q+2
|
||||
adc #0
|
||||
pha
|
||||
pea 1
|
||||
phx
|
||||
pea 1 (allocflag: 1 = allocate memory)
|
||||
jsl sv_add
|
||||
plx
|
||||
plx Restore X and Y regs from stack.
|
||||
ply
|
||||
skip dex
|
||||
bne addloop
|
||||
;
|
||||
; Files have all been added to the string vector
|
||||
;
|
||||
doneadd anop
|
||||
|
||||
doneprint pei (sv+2)
|
||||
pei (sv)
|
||||
jsl sv_sort
|
||||
pei (sv+2)
|
||||
pei (sv)
|
||||
jsl sv_colprint
|
||||
jsl sv_sort Sort the string vector.
|
||||
|
||||
pei (sv+2)
|
||||
pei (sv)
|
||||
jsl sv_dispose
|
||||
jsl sv_colprint Print the string vector in columns.
|
||||
|
||||
pei (sv+2)
|
||||
pei (sv)
|
||||
jsl sv_dispose Dispose of the string vector memory.
|
||||
|
||||
exit return 2:#0
|
||||
|
||||
@ -2153,7 +1886,7 @@ addloop lda builtintbl,x
|
||||
bra addloop
|
||||
doneadd anop
|
||||
|
||||
doneprint pei (sv+2)
|
||||
pei (sv+2)
|
||||
pei (sv)
|
||||
jsl sv_sort
|
||||
pei (sv+2)
|
||||
|
156
bin/gsh/cmd.asm
156
bin/gsh/cmd.asm
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: cmd.asm,v 1.3 1998/06/30 17:25:17 tribby Exp $
|
||||
* $Id: cmd.asm,v 1.4 1998/07/20 16:23:02 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -121,7 +121,7 @@ SINGQUOTE equ 4 ;single quote string
|
||||
; Main loop: get character and take action based upon state.
|
||||
;
|
||||
loop lda [buf]
|
||||
inc buf
|
||||
incad buf
|
||||
and2 @a,#$FF,ch ch = next character.
|
||||
bne switch
|
||||
|
||||
@ -204,7 +204,7 @@ neut4b if2 @a,ne,#'#',neut5 ;comment
|
||||
neut4c lda [buf]
|
||||
and #$7F
|
||||
beq neut4d
|
||||
inc buf
|
||||
incad buf
|
||||
if2 @a,eq,#13,neut4d
|
||||
if2 @a,eq,#10,neut4d
|
||||
bra neut4c
|
||||
@ -219,10 +219,10 @@ startsingle lda #SINGQUOTE
|
||||
neut8 if2 @a,ne,#'\',neut9
|
||||
lda [buf]
|
||||
and #$FF
|
||||
inc buf
|
||||
incad buf
|
||||
if2 @a,eq,#13,neut10a
|
||||
neut9 sta [word] ;default
|
||||
inc word
|
||||
incad word
|
||||
lda #INWORD
|
||||
neut10 sta state
|
||||
neut10a jmp loop
|
||||
@ -242,7 +242,7 @@ gtgt2 lda [buf]
|
||||
if2 @a,eq,#'&',gtgt3
|
||||
lda #T_GTGT
|
||||
jmp done
|
||||
gtgt3 inc buf
|
||||
gtgt3 incad buf
|
||||
lda #T_GTGTAMP
|
||||
jmp done
|
||||
;
|
||||
@ -250,9 +250,9 @@ gtgt3 inc buf
|
||||
;
|
||||
case_inquote if2 ch,ne,#'\',quote2 ;is it a quoted character?
|
||||
lda [buf]
|
||||
inc buf
|
||||
incad buf
|
||||
putword sta [word]
|
||||
inc word
|
||||
incad word
|
||||
jmp loop
|
||||
quote2 if2 @a,ne,#'"',putword
|
||||
ld2 INWORD,state
|
||||
@ -283,7 +283,7 @@ case_inword if2 ch,eq,#000,endword
|
||||
jeq startsingle
|
||||
if2 @a,ne,#'\',putword
|
||||
lda [buf]
|
||||
inc buf
|
||||
incad buf
|
||||
and #$FF
|
||||
if2 @a,eq,#13,word2
|
||||
bra putword
|
||||
@ -801,56 +801,60 @@ end equ path+4
|
||||
|
||||
lock mutex
|
||||
;
|
||||
; set the variables 0..argc
|
||||
; Set the variables 0..argc
|
||||
;
|
||||
lda argc
|
||||
jeq skipvar
|
||||
stz count
|
||||
parmloop lda count
|
||||
asl2 a
|
||||
tay
|
||||
lda [argv],y
|
||||
sta setparm+4
|
||||
iny2
|
||||
lda [argv],y
|
||||
sta setparm+6
|
||||
lda count
|
||||
cmp #10
|
||||
bcs num1
|
||||
short a
|
||||
adc #'0'
|
||||
sta num+2
|
||||
long a
|
||||
ld4 num+2,setparm
|
||||
bra setit
|
||||
num1 cmp #100
|
||||
bcs num2
|
||||
Int2Dec (@a,#num+1,#2,#0)
|
||||
ld4 num+1,setparm
|
||||
bra setit
|
||||
num2 Int2Dec (@a,#num,#3,#0)
|
||||
ld4 num,setparm
|
||||
setit ph4 setparm
|
||||
jsr c2pstr2
|
||||
phx
|
||||
pha
|
||||
stx setparm+2
|
||||
sta setparm
|
||||
ph4 setparm+4
|
||||
jsr c2pstr2
|
||||
phx
|
||||
pha
|
||||
stx setparm+4+2
|
||||
sta setparm+4
|
||||
Set_Variable setparm
|
||||
jsl nullfree
|
||||
jsl nullfree
|
||||
inc count
|
||||
lda count
|
||||
cmp argc
|
||||
jcc parmloop
|
||||
lda argc Get number of variables.
|
||||
jeq vars_set If 0, there are none to set.
|
||||
|
||||
skipvar unlock mutex
|
||||
stz count Start with argv[0].
|
||||
parmloop lda count Get index
|
||||
asl2 a into address array.
|
||||
tay
|
||||
lda [argv],y Copy argument
|
||||
sta SetValue pointer to
|
||||
iny2 SetValue
|
||||
lda [argv],y
|
||||
sta SetValue+2
|
||||
|
||||
lda count If parameter number
|
||||
cmp #10
|
||||
bcs digits2or3 < 10,
|
||||
adc #'0' Convert to single digit
|
||||
sta pname_text and store in name string.
|
||||
lda #1 Set length of string to 1.
|
||||
sta pname
|
||||
bra set_value
|
||||
|
||||
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 pname
|
||||
Int2Dec (@a,#pname_text,pname,#0)
|
||||
|
||||
set_value anop
|
||||
ph4 SetValue Convert value string
|
||||
jsr c2gsstr to a GS/OS string
|
||||
stx SetValue+2 and save in SetGS
|
||||
sta SetValue parameter block.
|
||||
|
||||
SetGS SetPB Set $count to the argv string.
|
||||
|
||||
ph4 SetValue Free the value buffer.
|
||||
jsl nullfree
|
||||
inc count Bump the parameter counter.
|
||||
lda count If more to do,
|
||||
cmp argc
|
||||
jcc parmloop stay in loop.
|
||||
|
||||
;
|
||||
; Variables have all been set
|
||||
;
|
||||
vars_set unlock mutex
|
||||
|
||||
ph4 #4 ;Close parms
|
||||
jsl ~NEW
|
||||
@ -969,21 +973,19 @@ noecho lda [data]
|
||||
and #$FF
|
||||
if2 @a,eq,#'#',ReadLoop
|
||||
|
||||
* execute subroutine (4:cmdline,2:jobflag)
|
||||
* call execute: subroutine (4:cmdline,2:jobflag)
|
||||
pei (data+2)
|
||||
pei (data)
|
||||
* ph2 #0
|
||||
* ph2 #1
|
||||
pei (jobflag)
|
||||
jsl execute
|
||||
sta status
|
||||
|
||||
lda exitamundo
|
||||
lda exit_requested
|
||||
bne almostdone
|
||||
bra ReadLoop
|
||||
|
||||
almostdone anop
|
||||
stz exitamundo
|
||||
stz exit_requested
|
||||
lda #1
|
||||
sta [CRec]
|
||||
pei (CRec+2)
|
||||
@ -1031,9 +1033,19 @@ NLTable dc h'0d'
|
||||
Err dc i2'1' pCount
|
||||
ErrError ds 2 Error number
|
||||
|
||||
setparm ds 4
|
||||
ds 4
|
||||
num dc c'000',h'00'
|
||||
;
|
||||
; Parameter block for shell SetGS calls (p 427 in ORCA/M manual)
|
||||
;
|
||||
SetPB anop
|
||||
dc i2'3' pCount
|
||||
SetName dc i4'pname' Name (pointer to GS/OS string)
|
||||
SetValue ds 4 Value (pointer to GS/OS string)
|
||||
SetExport ds 2 Export flag
|
||||
;
|
||||
; Name of argv parameter ($1 to $999) to be set; GS/OS string
|
||||
;
|
||||
pname ds 2 Length
|
||||
pname_text dc c'000' Text (up to 3 digits)
|
||||
|
||||
mutex key
|
||||
|
||||
@ -1097,10 +1109,8 @@ chkws lda [cmdstrt] Get next character.
|
||||
beq bump_strt
|
||||
cmp #9 or a tab,
|
||||
bne found_start
|
||||
bump_strt inc cmdstrt bump the start pointer
|
||||
bne chkws and look for more whitespace.
|
||||
inc cmdstrt+2
|
||||
bra chkws
|
||||
bump_strt incad cmdstrt bump the start pointer
|
||||
bra chkws and look for more whitespace.
|
||||
|
||||
; Initialize pointer to end of command
|
||||
|
||||
@ -1249,7 +1259,7 @@ noecho anop
|
||||
jmp chk_cmd
|
||||
|
||||
|
||||
* command l_subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2,
|
||||
* command subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2,
|
||||
* 4:pipesem,4:stream)
|
||||
loop pea 0 ;Bank 0 waitpid (hi)
|
||||
tdc
|
||||
@ -1322,7 +1332,11 @@ nowait if2 term,eq,#T_EOF,noerrexit
|
||||
beq exit
|
||||
jmp loop process the next command.
|
||||
|
||||
noerrexit stz waitstatus ;non-forked builtins cannot return an error
|
||||
;
|
||||
; NOTE: non-forked builtins have no mechanism to return command status
|
||||
;
|
||||
|
||||
noerrexit stz waitstatus
|
||||
|
||||
exit jsl nullfree
|
||||
lda term ;make sure we return -1 if error
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: dir.asm,v 1.3 1998/06/30 17:25:20 tribby Exp $
|
||||
* $Id: dir.asm,v 1.4 1998/07/20 16:23:03 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -693,7 +693,7 @@ checkhome lda [path],y
|
||||
|
||||
found lda #'~'
|
||||
sta [ptr]
|
||||
inc ptr
|
||||
incad ptr
|
||||
bra copyrest
|
||||
|
||||
notfound pla
|
||||
@ -706,7 +706,7 @@ copyloop lda [path],y
|
||||
lda #'/'
|
||||
copyput sta [ptr]
|
||||
long a
|
||||
inc ptr
|
||||
incad ptr
|
||||
short a
|
||||
iny
|
||||
bra copyloop
|
||||
|
369
bin/gsh/edit.asm
369
bin/gsh/edit.asm
@ -6,12 +6,13 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: edit.asm,v 1.3 1998/06/30 17:25:23 tribby Exp $
|
||||
* $Id: edit.asm,v 1.4 1998/07/20 16:23:03 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
* EDIT.ASM
|
||||
* By Tim Meekins
|
||||
* Modified by Dave Tribby for GNO 2.0.6
|
||||
*
|
||||
* The GNO/Shell command-line editor
|
||||
*
|
||||
@ -651,7 +652,7 @@ t1a lda [p],y
|
||||
;
|
||||
; one at a time
|
||||
;
|
||||
t2 jsr dofignore
|
||||
t2 jsl dofignore
|
||||
lda nummatch
|
||||
beq meepmeep
|
||||
dec a
|
||||
@ -730,27 +731,29 @@ wordlen equ wordnum+2
|
||||
varpos equ wordlen+2
|
||||
newpos equ varpos+2
|
||||
wordpos equ newpos+2
|
||||
gsbuf equ wordpos+2
|
||||
space equ gsbuf+4
|
||||
|
||||
jsl alloc256
|
||||
sta ReadName
|
||||
stx ReadName+2
|
||||
phx
|
||||
pha
|
||||
subroutine (0:dummy),space
|
||||
|
||||
Read_Variable varparms
|
||||
jsr p2cstr
|
||||
sta var
|
||||
stx var+2
|
||||
phx
|
||||
pha
|
||||
jsr lowercstr
|
||||
lda ReadName
|
||||
ldx ReadName+2
|
||||
jsl free256
|
||||
ph4 #fignore
|
||||
jsl getenv
|
||||
|
||||
lda [var]
|
||||
and #$FF
|
||||
jeq done
|
||||
sta gsbuf If buffer wasn't allocated
|
||||
stx gsbuf+2
|
||||
ora gsbuf+2
|
||||
jeq done return to caller.
|
||||
|
||||
clc
|
||||
lda gsbuf Text begins after
|
||||
adc #4 four bytes of
|
||||
bcc storevar length words.
|
||||
inx
|
||||
storevar sta var Store pointer to
|
||||
stx var+2 c-string in var.
|
||||
phx Shift
|
||||
pha to
|
||||
jsr lowercstr lower case.
|
||||
|
||||
lda #0
|
||||
sta wordnum
|
||||
@ -762,14 +765,14 @@ bigloop asl a
|
||||
tay
|
||||
lda matchbuf+2,x
|
||||
sta word+2
|
||||
pha
|
||||
pha
|
||||
phy
|
||||
jsr cstrlen
|
||||
sta wordlen
|
||||
stz newpos
|
||||
figmatch lda newpos
|
||||
sta varpos
|
||||
ldy varpos
|
||||
ldy varpos
|
||||
eatspace lda [var],y
|
||||
and #$FF
|
||||
beq bignext
|
||||
@ -777,6 +780,7 @@ eatspace lda [var],y
|
||||
bne yummy
|
||||
iny
|
||||
bra eatspace
|
||||
|
||||
yummy sty varpos
|
||||
ldx #0
|
||||
eatstuff lda [var],y
|
||||
@ -787,6 +791,7 @@ eatstuff lda [var],y
|
||||
inx
|
||||
iny
|
||||
bra eatstuff
|
||||
|
||||
gotstuff sty newpos
|
||||
cpx wordlen
|
||||
beq hgf
|
||||
@ -817,18 +822,15 @@ bignext inc wordnum
|
||||
cmp nummatch
|
||||
bcc bigloop
|
||||
|
||||
done pei (var+2)
|
||||
pei (var)
|
||||
pei (gsbuf+2) Free memory allocated
|
||||
pei (gsbuf) for the value of $FIGNORE.
|
||||
jsl nullfree
|
||||
rts
|
||||
|
||||
; Parameter block for shell Read_Variable call
|
||||
; [predecessor to ReadVariableGS call (p 423 in ORCA/M manual)]
|
||||
varparms anop
|
||||
dc a4'fignore' Pointer to name
|
||||
ReadName ds 4 Pointer to result
|
||||
done anop
|
||||
|
||||
fignore str 'fignore' Env variable name
|
||||
return
|
||||
|
||||
fignore gsstr 'fignore' Env variable name
|
||||
|
||||
END
|
||||
|
||||
@ -1023,12 +1025,12 @@ isolate cpy cmdlen
|
||||
beq gotiso
|
||||
cmp #'&'
|
||||
beq gotiso
|
||||
sta wordbuf,x
|
||||
sta wordgs_text,x
|
||||
iny
|
||||
inx
|
||||
bra isolate
|
||||
gotiso lda #0
|
||||
sta wordbuf,x
|
||||
sta wordgs_text,x
|
||||
stx wordlen
|
||||
sty cmdloc
|
||||
txa
|
||||
@ -1070,115 +1072,93 @@ chkflag cmp #';'
|
||||
|
||||
gotflag anop
|
||||
;
|
||||
; check if the first character is '$', if so, match for variables ONLY
|
||||
; Check if the first character is '$', if so, match for variables ONLY
|
||||
;
|
||||
lda wordbuf
|
||||
lda wordgs_text
|
||||
and #$FF
|
||||
cmp #'$'
|
||||
jne filem
|
||||
|
||||
ld2 1,varIndex
|
||||
varloop Read_Indexed varParm
|
||||
lda buffer
|
||||
jeq vardone
|
||||
dec a
|
||||
ld2 1,idxIndex
|
||||
varloop ReadIndexedGS idxParm
|
||||
lda NameLen
|
||||
beq vardone
|
||||
cmp wordlen ;if shorter than word skip
|
||||
jcc nextvar
|
||||
;
|
||||
; Scan this variable name to see if it matches wordgs_text
|
||||
;
|
||||
ldx #1
|
||||
varscan lda wordbuf,x
|
||||
varscan lda wordgs_text,x
|
||||
and #$FF
|
||||
beq goodvar
|
||||
beq goodvar Matches (up to current length)
|
||||
jsr tolower
|
||||
eor buffer,x
|
||||
eor NameText-1,x
|
||||
and #$FF
|
||||
jne nextvar
|
||||
jne nextvar Name doesn't match word.
|
||||
inx
|
||||
bra varscan
|
||||
;
|
||||
; We have a match between the variable name and word being typed
|
||||
;
|
||||
goodvar stz sepstyle Don't use ":" or "/"
|
||||
|
||||
goodvar stz sepstyle
|
||||
lda varval
|
||||
and #$FF
|
||||
tay
|
||||
ldx #1
|
||||
gv00 dey
|
||||
bmi gv02
|
||||
lda varval,x
|
||||
and #$FF
|
||||
cmp #':'
|
||||
beq gv00b
|
||||
cmp #'/'
|
||||
bne gv00a
|
||||
gv00b sta sepstyle
|
||||
gv00a inx
|
||||
bra gv00
|
||||
|
||||
gv02 lda varval ;check if it really is a directory
|
||||
and #$FF
|
||||
sta varval-1
|
||||
ld4 varval-1,GFName
|
||||
GetFileInfo GFParm
|
||||
lda GFType
|
||||
cmp #$0F
|
||||
beq gv02a
|
||||
stz sepstyle
|
||||
|
||||
gv02a lda nummatch
|
||||
gv02a anop
|
||||
lda nummatch Get the number of matches.
|
||||
asl a Multiply by 4 (size of address entry)
|
||||
asl a
|
||||
asl a
|
||||
pha
|
||||
lda buffer
|
||||
and #$FF
|
||||
inc a
|
||||
pha Hold offset on stack.
|
||||
lda NameLen Get length of name,
|
||||
inc a and add 3.
|
||||
inc a
|
||||
inc a
|
||||
pea 0
|
||||
pha
|
||||
jsl ~NEW
|
||||
jsl ~NEW Request memory to hold name.
|
||||
sta 0
|
||||
stx 0+2
|
||||
ply
|
||||
sta matchbuf,y
|
||||
txa
|
||||
ply Get matchbuf offset from stack.
|
||||
sta matchbuf,y Store allocated memory's
|
||||
txa address in matchbuf array.
|
||||
sta matchbuf+2,y
|
||||
inc nummatch
|
||||
lda #'$'
|
||||
sta [0]
|
||||
lda buffer
|
||||
and #$FF
|
||||
tax
|
||||
ldy #1
|
||||
gv01 lda buffer,y
|
||||
sta [0],y
|
||||
iny
|
||||
dex
|
||||
bne gv01
|
||||
lda sepstyle
|
||||
sta [0],y
|
||||
|
||||
nextvar inc varIndex
|
||||
lda #'$' First character = "$".
|
||||
sta [0]
|
||||
ldx NameLen Get length of name in X-Reg.
|
||||
ldy #1 Use Y as offset into strings.
|
||||
gv01 lda NameText-1,y Get next byte of name.
|
||||
sta [0],y Store in allocated memory.
|
||||
iny Bump the index.
|
||||
dex Decrement the count
|
||||
bne gv01 Keep copying until done.
|
||||
lda sepstyle Store separator style at end.
|
||||
sta [0],y
|
||||
;
|
||||
; Done with this variable. Check the next one.
|
||||
;
|
||||
nextvar inc idxIndex
|
||||
jmp varloop
|
||||
|
||||
vardone rts
|
||||
|
||||
;
|
||||
; next lets match by file names
|
||||
; we'll start by moving our wordbuf to a pascal string
|
||||
; Match by file names; start by moving wordgs_text + trailing "*" to a GS/OS string
|
||||
;
|
||||
filem lda #1
|
||||
sta iwparm+4
|
||||
sta iwFlags
|
||||
|
||||
short a
|
||||
lda wordlen
|
||||
inc a
|
||||
sta wordpbuf
|
||||
long a
|
||||
sta wordgsbuf
|
||||
ldy wordlen
|
||||
lda #'*'
|
||||
sta wordbuf,y
|
||||
sta wordgs_text,y
|
||||
|
||||
ldx #0
|
||||
short a
|
||||
dey
|
||||
findsep lda wordbuf,y
|
||||
findsep lda wordgs_text,y
|
||||
cmp #':'
|
||||
beq gotsep
|
||||
cmp #'/'
|
||||
@ -1197,7 +1177,7 @@ findsep lda wordbuf,y
|
||||
bne nextsep
|
||||
cpy #0 ;allow boot prefix */
|
||||
bne gotglob
|
||||
lda wordbuf+1
|
||||
lda wordgs_text+1
|
||||
cmp sepstyle
|
||||
bne gotglob
|
||||
bra nextsep
|
||||
@ -1211,57 +1191,66 @@ nextsep dey
|
||||
long a
|
||||
cpx #0
|
||||
beq initit
|
||||
dec iwparm+4
|
||||
dec iwFlags
|
||||
|
||||
initit Init_Wildcard iwparm
|
||||
initit InitWildcardGS iwparm
|
||||
|
||||
filematch Next_Wildcard nwparm
|
||||
lda buffer
|
||||
and #$FF
|
||||
filematch anop
|
||||
NextWildcardGS nwparm
|
||||
ldy NameLen Get length of name.
|
||||
jeq filemdone
|
||||
cmp wordlen
|
||||
cpy wordlen
|
||||
beq filematch
|
||||
lda nummatch
|
||||
|
||||
lda #0 Store null byte at end of name,
|
||||
sta NameText,y so it will act like a c-string.
|
||||
|
||||
lda nummatch Get the number of matches.
|
||||
asl a Multiply by 4 (size of address entry)
|
||||
asl a
|
||||
asl a
|
||||
pha
|
||||
ph4 #buffer
|
||||
jsr p2cstr
|
||||
ply
|
||||
phx ;for c2gsstr
|
||||
pha
|
||||
sta matchbuf,y
|
||||
txa
|
||||
pha Hold offset on stack.
|
||||
iny Get length of name + 1
|
||||
pea 0
|
||||
phy
|
||||
jsl ~NEW Request memory to hold name.
|
||||
ply Get matchbuf offset from stack.
|
||||
sta matchbuf,y Store allocated memory's
|
||||
txa address in matchbuf array.
|
||||
sta matchbuf+2,y
|
||||
jsr c2gsstr
|
||||
phx ;for nullfree
|
||||
|
||||
ph4 #NameText Copy string from
|
||||
lda matchbuf+2,y name buffer into
|
||||
pha matchbuf table entry.
|
||||
lda matchbuf,y
|
||||
pha
|
||||
sta GFName
|
||||
stx GFName+2
|
||||
sta 4
|
||||
stx 6
|
||||
GetFileInfo GFParm
|
||||
jsl nullfree
|
||||
lda cmdflag
|
||||
jsr copycstr
|
||||
|
||||
lda cmdflag Are we looking for a command?
|
||||
beq fm01
|
||||
lda GFType
|
||||
cmp #$0F
|
||||
beq isdir
|
||||
cmp #$B5
|
||||
beq notdir
|
||||
cmp #$B3
|
||||
beq notdir
|
||||
cmp #$B0
|
||||
bne filematch
|
||||
lda GFAux
|
||||
cmp #6
|
||||
bne filematch
|
||||
lda GFAux+2
|
||||
bne filematch
|
||||
bra notdir
|
||||
fm01 lda GFType
|
||||
lda nwType Yes: Get the file's type
|
||||
cmp #$0F == $0F?
|
||||
beq isdir it's a directory
|
||||
cmp #$B5 == $B5?
|
||||
beq notdir it's EXE (shell executable)
|
||||
cmp #$B3 == $B3?
|
||||
beq notdir it's S16 (GS/OS application)
|
||||
cmp #$B0 == $B0?
|
||||
bne filematch it's SRC (shell source code)
|
||||
lda nwAux Get file's aux type
|
||||
cmp #6 == $00000006?
|
||||
bne filematch
|
||||
lda nwAux+2
|
||||
bne filematch No; try next wildcard.
|
||||
bra notdir It's shell cmd file.
|
||||
;
|
||||
; Not looking for a command
|
||||
;
|
||||
fm01 lda nwType
|
||||
cmp #$0F
|
||||
bne notdir
|
||||
;
|
||||
; File type is $0F: it's a directory
|
||||
;
|
||||
isdir lda nummatch
|
||||
asl a
|
||||
asl a
|
||||
@ -1271,8 +1260,7 @@ isdir lda nummatch
|
||||
sta 0
|
||||
lda matchbuf+2,x
|
||||
sta 2
|
||||
lda buffer
|
||||
and #$FF
|
||||
lda NameLen Allocate NameLen+2 bytes of memory
|
||||
inc a
|
||||
inc a
|
||||
pea 0
|
||||
@ -1292,15 +1280,13 @@ isdir lda nummatch
|
||||
pei (2)
|
||||
pei (0)
|
||||
jsl nullfree
|
||||
lda buffer
|
||||
and #$FF
|
||||
tay
|
||||
ldy NameLen
|
||||
lda sepstyle
|
||||
sta [8],y
|
||||
|
||||
notdir anop
|
||||
inc nummatch
|
||||
jmp filematch
|
||||
inc nummatch Bump the match count.
|
||||
jmp filematch Try next wildcard.
|
||||
|
||||
filemdone anop
|
||||
lda cmdflag ;if it's not a command, we're done
|
||||
@ -1313,17 +1299,17 @@ q equ 4
|
||||
|
||||
ldy wordlen ;remove '*' from above
|
||||
lda #0
|
||||
sta wordbuf,y
|
||||
sta wordgs_text,y
|
||||
|
||||
lda hash_table
|
||||
ora hash_table+2
|
||||
beq endhash
|
||||
beq eq_endhash
|
||||
mv4 hash_table,p
|
||||
lda hash_numexe
|
||||
beq endhash
|
||||
ldy #0
|
||||
ldx t_size
|
||||
beq endhash
|
||||
eq_endhash beq endhash
|
||||
;
|
||||
; loop through every hashed file and add it the string vector
|
||||
;
|
||||
@ -1337,8 +1323,8 @@ hashloop lda [p],y
|
||||
iny
|
||||
ora q
|
||||
beq nexthash
|
||||
inc q
|
||||
inc q
|
||||
incad q
|
||||
incad q
|
||||
phy
|
||||
phx
|
||||
pei (q+2)
|
||||
@ -1348,7 +1334,7 @@ hashloop lda [p],y
|
||||
bcc nexthash0
|
||||
tax
|
||||
ldy #0
|
||||
hl lda wordbuf,y
|
||||
hl lda wordgs_text,y
|
||||
and #$FF
|
||||
beq hl0
|
||||
jsr tolower
|
||||
@ -1400,7 +1386,7 @@ bilup lda [p]
|
||||
bcc binext
|
||||
tax
|
||||
ldy #0
|
||||
bl lda wordbuf,y
|
||||
bl lda wordgs_text,y
|
||||
and #$FF
|
||||
beq bl0
|
||||
eor [q],y
|
||||
@ -1435,27 +1421,52 @@ done rts
|
||||
startpos ds 2
|
||||
cmdflag ds 2
|
||||
|
||||
iwparm dc i4'wordpbuf'
|
||||
dc i2'1'
|
||||
;
|
||||
; GS/OS string holding match word + wildcard "*"
|
||||
;
|
||||
wordgsbuf ds 2
|
||||
wordgs_text ds 256
|
||||
|
||||
nwparm dc i4'buffer'
|
||||
;
|
||||
; Parameter block for shell InitWildcardGS call (p 414 in ORCA/M manual)
|
||||
;
|
||||
iwparm dc i2'2' pCount
|
||||
dc i4'wordgsbuf' pathname with wildcard
|
||||
iwFlags dc i2'1' flags
|
||||
|
||||
GFParm dc i2'4'
|
||||
GFName dc i4'0'
|
||||
dc i2'0'
|
||||
GFType dc i2'0'
|
||||
GFAux dc i4'0'
|
||||
;
|
||||
; Parameter block for shell NextWildcardGS call (p 414 in ORCA/M manual)
|
||||
;
|
||||
nwparm dc i2'4' pCount
|
||||
dc i4'NameBuf' pathName
|
||||
dc i2'0' access
|
||||
nwType dc i2'0' fileType
|
||||
nwAux dc i4'0' auxType
|
||||
|
||||
|
||||
; Parameter block for shell Read_Indexed call
|
||||
; [predecessor to ReadIndexedGS call (p 421 in ORCA/M manual)]
|
||||
varParm anop
|
||||
dc i4'buffer' Name (pointer to 256-byte p-string)
|
||||
dc i4'varval' Value (pointer to 256-byte p-string)
|
||||
varIndex dc i2'0' Index number
|
||||
|
||||
ds 1 ;<- don't futz with me!!
|
||||
varval ds 256
|
||||
;
|
||||
; Parameter block for shell ReadIndexedGS call (p 421 in ORCA/M manual)
|
||||
;
|
||||
idxParm anop
|
||||
dc i2'4' pCount
|
||||
dc i4'NameBuf' Name (pointer to GS/OS result buf)
|
||||
dc i4'ResultBuf' Value (pointer to GS/OS result buf)
|
||||
idxIndex ds 2 Index number
|
||||
ds 2 Export flag
|
||||
;
|
||||
; GS/OS result buffer to hold name: maximum size = 255 bytes
|
||||
;
|
||||
NameBuf dc i2'259' Total length of result buf.
|
||||
NameLen ds 2 Name's length returned here.
|
||||
NameText ds 255 Text goes here.
|
||||
ds 2 Room for terminating null bytes.
|
||||
;
|
||||
; GS/OS result buffer for testing whether a variable is defined.
|
||||
; It doesn't have enough room for > 1 byte to be returned, but we
|
||||
; only need to get the length of the value.
|
||||
;
|
||||
ResultBuf dc i2'5' Only five bytes total.
|
||||
ds 2 Value's length returned here.
|
||||
ds 1 Only 1 byte for value.
|
||||
|
||||
sepstyle ds 2
|
||||
|
||||
@ -1944,9 +1955,7 @@ numloop asl ch
|
||||
|
||||
casebreak lda ch
|
||||
casebreak0 sta [cp]
|
||||
inc cp
|
||||
jne loop
|
||||
inc cp+2
|
||||
incad cp
|
||||
jmp loop
|
||||
|
||||
breakloop lda #0
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: expand.asm,v 1.3 1998/06/30 17:25:27 tribby Exp $
|
||||
* $Id: expand.asm,v 1.4 1998/07/20 16:23:03 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -219,7 +219,7 @@ globword stz filesep
|
||||
sta exppath
|
||||
stx exppath+2
|
||||
|
||||
inc eptr ;leave room for pascal length
|
||||
incad eptr ;leave room for pascal length
|
||||
mv4 eptr,sepptr
|
||||
|
||||
ldy #0
|
||||
@ -233,11 +233,11 @@ exploop lda [wordbuf],y
|
||||
if2 @a,eq,#'/',expsep
|
||||
if2 @a,eq,#':',expsep
|
||||
expput sta [eptr]
|
||||
inc eptr
|
||||
incad eptr
|
||||
bra exploop
|
||||
expsep sty filesep
|
||||
sta [eptr]
|
||||
inc eptr
|
||||
incad eptr
|
||||
mv4 eptr,sepptr
|
||||
bra exploop
|
||||
expslash lda [wordbuf],y
|
||||
@ -251,7 +251,7 @@ expsingle lda [wordbuf],y
|
||||
beq endexp
|
||||
if2 @a,eq,#"'",exploop
|
||||
sta [eptr]
|
||||
inc eptr
|
||||
incad eptr
|
||||
bra expsingle
|
||||
expdouble lda [wordbuf],y
|
||||
iny
|
||||
@ -259,7 +259,7 @@ expdouble lda [wordbuf],y
|
||||
beq endexp
|
||||
if2 @a,eq,#'"',exploop
|
||||
sta [eptr]
|
||||
inc eptr
|
||||
incad eptr
|
||||
bra expdouble
|
||||
;
|
||||
; We really didn't mean to expand the filename, so, copy it back again..
|
||||
@ -269,7 +269,7 @@ copyback lda [wordbuf],y
|
||||
iny
|
||||
and #$FF
|
||||
sta [sepptr]
|
||||
inc sepptr
|
||||
incad sepptr
|
||||
cmp #0
|
||||
bne copyback
|
||||
;
|
||||
@ -393,7 +393,7 @@ bye return 4:buf
|
||||
; Subroutine of glob: get a byte from the original command-line
|
||||
;
|
||||
g_getbyte lda [cmd]
|
||||
inc cmd
|
||||
incad cmd
|
||||
and #$FF
|
||||
rts
|
||||
|
||||
@ -419,21 +419,21 @@ special pha
|
||||
;
|
||||
; Subroutine of glob: store a byte into the new command-line
|
||||
;
|
||||
g_putbyte short a
|
||||
sta [ptr]
|
||||
long a
|
||||
inc ptr
|
||||
rts
|
||||
g_putbyte short a
|
||||
sta [ptr]
|
||||
long a
|
||||
incad ptr
|
||||
rts
|
||||
|
||||
|
||||
glob_mutex key
|
||||
|
||||
; Parameter block for InitWildcard shell call (ORCA/M pp 414-415)
|
||||
InitWCParm ds 4 Path name, with wildcard
|
||||
dc i2'%00000001' Flags (this bit not documented!!!)
|
||||
InitWCParm ds 4 Path name, with wildcard
|
||||
dc i2'%00000001' Flags (this bit not documented!!!)
|
||||
|
||||
; Parameter block for NextWildcard shell call (ORCA/M pp 417-418)
|
||||
nWCparm ds 4 Pointer to returned path name
|
||||
nWCparm ds 4 Pointer to returned path name
|
||||
|
||||
nomatch dc c'No match: ',h'00'
|
||||
ignored dc c' ignored',h'0d00'
|
||||
@ -444,13 +444,14 @@ ignored dc c' ignored',h'0d00'
|
||||
*
|
||||
* Expand $variables and tildes not in single quotes
|
||||
*
|
||||
* * Add error checking if out buf gets too big (> 1024)
|
||||
* * Get rid of fixed buffers
|
||||
*
|
||||
**************************************************************************
|
||||
|
||||
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
|
||||
@ -536,6 +537,8 @@ nameloop lda [cmd]
|
||||
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
|
||||
@ -550,6 +553,8 @@ braceloop lda [cmd]
|
||||
beq getval
|
||||
jsr e_getbyte
|
||||
if2 @a,eq,#'}',getval
|
||||
cpx #255 Only the first 255 characters
|
||||
beq braceloop are significant.
|
||||
sta name,x
|
||||
inx
|
||||
bra braceloop
|
||||
@ -558,83 +563,77 @@ braceloop lda [cmd]
|
||||
; get text from standard input
|
||||
;
|
||||
stdinexpand jsr e_getbyte
|
||||
ReadLine (#value+1,#255,#13,#1),@a
|
||||
ReadLine (#value,#MAXVAL,#13,#1),@a
|
||||
sta valueln
|
||||
bra chklen
|
||||
|
||||
;
|
||||
; get a value for this variable
|
||||
; Get a value for this variable
|
||||
;
|
||||
getval lda #0
|
||||
sta name,x
|
||||
ph4 #name
|
||||
jsr c2pstr2
|
||||
phx
|
||||
pha
|
||||
sta parm
|
||||
stx parm+2
|
||||
Read_Variable parm
|
||||
jsl nullfree
|
||||
getval stx nameln Save length of name.
|
||||
ReadVariableGS ReadVarPB Read its value.
|
||||
|
||||
lda value Get length
|
||||
chklen and #$FF byte.
|
||||
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
|
||||
tax Save length in X-reg.
|
||||
lda dflag If delimiter flag isn't set,
|
||||
beq storeval go store the variable value
|
||||
|
||||
; Check to see if delimiters in the variable need to be switched
|
||||
lda value Set up length
|
||||
and #$FF byte in
|
||||
tax X-reg and
|
||||
lda [cmd] Get next command line
|
||||
and #$FF character.
|
||||
lda valueln Set up length in
|
||||
tax X-reg and get
|
||||
lda [cmd] next command line
|
||||
and #$FF character.
|
||||
cmp #"/" If it's a slash, see if
|
||||
beq chkvarslash variable needs to convert to slash.
|
||||
cmp #":" If it's not a colon,
|
||||
bne storeval no need to convert.
|
||||
lda value+1 Get first character of value.
|
||||
lda value Get first character of value.
|
||||
and #$FF
|
||||
cmp #"/" If it's not a slash,
|
||||
bne storeval no need to convert.
|
||||
|
||||
; Convert variable from "/" to ":" delimiter
|
||||
short m
|
||||
chk_s lda value,x
|
||||
chk_s lda value-1,x
|
||||
cmp #"/"
|
||||
bne bump_s
|
||||
lda #":"
|
||||
sta value,x
|
||||
sta value-1,x
|
||||
bump_s dex
|
||||
bpl chk_s
|
||||
long m
|
||||
bra storeval
|
||||
|
||||
chkvarslash anop
|
||||
lda value+1 Get first character of value.
|
||||
lda value Get first character of value.
|
||||
and #$FF
|
||||
cmp #":" If it's not a colon,
|
||||
bne storeval no need to convert.
|
||||
|
||||
; Convert variable from ":" to "/" delimiter
|
||||
short m
|
||||
chk_c lda value,x
|
||||
chk_c lda value-1,x
|
||||
cmp #":"
|
||||
bne bump_c
|
||||
lda #"/"
|
||||
sta value,x
|
||||
sta value-1,x
|
||||
bump_c dex
|
||||
bpl chk_c
|
||||
long m
|
||||
|
||||
;
|
||||
; store the variable value in the out buffer
|
||||
; Store the variable's value in the out buffer
|
||||
;
|
||||
storeval anop
|
||||
lda value Get length
|
||||
and #$FF byte.
|
||||
lda valueln Get length.
|
||||
tay Save length in Y-reg.
|
||||
ldx #0 Use X-reg in index value.
|
||||
putval lda value+1,x
|
||||
putval lda value,x
|
||||
jsr e_putbyte
|
||||
inx
|
||||
dey
|
||||
@ -662,24 +661,38 @@ done jsr e_putbyte
|
||||
tya
|
||||
rtl
|
||||
|
||||
e_getbyte lda [cmd]
|
||||
inc cmd
|
||||
and #$FF
|
||||
rts
|
||||
e_getbyte lda [cmd]
|
||||
incad cmd
|
||||
and #$FF
|
||||
rts
|
||||
|
||||
e_putbyte short a
|
||||
sta [ptr]
|
||||
long a
|
||||
inc ptr
|
||||
e_putbyte short a
|
||||
sta [ptr]
|
||||
long a
|
||||
incad ptr
|
||||
rts
|
||||
|
||||
exp_mutex key
|
||||
|
||||
; Parameter block for ReadVariable shell call
|
||||
parm dc a4'name'
|
||||
dc a4'value'
|
||||
|
||||
name ds 256
|
||||
value ds 256
|
||||
; GS/OS string to hold variable name
|
||||
namestr anop
|
||||
nameln ds 2 Length of name
|
||||
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
|
||||
|
||||
|
||||
; Parameter block for shell ReadVariableGS calls
|
||||
ReadVarPB anop
|
||||
dc i2'3' pCount
|
||||
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
|
||||
|
2909
bin/gsh/gsh.mac
2909
bin/gsh/gsh.mac
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Resources for version and comment
|
||||
*
|
||||
* $Id: gsh.rez,v 1.2 1998/06/30 17:25:33 tribby Exp $
|
||||
* $Id: gsh.rez,v 1.3 1998/07/20 16:23:06 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 */
|
||||
1 }, /* non-final release number */
|
||||
2 }, /* non-final release number */
|
||||
verUS, /* Country */
|
||||
PROG, /* Program name */
|
||||
DESC
|
||||
@ -30,6 +30,6 @@ resource rVersion (1, purgeable3) {
|
||||
resource rComment (1, purgeable3) {
|
||||
PROG " v2.0\n"
|
||||
DESC
|
||||
"Written by Tim Meekins.\n"
|
||||
"Written by Tim Meekins. Updated by Dave Tribby\n"
|
||||
BUILD_DATE
|
||||
};
|
||||
|
526
bin/gsh/hash.asm
526
bin/gsh/hash.asm
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: hash.asm,v 1.3 1998/06/30 17:25:34 tribby Exp $
|
||||
* $Id: hash.asm,v 1.4 1998/07/20 16:23:06 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -57,16 +57,27 @@ dummyhash start ; ends up in .root
|
||||
C1 gequ 11
|
||||
C2 gequ 13
|
||||
TAB_MULT gequ 4
|
||||
|
||||
;
|
||||
; Structure for filenames
|
||||
;
|
||||
; struct filenode {
|
||||
; short dirnum;
|
||||
; char name[32];
|
||||
; filenode *next;
|
||||
; };
|
||||
fn_dirNum gequ 0
|
||||
fn_name gequ fn_dirNum+2
|
||||
fn_next gequ fn_name+32
|
||||
fn_size gequ fn_next+4
|
||||
|
||||
;
|
||||
; Structure for hash table
|
||||
;
|
||||
; struct tablenode {
|
||||
; short dirnum;
|
||||
; char *name[32];
|
||||
; };
|
||||
tn_dirNum gequ 0
|
||||
tn_name gequ tn_dirNum+2
|
||||
tn_size gequ tn_name+32
|
||||
@ -259,23 +270,29 @@ hashloop pei (files+2)
|
||||
tay
|
||||
lda [table],y
|
||||
tax
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
ora [table],y
|
||||
beq gotit
|
||||
|
||||
; let's see if it's the same, skip if so...
|
||||
; If it's the same name, skip the duplicate entry
|
||||
|
||||
; pei (files+2)
|
||||
; lda files
|
||||
; inc a
|
||||
; inc a
|
||||
; pha
|
||||
; lda [table],y
|
||||
; pha
|
||||
; phx
|
||||
; jsr cmpcstr
|
||||
; beq mainloop
|
||||
ldy h Calculate address
|
||||
clc of hash entry's
|
||||
lda [table],y name field.
|
||||
adc #tn_name
|
||||
tax
|
||||
iny2
|
||||
lda [table],y
|
||||
adc #0
|
||||
pha High-order word of address.
|
||||
phx Low-order word of address.
|
||||
pei (files+2)
|
||||
lda files
|
||||
inc a
|
||||
inc a
|
||||
pha
|
||||
jsr cmpcstr
|
||||
beq mainloop
|
||||
|
||||
inc qh
|
||||
bra hashloop
|
||||
@ -361,64 +378,70 @@ end equ file+4
|
||||
tcd
|
||||
|
||||
stz qh
|
||||
stz full_path
|
||||
stz full_path Set result to NULL.
|
||||
stz full_path+2
|
||||
|
||||
lda table
|
||||
ora table+2
|
||||
jeq done
|
||||
lda table If hash table hasn't
|
||||
ora table+2 been allocated,
|
||||
jeq done return null string.
|
||||
|
||||
pei (file+2)
|
||||
pei (file)
|
||||
jsr lowercstr
|
||||
mainloop pei (file+2)
|
||||
mainloop pei (file+2) Get hash(qh,file)
|
||||
pei (file)
|
||||
pei (qh)
|
||||
jsr hash
|
||||
asl a
|
||||
asl a Multiply by 4
|
||||
asl a
|
||||
tay
|
||||
lda [table],y
|
||||
tay Use as index into table.
|
||||
lda [table],y ptr = table[hash(qh,file)]
|
||||
sta ptr
|
||||
tax
|
||||
iny
|
||||
iny
|
||||
ora [table],y
|
||||
jeq done
|
||||
ora [table],y If == 0,
|
||||
jeq done all done.
|
||||
|
||||
lda [table],y
|
||||
sta ptr+2
|
||||
|
||||
pei (file+2)
|
||||
pei (file)
|
||||
pha ;ptr+2
|
||||
inx ;ptr + #2
|
||||
inx
|
||||
phx
|
||||
jsr cmpcstr
|
||||
jsr cmpcstr Compare filename against entry.
|
||||
beq found
|
||||
inc qh
|
||||
bra mainloop
|
||||
|
||||
;
|
||||
; Found an entry that matches the filename. Calculate full path.
|
||||
;
|
||||
found lda [ptr]
|
||||
asl a
|
||||
asl a
|
||||
ldx paths+2
|
||||
adc paths ;(cf=0)
|
||||
stx ptr+2
|
||||
sta ptr
|
||||
ldx paths+2
|
||||
stx ptr+2
|
||||
ldy #2
|
||||
lda [ptr],y
|
||||
pha
|
||||
lda [ptr]
|
||||
pha
|
||||
jsr cstrlen
|
||||
jsr cstrlen Get length of path.
|
||||
pha
|
||||
clc
|
||||
adc #33
|
||||
adc #33 Add 33 (max prog name size + 1)
|
||||
pea 0
|
||||
pha
|
||||
jsl ~NEW
|
||||
sta full_path
|
||||
stx full_path+2
|
||||
jsl ~NEW Allocate memory,
|
||||
sta full_path storing address at
|
||||
stx full_path+2 functional return value.
|
||||
|
||||
ldy #2
|
||||
lda [ptr],y
|
||||
pha
|
||||
@ -426,7 +449,8 @@ found lda [ptr]
|
||||
pha
|
||||
pei (full_path+2)
|
||||
pei (full_path)
|
||||
jsr copycstr
|
||||
jsr copycstr Copy pathname into buffer.
|
||||
|
||||
pla ;length of path
|
||||
pei (file+2)
|
||||
pei (file)
|
||||
@ -434,10 +458,12 @@ found lda [ptr]
|
||||
clc
|
||||
adc full_path
|
||||
pha
|
||||
jsr copycstr
|
||||
jsr copycstr Put filename at end of pathname.
|
||||
|
||||
done ldx full_path+2
|
||||
done ldx full_path+2 Load return value into Y- & X- regs
|
||||
ldy full_path
|
||||
|
||||
; Adjust stack in preparation for return
|
||||
lda space
|
||||
sta end-3
|
||||
lda space+1
|
||||
@ -448,7 +474,8 @@ done ldx full_path+2
|
||||
adc #end-4
|
||||
tcs
|
||||
|
||||
tya
|
||||
tya A- & X- regs contain ptr (or NULL)
|
||||
|
||||
rtl
|
||||
|
||||
END
|
||||
@ -538,101 +565,124 @@ space equ ptr+4
|
||||
|
||||
subroutine (4:dir,2:dirNum,4:files),space
|
||||
;
|
||||
; Open directory
|
||||
; Open directory name passed as 1st parameter
|
||||
;
|
||||
ld2 3,ORec
|
||||
pei (dir+2) ;copy this string
|
||||
pei (dir)
|
||||
jsr c2gsstr
|
||||
pei (dir+2) Turn "dir" c-string into
|
||||
pei (dir) a GS/OS string, allocated
|
||||
jsr c2gsstr via ~NEW.
|
||||
sta ORecPath
|
||||
stx ORecPath+2
|
||||
phx
|
||||
pha
|
||||
Open ORec
|
||||
bcc goodopen
|
||||
jsl nullfree
|
||||
jmp exit
|
||||
phx Put GS/OS string addr on stack
|
||||
pha so it can be deallocated.
|
||||
Open ORec Open that file.
|
||||
bcc goodopen If there was an error,
|
||||
jsl nullfree Free the GS/OS string
|
||||
jmp exit and exit.
|
||||
|
||||
goodopen jsl nullfree
|
||||
mv2 ORecRef,DRecRef
|
||||
stz DRecBase
|
||||
stz DRecDisp
|
||||
jsl alloc256
|
||||
sta DRecName
|
||||
sta ptr
|
||||
goodopen jsl nullfree Free the GS/OS string.
|
||||
|
||||
;
|
||||
; Set up parameter block for GetDirEntry
|
||||
;
|
||||
mv2 ORecRef,DRecRef Copy the file ref num from open.
|
||||
stz DRecBase Zero the base and
|
||||
stz DRecDisp displacement.
|
||||
jsl alloc256 Get 256 bytes for name.
|
||||
sta DRecName Store address in param block
|
||||
sta ptr and also in direct page var.
|
||||
stx DRecName+2
|
||||
stx ptr+2
|
||||
lda #254 Set total length of GS/OS buffer in
|
||||
sta [ptr] bufsize word (save byte for 0 at end).
|
||||
GetDirEntry DRec Make DirEntry call.
|
||||
|
||||
lda #254 ;Output buffer size (GT never did this?)
|
||||
sta [ptr]
|
||||
GetDirEntry DRec
|
||||
mv2 DRecEntry,numEntries
|
||||
mv2 DRecEntry,numEntries Save number of entries.
|
||||
ld2 1,(DRecBase,DRecDisp)
|
||||
stz entry
|
||||
stz entry # processed entries = 0.
|
||||
|
||||
loop lda entry
|
||||
cmp numEntries
|
||||
jge done
|
||||
loop lda entry If number of processed entries
|
||||
cmp numEntries equals the total number,
|
||||
jge done we are all done.
|
||||
GetDirEntry DRec
|
||||
|
||||
; Check for filetype $B3: GS/OS Application (S16)
|
||||
if2 DRecFileType,eq,#$B3,goodfile
|
||||
|
||||
; Check for filetype $B5: GS/OS Shell Application (EXE)
|
||||
if2 @a,eq,#$B5,goodfile
|
||||
|
||||
; Check for filetype $B0, subtype $0006: Shell command file (EXEC)
|
||||
cmp #$B0
|
||||
jne nextfile
|
||||
bne nextfile
|
||||
lda DRecAuxType
|
||||
cmp #$06
|
||||
jne nextfile
|
||||
bne nextfile
|
||||
lda DRecAuxType+2
|
||||
jne nextfile
|
||||
goodfile inc hash_numexe
|
||||
ldy #2
|
||||
lda [ptr],y
|
||||
add2 @a,#4,@y
|
||||
lda #0
|
||||
sta [ptr],y
|
||||
bne nextfile
|
||||
;
|
||||
; This directory entry points to an executable file.
|
||||
; Included it in the file list.
|
||||
;
|
||||
goodfile inc hash_numexe Bump the (global) # files.
|
||||
ldy #2 Get length word from GS/OS string
|
||||
lda [ptr],y in result buffer.
|
||||
add2 @a,#4,@y Use length + 4 as index
|
||||
lda #0 to store terminating
|
||||
sta [ptr],y null byte.
|
||||
add2 ptr,#4,@a
|
||||
pei (ptr+2) ;for copycstr
|
||||
pha
|
||||
pei (ptr+2)
|
||||
pha
|
||||
jsr lowercstr
|
||||
jsr lowercstr Convert name to lower case.
|
||||
|
||||
ldy #fn_next
|
||||
ldy #fn_next temp = files->next.
|
||||
lda [files],y
|
||||
sta temp
|
||||
ldy #fn_next+2
|
||||
lda [files],y
|
||||
sta temp+2
|
||||
ph4 #fn_size
|
||||
|
||||
ph4 #fn_size temp2 = new entry.
|
||||
jsl ~NEW
|
||||
sta temp2
|
||||
stx temp2+2
|
||||
ldy #fn_next
|
||||
|
||||
ldy #fn_next files->next = temp2
|
||||
sta [files],y
|
||||
ldy #fn_next+2
|
||||
txa
|
||||
pha
|
||||
sta [files],y
|
||||
|
||||
lda temp2
|
||||
clc
|
||||
adc #fn_name
|
||||
pha
|
||||
jsr copycstr
|
||||
lda dirNum
|
||||
sta [temp2]
|
||||
ldy #fn_next
|
||||
|
||||
lda dirNum temp2->dirnum = dirNum
|
||||
sta [temp2]
|
||||
|
||||
ldy #fn_next temp2->next = temp
|
||||
lda temp
|
||||
sta [temp2],y
|
||||
sta [temp2],y
|
||||
ldy #fn_next+2
|
||||
lda temp+2
|
||||
sta [temp2],y
|
||||
|
||||
nextfile inc entry
|
||||
jmp loop
|
||||
nextfile inc entry Bump entry number
|
||||
jmp loop and stay in the loop.
|
||||
|
||||
done ldx DRecName+2
|
||||
;
|
||||
; Done adding entries to the hash table from this directory
|
||||
;
|
||||
done ldx DRecName+2 Free the Name buffer.
|
||||
lda DRecName
|
||||
jsl free256
|
||||
ld2 1,ORec
|
||||
|
||||
ld2 1,ORec ORec.pCount = 1
|
||||
Close ORec
|
||||
|
||||
exit return
|
||||
@ -671,13 +721,17 @@ DRecAuxType ds 4 auxType
|
||||
hashpath START
|
||||
|
||||
using hashdata
|
||||
using vardata
|
||||
|
||||
len equ 1
|
||||
pathnum equ len+2
|
||||
ptr equ pathnum+2
|
||||
files equ ptr+4
|
||||
pathptr equ files+4
|
||||
space equ pathptr+4
|
||||
qflag equ pathptr+4
|
||||
qptr equ qflag+2
|
||||
gsosbuf equ qptr+4
|
||||
space equ gsosbuf+4
|
||||
end equ space+3
|
||||
|
||||
;
|
||||
@ -689,8 +743,10 @@ end equ space+3
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
|
||||
lock hashmutex
|
||||
;
|
||||
; allocate special file node
|
||||
; Allocate special file node
|
||||
;
|
||||
ph4 #fn_size
|
||||
jsl ~NEW
|
||||
@ -699,15 +755,18 @@ end equ space+3
|
||||
stx hash_files+2
|
||||
stx files+2
|
||||
|
||||
;
|
||||
; Allocate memory for ExpandPath GS/OS result string
|
||||
;
|
||||
jsl alloc256
|
||||
sta EPParm+6
|
||||
stx EPParm+6+2
|
||||
sta EPoutputPath
|
||||
stx EPoutputPath+2
|
||||
sta ptr
|
||||
stx ptr+2
|
||||
lda #254
|
||||
sta [ptr]
|
||||
;
|
||||
; initialize counters and pointers
|
||||
; Initialize counters and pointers
|
||||
;
|
||||
lda #0
|
||||
sta hash_numexe
|
||||
@ -720,37 +779,38 @@ end equ space+3
|
||||
sta [files],y
|
||||
sta [files]
|
||||
;
|
||||
; allocate memory for $path variable
|
||||
; Determine length of $PATH environment variable string
|
||||
;
|
||||
jsl alloc256
|
||||
sta pathvalue
|
||||
stx pathvalue+2
|
||||
phx
|
||||
pha
|
||||
phx
|
||||
pha
|
||||
;
|
||||
; read $PATH
|
||||
;
|
||||
Read_Variable pathparm
|
||||
ph4 #pathname
|
||||
jsl getenv
|
||||
sta gsosbuf Save address of allocated buffer.
|
||||
stx gsosbuf+2
|
||||
ora gsosbuf+2 If null,
|
||||
bne setptr
|
||||
ldx #^nopatherr print error message
|
||||
lda #nopatherr
|
||||
jsr errputs
|
||||
jmp noprint and exit.
|
||||
|
||||
setptr clc Add 4 bytes to
|
||||
lda gsosbuf direct page pointer
|
||||
adc #4 to get the addr of
|
||||
sta pathptr beginning of text.
|
||||
lda gsosbuf+2
|
||||
adc #0
|
||||
sta pathptr+2
|
||||
|
||||
jsr p2cstr
|
||||
stx pathptr+2
|
||||
sta pathptr
|
||||
stx pathvalue+2 ;for disposal only
|
||||
sta pathvalue
|
||||
pla
|
||||
plx
|
||||
jsl free256 ;pushed earlier
|
||||
;
|
||||
; begin parsing $path
|
||||
; Begin parsing $PATH
|
||||
;
|
||||
loop lda [pathptr]
|
||||
and #$FF
|
||||
jeq done
|
||||
jeq pathdone
|
||||
;
|
||||
; parse next pathname
|
||||
;
|
||||
stz qflag Clear quote flag for this path
|
||||
|
||||
mv4 pathptr,ptr
|
||||
ldy #0
|
||||
despace lda [pathptr],y
|
||||
@ -764,15 +824,19 @@ despace lda [pathptr],y
|
||||
bra despace
|
||||
|
||||
; Found "\"
|
||||
gotquote iny2
|
||||
gotquote anop
|
||||
iny2
|
||||
ldx qflag If quote flag hasn't already been set,
|
||||
bne despace
|
||||
sty qflag set it to index of first "\" + 2.
|
||||
bra despace
|
||||
|
||||
; Found null byte
|
||||
gotspace0 tyx
|
||||
gotspace0 tyx Why put Y-reg in X???
|
||||
bra gotspace3
|
||||
|
||||
; Found " ", tab, or creturn
|
||||
gotspace1 tyx
|
||||
gotspace1 tyx Why put Y-reg in X???
|
||||
short a
|
||||
lda #0
|
||||
sta [pathptr],y
|
||||
@ -799,25 +863,67 @@ gotspace3 anop
|
||||
ldx #^toomanyerr
|
||||
lda #toomanyerr
|
||||
jsr errputs
|
||||
jmp done
|
||||
jmp pathdone
|
||||
|
||||
;
|
||||
; Convert c string to GS/OS string (allocating space for it)
|
||||
;
|
||||
numok pei (ptr+2)
|
||||
pei (ptr)
|
||||
jsr c2gsstr
|
||||
phx
|
||||
pha
|
||||
sta EPinputPath
|
||||
stx EPinputPath+2
|
||||
ExpandPath EPParm
|
||||
phx Push allocated address onto
|
||||
pha stack for later deallocation.
|
||||
sta EPinputPath Save address in ExpandPath
|
||||
stx EPinputPath+2 parameter block.
|
||||
;
|
||||
; If any quoted characters were included, the "\" chars must be removed
|
||||
;
|
||||
ldy qflag Get quote flag (index to "\" char).
|
||||
beq xpandit If no "\", go ahead with expansion.
|
||||
|
||||
sta qptr Save EPinputPath pointer in
|
||||
stx qptr+2 direct page variable.
|
||||
lda [qptr] Store length + 2 (since we're indexing
|
||||
inc2 a from before length word) in qflag.
|
||||
sta qflag
|
||||
tyx X = index of 1st overwritten "\".
|
||||
short a Use 1-byte accumulator
|
||||
;
|
||||
; Copy characters toward front of string, removing "\" chars
|
||||
;
|
||||
chkloop2 lda [qptr],y Get next character.
|
||||
cmp #'\' If it's a quote,
|
||||
bne storeit
|
||||
lda [qptr] Decrement length.
|
||||
dec a
|
||||
sta [qptr]
|
||||
iny Skip over "\".
|
||||
lda [qptr],y Get character following.
|
||||
storeit phy Push source index onto stack
|
||||
txy so destination index can be
|
||||
sta [qptr],y used to store the character.
|
||||
ply Restore the source index.
|
||||
inx Bump destination and
|
||||
iny source index registers.
|
||||
cpy qflag If source index < length,
|
||||
bcc chkloop2 stay in copy loop.
|
||||
|
||||
long a Restore long accumulator.
|
||||
|
||||
;
|
||||
; Convert the input pathname into the corresponding
|
||||
; full pathname with colons as separators.
|
||||
;
|
||||
xpandit ExpandPath EPParm
|
||||
bcc epok
|
||||
|
||||
ldx #^eperrstr Print error message:
|
||||
lda #eperrstr "Invalid pathname syntax."
|
||||
jsr errputs
|
||||
jsl nullfree
|
||||
jmp next
|
||||
jsl nullfree Free GS/OS string (pushed earlier).
|
||||
jmp next Get the next one.
|
||||
|
||||
epok jsl nullfree
|
||||
epok jsl nullfree Free GS/OS string (addr on stack)
|
||||
|
||||
clc Set ptr to GS/OS string
|
||||
lda EPoutputPath portion of result buffer.
|
||||
@ -835,11 +941,10 @@ epok jsl nullfree
|
||||
lda #0
|
||||
sta [ptr],y
|
||||
|
||||
pea 0
|
||||
phy
|
||||
pea 0 Allocate memory the
|
||||
phy size of the expanded path.
|
||||
jsl ~NEW
|
||||
phx ;for dir_search
|
||||
pha
|
||||
|
||||
pei (ptr+2)
|
||||
inc2 ptr
|
||||
pei (ptr)
|
||||
@ -847,58 +952,122 @@ epok jsl nullfree
|
||||
pha
|
||||
sta ptr
|
||||
stx ptr+2
|
||||
|
||||
ldy pathnum
|
||||
sta hash_paths,y
|
||||
txa
|
||||
sta hash_paths+2,y
|
||||
sta hash_paths,y Store address of this
|
||||
txa path's address in the
|
||||
sta hash_paths+2,y hash path table.
|
||||
|
||||
jsr copycstr
|
||||
ldy len
|
||||
beq go4it
|
||||
beq bumppnum
|
||||
dey
|
||||
lda [ptr],y
|
||||
and #$FF
|
||||
cmp #':'
|
||||
beq go4it
|
||||
lda [ptr],y If last character
|
||||
and #$FF of path name
|
||||
cmp #':' isn't ":",
|
||||
beq bumppnum
|
||||
iny
|
||||
lda #':'
|
||||
sta [ptr],y
|
||||
iny
|
||||
lda #0
|
||||
sta [ptr],y
|
||||
lda #':' store ":\0"
|
||||
sta [ptr],y at end of string.
|
||||
|
||||
go4it lda pathnum
|
||||
lsr2 a
|
||||
pha
|
||||
pei (files+2)
|
||||
pei (files)
|
||||
jsl dir_search
|
||||
add2 pathnum,#4,pathnum
|
||||
bumppnum anop
|
||||
add2 pathnum,#4,pathnum Bump path pointer.
|
||||
next jmp loop Stay in loop.
|
||||
|
||||
next jmp loop
|
||||
;
|
||||
; The $PATH entries have been created. Now we need to search each of the
|
||||
; directories for executable files and add them to the "files" list.
|
||||
; The earliest versions of gsh added files to the list in the order that
|
||||
; directories appeared in $PATH, which put the earliest directories' files
|
||||
; at the end of the list. Check for existence of $OLDPATHMODE environment
|
||||
; variable to see if the user wants this, or would rather have them hashed
|
||||
; in the expected order.
|
||||
;
|
||||
pathdone anop
|
||||
lda varoldpmode
|
||||
beq neworder
|
||||
|
||||
;
|
||||
; Search directories and add executables to file list starting at the
|
||||
; beginning of $PATH and working to the end.
|
||||
;
|
||||
stz pathnum Start at beginning of path table.
|
||||
|
||||
nextpath1 ldy pathnum Get offset into hash table.
|
||||
cpy #32*4
|
||||
bcs filesdone
|
||||
lda hash_paths,y If address of this path
|
||||
ora hash_paths+2,y has not been set,
|
||||
beq filesdone all done.
|
||||
lda hash_paths,y Get address of this
|
||||
ldx hash_paths+2,y path's address in the
|
||||
phx hash path table.
|
||||
pha
|
||||
tya Directory number =
|
||||
lsr2 a offset / 4
|
||||
pha
|
||||
pei (files+2) Pointer to file list.
|
||||
pei (files)
|
||||
jsl dir_search Add executables from this directory.
|
||||
add2 pathnum,#4,pathnum Bump path offset.
|
||||
bra nextpath1
|
||||
|
||||
;
|
||||
; Search directories and add executables to file list starting at end
|
||||
; of $PATH and working back to the beginning. (Note: Loop begins at
|
||||
; "neworder", but structuring the code this ways saves an instruction.)
|
||||
;
|
||||
nextpath2 dey4 Decrement path offset.
|
||||
sty pathnum
|
||||
lda hash_paths,y Get address of this
|
||||
ldx hash_paths+2,y path's address in the
|
||||
phx hash path table.
|
||||
pha
|
||||
tya Directory number =
|
||||
lsr2 a offset / 4
|
||||
pha
|
||||
pei (files+2) Pointer to file list.
|
||||
pei (files)
|
||||
jsl dir_search Add executables from this directory.
|
||||
neworder ldy pathnum Get offset into hash table.
|
||||
bne nextpath2 When == 0, no more to do.
|
||||
|
||||
|
||||
done ph4 pathvalue
|
||||
jsl nullfree
|
||||
;
|
||||
; Executable files in $PATH have been added to the list. Print
|
||||
; number of files, then build the hash table.
|
||||
;
|
||||
filesdone anop
|
||||
ph4 gsosbuf Free memory allocated for
|
||||
jsl nullfree $PATH string.
|
||||
|
||||
lda hash_print
|
||||
beq noprint
|
||||
lda hash_print If this is the first time,
|
||||
beq noprint don't print the # of files.
|
||||
|
||||
Int2Dec (hash_numexe,#hashnum,#3,#0)
|
||||
ldx #^hashmsg
|
||||
lda #hashmsg
|
||||
jsr puts
|
||||
|
||||
noprint ld2 1,hash_print
|
||||
noprint ld2 1,hash_print Set print flag.
|
||||
|
||||
;
|
||||
; Free memory allocated for ExpandPath output string
|
||||
;
|
||||
lda EPoutputPath
|
||||
ldx EPoutputPath+2
|
||||
jsl free256
|
||||
|
||||
;
|
||||
; Create the hash table from the file list.
|
||||
;
|
||||
ph4 hash_files
|
||||
jsl dohash
|
||||
sta hash_table
|
||||
stx hash_table+2
|
||||
|
||||
lda EPoutputPath
|
||||
ldx EPoutputPath+2
|
||||
jsl free256
|
||||
|
||||
unlock hashmutex
|
||||
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
@ -907,12 +1076,9 @@ noprint ld2 1,hash_print
|
||||
|
||||
rtl
|
||||
|
||||
; Parameter block for shell call Read_Variable
|
||||
pathparm anop
|
||||
dc a4'pathvar' Address of name
|
||||
pathvalue ds 4 Address to store result
|
||||
hashmutex key Mutual exclusion key
|
||||
|
||||
pathvar str 'path'
|
||||
pathname gsstr 'path'
|
||||
|
||||
hashmsg dc c'hashed '
|
||||
hashnum dc c'000 files',h'0d00'
|
||||
@ -924,6 +1090,7 @@ EPoutputPath ds 4 ptr to outputPath (Result buffer)
|
||||
|
||||
eperrstr dc c'rehash: Invalid pathname syntax.',h'0d00'
|
||||
toomanyerr dc c'rehash: Too many paths specified.',h'0d00'
|
||||
nopatherr dc c'rehash: PATH string is not set.',h'0d00'
|
||||
|
||||
END
|
||||
|
||||
@ -940,23 +1107,24 @@ dispose_hash START
|
||||
ora2 hash_table,hash_table+2,@a
|
||||
beq done
|
||||
|
||||
ldx #32
|
||||
ldy #0
|
||||
loop1 phx
|
||||
phy
|
||||
lda hash_paths+2,y
|
||||
ldx #32 32 different paths, maximum
|
||||
ldy #0 Start looking at the first entry.
|
||||
|
||||
loop1 phx Save path counter
|
||||
phy and index.
|
||||
lda hash_paths+2,y Put address for this
|
||||
pha path table entry on
|
||||
lda hash_paths,y the stack.
|
||||
pha
|
||||
lda hash_paths,y
|
||||
pha
|
||||
lda #0
|
||||
lda #0 Zero out the table entry.
|
||||
sta hash_paths+2,y
|
||||
sta hash_paths,y
|
||||
jsl nullfree
|
||||
next1 ply
|
||||
plx
|
||||
iny4
|
||||
dex
|
||||
bne loop1
|
||||
jsl nullfree Free the entry's memory.
|
||||
next1 ply Restore path index
|
||||
plx and counter.
|
||||
iny4 Bump pointer to next address.
|
||||
dex If more paths to process,
|
||||
bne loop1 stay in the loop.
|
||||
|
||||
ph4 hash_files
|
||||
jsl free_files
|
||||
@ -980,12 +1148,12 @@ done rts
|
||||
|
||||
hashdata DATA
|
||||
|
||||
t_size ds 2
|
||||
t_size ds 2 t_size = (TAB_MULT * numexe) - 1
|
||||
|
||||
hash_paths dc 32i4'0' ;32 paths max for now.
|
||||
hash_paths dc 32i4'0' 32 paths max for now.
|
||||
hash_files dc i4'0'
|
||||
hash_table dc i4'0'
|
||||
hash_numexe dc i2'0'
|
||||
hash_print dc i2'0'
|
||||
hash_table dc i4'0' Pointer to table (t_size entries)
|
||||
hash_numexe dc i2'0' Number of hashed executables
|
||||
hash_print dc i2'0' Print flag; 0 first time through
|
||||
|
||||
END
|
||||
|
@ -6,12 +6,13 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: history.asm,v 1.3 1998/06/30 17:25:37 tribby Exp $
|
||||
* $Id: history.asm,v 1.4 1998/07/20 16:23:07 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
* HISTORY.ASM
|
||||
* By Tim Meekins
|
||||
* Modified by Dave Tribby for GNO 2.0.6
|
||||
*
|
||||
* Routines for dealing with history buffers.
|
||||
*
|
||||
@ -71,7 +72,8 @@ InsertHistory START
|
||||
ptr2 equ 0
|
||||
ptr equ ptr2+4
|
||||
len equ ptr+4
|
||||
space equ len+2
|
||||
histvalptr equ len+2
|
||||
space equ histvalptr+4
|
||||
|
||||
subroutine (4:cmd),space
|
||||
|
||||
@ -112,11 +114,33 @@ space equ len+2
|
||||
;
|
||||
putdone anop
|
||||
|
||||
Read_Variable RVParm
|
||||
lda buffer
|
||||
and #$FF
|
||||
beq alldone
|
||||
Dec2Int (#buffer+1,@a,#0),@a
|
||||
;
|
||||
; Get value of $HISTORY environment variable
|
||||
;
|
||||
ph4 #historyStr
|
||||
jsl getenv
|
||||
sta histvalptr Save pointer to GS/OS result buffer.
|
||||
stx histvalptr+2
|
||||
ora histvalptr+2 If buffer wasn't allocated,
|
||||
jeq goback all done.
|
||||
;
|
||||
; Call Dec2Int to convert value of string into an integer
|
||||
;
|
||||
pha Reserve room on stack for result.
|
||||
lda histvalptr Get pointer to $HISTORY value.
|
||||
ldx histvalptr+2
|
||||
clc Add 4 to address to skip
|
||||
adc #4 over length words.
|
||||
bcc pushaddr
|
||||
inx
|
||||
pushaddr phx Push address onto stack.
|
||||
pha
|
||||
ldy #2
|
||||
lda [histvalptr],y
|
||||
pha Push length.
|
||||
pea 0 Push signedFlag = 0 (unsigned)
|
||||
Tool $280b Dec2Int.
|
||||
pla Get result.
|
||||
sta size
|
||||
beq alldone
|
||||
;
|
||||
@ -165,10 +189,11 @@ dispose lda ptr2
|
||||
ldy #histNext+2
|
||||
bra dispose
|
||||
|
||||
alldone return
|
||||
alldone pei (histvalptr+2)
|
||||
pei (histvalptr)
|
||||
jsl nullfree
|
||||
|
||||
RVParm dc a4'historyStr'
|
||||
dc a4'buffer'
|
||||
goback return
|
||||
|
||||
size ds 2
|
||||
|
||||
@ -339,6 +364,11 @@ SaveHistory START
|
||||
using HistoryData
|
||||
using global
|
||||
|
||||
svhisvalptr equ 0
|
||||
space equ svhisvalptr+4
|
||||
|
||||
subroutine ,space
|
||||
|
||||
lda historyFN
|
||||
sta DestroyParm+2
|
||||
sta CreateParm+2
|
||||
@ -347,14 +377,35 @@ SaveHistory START
|
||||
sta DestroyParm+4
|
||||
sta CreateParm+4
|
||||
sta OpenParm+6
|
||||
|
||||
Read_Variable RVParm
|
||||
lda buffer
|
||||
and #$FF
|
||||
jeq done
|
||||
Dec2Int (#buffer+1,@a,#0),size
|
||||
lda size
|
||||
jeq done
|
||||
;
|
||||
; Get value of $SAVEHISTORY environment variable
|
||||
;
|
||||
ph4 #savehistStr
|
||||
jsl getenv
|
||||
sta svhisvalptr Save pointer to GS/OS result buffer.
|
||||
stx svhisvalptr+2
|
||||
ora svhisvalptr+2 If buffer wasn't allocated,
|
||||
jeq goback all done.
|
||||
;
|
||||
; Call Dec2Int to convert value of string into an integer
|
||||
;
|
||||
pha Reserve room on stack for result.
|
||||
lda svhisvalptr Get pointer to $HISTORY value.
|
||||
ldx svhisvalptr+2
|
||||
clc Add 4 to address to skip
|
||||
adc #4 over length words.
|
||||
bcc pushaddr
|
||||
inx
|
||||
pushaddr phx Push address onto stack.
|
||||
pha
|
||||
ldy #2
|
||||
lda [svhisvalptr],y
|
||||
pha Push length.
|
||||
pea 0 Push signedFlag = 0 (unsigned)
|
||||
Tool $280b Dec2Int
|
||||
pla Get result.
|
||||
sta size
|
||||
jeq done
|
||||
;
|
||||
; Create and write history to file
|
||||
;
|
||||
@ -400,10 +451,12 @@ next dec size
|
||||
|
||||
doneclose Close CloseParm
|
||||
|
||||
done rts
|
||||
done pei (svhisvalptr+2) Free $SAVEHISTORY value buffer
|
||||
pei (svhisvalptr)
|
||||
jsl nullfree
|
||||
|
||||
goback return
|
||||
|
||||
RVParm dc a4'savehistStr'
|
||||
dc a4'buffer'
|
||||
|
||||
DestroyParm dc i2'1'
|
||||
dc a4'historyFN'
|
||||
@ -587,15 +640,15 @@ count ds 2
|
||||
;
|
||||
;=========================================================================
|
||||
|
||||
HistoryData DATA
|
||||
HistoryData DATA
|
||||
|
||||
lasthist dc i2'0'
|
||||
numhist dc i2'0'
|
||||
currenthist ds 4
|
||||
historyptr dc i4'0'
|
||||
historyStr str 'HISTORY'
|
||||
savehistStr str 'SAVEHIST'
|
||||
histName dc c'/history',i1'0'
|
||||
lasthist dc i2'0'
|
||||
numhist dc i2'0'
|
||||
currenthist ds 4
|
||||
historyptr dc i4'0'
|
||||
historyStr gsstr 'HISTORY'
|
||||
savehistStr gsstr 'SAVEHIST'
|
||||
histName dc c'/history',i1'0'
|
||||
historyFN ds 4
|
||||
|
||||
END
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: invoke.asm,v 1.4 1998/06/30 17:25:40 tribby Exp $
|
||||
* $Id: invoke.asm,v 1.5 1998/07/20 16:23:07 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -30,7 +30,7 @@
|
||||
* invoke subroutine (2:argc,4:argv,4:sfile,4:dfile,4:efile,2:app,
|
||||
* 2:eapp,2:bg,4:cmd,2:jobflag,2:pipein,2:pipeout,
|
||||
* 2:pipein2,2:pipeout2,4:pipesem)
|
||||
* return 2:val
|
||||
* return 2:rtnval
|
||||
*
|
||||
**************************************************************************
|
||||
|
||||
@ -245,13 +245,13 @@ invoke START
|
||||
p equ 0
|
||||
biflag equ p+4
|
||||
ptr equ biflag+2
|
||||
val equ ptr+4
|
||||
dir equ val+2
|
||||
space equ dir+4
|
||||
rtnval equ ptr+4 Return pid, -1 (error), or 0 (no fork)
|
||||
dir equ rtnval+2
|
||||
space equ dir+4
|
||||
|
||||
subroutine (2:argc,4:argv,4:sfile,4:dfile,4:efile,2:app,2:eapp,2:bg,4:cmd,2:jobflag,2:pipein,2:pipeout,2:pipein2,2:pipeout2,4:pipesem),space
|
||||
|
||||
ld2 -1,val
|
||||
ld2 -1,rtnval
|
||||
stz biflag ;not a built-in
|
||||
|
||||
lda argc Get number of arguments.
|
||||
@ -296,7 +296,7 @@ checkfile anop
|
||||
cmp #-1
|
||||
jne trybuiltin
|
||||
|
||||
; Command is not listed in the built-in table
|
||||
; Command is not listed in the built-in table. See if it was hashed
|
||||
|
||||
pei (dir+2)
|
||||
pei (dir)
|
||||
@ -456,7 +456,7 @@ doDir lock cdmutex
|
||||
mv4 GRecPath,PRecPath
|
||||
SetPrefix PRec
|
||||
unlock cdmutex
|
||||
stz val
|
||||
stz rtnval Return value: no fork done.
|
||||
jmp free
|
||||
|
||||
;
|
||||
@ -556,7 +556,7 @@ noforkbuiltin anop
|
||||
pei (argv+2)
|
||||
pei (argv)
|
||||
jsl builtin
|
||||
stz val
|
||||
stz rtnval Return value: no fork done.
|
||||
bra done
|
||||
|
||||
*
|
||||
@ -575,8 +575,10 @@ notfound pei (ptr+2)
|
||||
ldx #^err2 Print error message:
|
||||
lda #err2 'Command not found.'
|
||||
jsr errputs
|
||||
|
||||
lda pipein
|
||||
beq notfound0
|
||||
|
||||
ssignal _semaphore
|
||||
sdelete _semaphore
|
||||
mv4 pjoblist,p
|
||||
@ -603,7 +605,7 @@ skipfrarg pei (cmd+2)
|
||||
pei (cmd)
|
||||
jsl nullfree
|
||||
|
||||
return 2:val
|
||||
return 2:rtnval
|
||||
;
|
||||
;
|
||||
; stuff to do just before forking
|
||||
@ -636,7 +638,7 @@ prefork lock mutex
|
||||
;
|
||||
; stuff to do right after forking
|
||||
;
|
||||
postfork sta val
|
||||
postfork sta rtnval
|
||||
lda pipein
|
||||
beq postfork2
|
||||
sta CloseRef
|
||||
@ -645,7 +647,7 @@ postfork2 lda pipeout
|
||||
beq postfork3
|
||||
sta CloseRef
|
||||
Close CloseParm
|
||||
postfork3 lda val
|
||||
postfork3 lda rtnval
|
||||
cmp #-1
|
||||
bne postfork4
|
||||
ldx #^deadstr Print error message:
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: jobs.asm,v 1.3 1998/06/30 17:25:43 tribby Exp $
|
||||
* $Id: jobs.asm,v 1.4 1998/07/20 16:23:07 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -576,44 +576,55 @@ done anop
|
||||
tcs
|
||||
|
||||
rtl
|
||||
|
||||
;
|
||||
; set status return variable
|
||||
; Set $status return variable
|
||||
;
|
||||
setstatus ENTRY
|
||||
|
||||
xba
|
||||
and #$FF
|
||||
xba Isolate status
|
||||
and #$FF byte.
|
||||
|
||||
cmp #100
|
||||
bcc set1
|
||||
Int2Dec (@a,#valstat1+1,#3,#0)
|
||||
lda #valstat1
|
||||
ldx #^valstat1
|
||||
bra set0
|
||||
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
|
||||
|
||||
set1 cmp #10
|
||||
bcc set2
|
||||
Int2Dec (@a,#valstat2+1,#2,#0)
|
||||
lda #valstat2
|
||||
ldx #^valstat2
|
||||
bra set0
|
||||
|
||||
set2 Int2Dec (@a,#valstat3+1,#1,#0)
|
||||
lda #valstat3
|
||||
ldx #^valstat3
|
||||
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
|
||||
Int2Dec (@a,#valstat_text,valstat,#0)
|
||||
|
||||
set0 sta SetParm+4
|
||||
stx SetParm+6
|
||||
Set_Variable SetParm
|
||||
set_value anop
|
||||
SetGS SetPB
|
||||
|
||||
rts
|
||||
|
||||
SetParm dc a4'name'
|
||||
ds 4
|
||||
name str 'status'
|
||||
valstat1 str '000'
|
||||
valstat2 str '00'
|
||||
valstat3 str '0'
|
||||
;
|
||||
; Parameter block for shell SetGS calls (p 427 in ORCA/M manual)
|
||||
;
|
||||
SetPB anop
|
||||
dc i2'3' pCount
|
||||
dc i4'status' Name (pointer to GS/OS string)
|
||||
dc i4'valstat' Value (pointer to GS/OS string)
|
||||
dc i2'0' Export flag
|
||||
|
||||
status gsstr 'status' Name of environment variable
|
||||
|
||||
;
|
||||
; Value of status: GS/OS string with one to three digits
|
||||
;
|
||||
valstat ds 2 Length word
|
||||
valstat_text dc c'000' Text (up to three digits)
|
||||
|
||||
END
|
||||
|
||||
@ -972,7 +983,7 @@ init stz pid
|
||||
cmp #'-'
|
||||
jne getpid
|
||||
|
||||
inc arg
|
||||
incad arg
|
||||
|
||||
lda [arg]
|
||||
and #$FF
|
||||
@ -1677,7 +1688,7 @@ dojobnum ldy len
|
||||
dey
|
||||
ldx str+2
|
||||
lda str
|
||||
inc a
|
||||
incad @xa
|
||||
Dec2Int (@xa,@y,#0),pid
|
||||
lda pjoblist
|
||||
ldx pjoblist+2
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: orca.asm,v 1.3 1998/06/30 17:25:48 tribby Exp $
|
||||
* $Id: orca.asm,v 1.5 1998/08/03 17:30:22 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -120,9 +120,7 @@ doloop short m Between parameters:
|
||||
sta [strPtr] character in strPtr.
|
||||
long m
|
||||
inc sLen Bump string length
|
||||
inc strPtr and pointer.
|
||||
bne nodelimit
|
||||
inc strPtr+2
|
||||
incad strPtr and pointer.
|
||||
|
||||
nodelimit anop
|
||||
lda pnum Get parameter number
|
||||
@ -229,10 +227,17 @@ doloopend inc pnum pnum++
|
||||
ph4 #defedit use default value.
|
||||
bra execit
|
||||
|
||||
goteditvar anop
|
||||
pei (editcommand+2)
|
||||
pei (editcommand)
|
||||
execit ph2 #0 ;tells execute we're called by system
|
||||
goteditvar anop Add 4 to value returned by getenv
|
||||
ldx editcommand+2 to get address of text portion.
|
||||
clc
|
||||
lda editcommand
|
||||
adc #4
|
||||
bcc nobump
|
||||
inx
|
||||
nobump anop
|
||||
phx Push address onto stack.
|
||||
pha
|
||||
execit ph2 #0 Tells execute we're called by system
|
||||
jsl execute
|
||||
sta retval
|
||||
|
||||
@ -295,12 +300,13 @@ gl_sfile dc i4'0' source file name (GS/OS string)
|
||||
dc i1'0' max err level found (compile/link)
|
||||
dc i1'0' operations flags (compile/link)
|
||||
dc i1'0' keep flag (compile)
|
||||
dc i4'0' minus flags (see ASML)
|
||||
dc i4'0' minus flags (see ASML command descr)
|
||||
dc i4'$08000000' plus flags [+E] (see ASML)
|
||||
dc i4'0' origin (link)
|
||||
|
||||
nullparm dc i2'0'
|
||||
|
||||
editorvar dc c'editor',h'00' Name of editor environment variable
|
||||
editorvar gsstr 'editor' Name of editor environment variable
|
||||
|
||||
defedit dc c'4:editor',h'00' Default value for editor
|
||||
END
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: prompt.asm,v 1.3 1998/06/30 17:25:50 tribby Exp $
|
||||
* $Id: prompt.asm,v 1.4 1998/07/20 16:23:08 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -34,58 +34,64 @@ WritePrompt START
|
||||
|
||||
|
||||
prompt equ 0
|
||||
hour equ prompt+4
|
||||
minute equ hour+2
|
||||
offset equ minute+2
|
||||
promptgsbuf equ prompt+4
|
||||
usergsbuf equ promptgsbuf+4
|
||||
hour equ usergsbuf+4
|
||||
minute equ hour+2
|
||||
offset equ minute+2
|
||||
pfx equ offset+2
|
||||
space equ pfx+4
|
||||
space equ pfx+4
|
||||
|
||||
year equ hour
|
||||
monday equ minute
|
||||
precmd equ prompt
|
||||
year equ hour
|
||||
monday equ minute
|
||||
precmd equ prompt
|
||||
|
||||
subroutine (0:dummy),space
|
||||
|
||||
ph4 #precmdstr
|
||||
ph4 #precmdstr If "precmd" alias is defined,
|
||||
jsl findalias
|
||||
sta precmd
|
||||
stx precmd+2
|
||||
ora precmd+2
|
||||
beq getvar
|
||||
|
||||
pei (precmd+2)
|
||||
pei (precmd+2) execute it before parsing prompt.
|
||||
pei (precmd)
|
||||
ph2 #0
|
||||
jsl execute
|
||||
|
||||
getvar Read_Variable promptparm
|
||||
;
|
||||
; Get value of $PROMPT environment variable
|
||||
;
|
||||
getvar ph4 #promptname
|
||||
jsl getenv
|
||||
|
||||
php
|
||||
sei ;interrupt free environment
|
||||
|
||||
lda promptbuf
|
||||
and #$FF
|
||||
bne parseprompt
|
||||
|
||||
sta promptgsbuf Save pointer to GS/OS result buffer.
|
||||
stx promptgsbuf+2 If there is no memory to hold it,
|
||||
ora promptgsbuf+2 it's undefined, or it has a
|
||||
bne parseprompt length of 0,
|
||||
ldx #^dfltPrompt
|
||||
lda #dfltPrompt
|
||||
jsr puts
|
||||
|
||||
bra donemark2
|
||||
|
||||
precmdstr dc c'precmd',h'00'
|
||||
jsr puts print the default prompt
|
||||
bra donemark2 and exit.
|
||||
|
||||
;
|
||||
; Prompt string begins in result buffer after the two length words
|
||||
;
|
||||
parseprompt anop
|
||||
|
||||
ph4 #promptbuf
|
||||
jsr p2cstr
|
||||
phx ;for disposal
|
||||
pha
|
||||
stx prompt+2
|
||||
clc
|
||||
lda promptgsbuf
|
||||
adc #4
|
||||
sta prompt
|
||||
lda promptgsbuf+2
|
||||
adc #0
|
||||
sta prompt+2
|
||||
|
||||
promptloop lda [prompt]
|
||||
inc prompt
|
||||
incad prompt
|
||||
and #$FF
|
||||
beq done
|
||||
cmp #'%'
|
||||
@ -99,13 +105,19 @@ _putchar jsr putchar
|
||||
|
||||
done jsr standend
|
||||
jsr cursoron
|
||||
|
||||
donemark2 anop
|
||||
pei (promptgsbuf+2) Free $PROMPT value buffer
|
||||
pei (promptgsbuf)
|
||||
jsl nullfree
|
||||
donemark2 plp
|
||||
|
||||
plp Restore interrupts.
|
||||
|
||||
jsr flush
|
||||
return
|
||||
return
|
||||
|
||||
special lda [prompt]
|
||||
inc prompt
|
||||
incad prompt
|
||||
and #$FF
|
||||
beq done
|
||||
cmp #'%'
|
||||
@ -313,11 +325,25 @@ ptilde anop
|
||||
;
|
||||
; Write user name
|
||||
;
|
||||
puser Read_Variable userparm
|
||||
ldx #^buf2
|
||||
lda #buf2
|
||||
jsr putp
|
||||
jmp promptloop
|
||||
puser ph4 #username Get value of $USER
|
||||
jsl getenv
|
||||
sta usergsbuf If buffer wasn't allocated
|
||||
stx usergsbuf+2
|
||||
ora usergsbuf+2
|
||||
beq goploop ignore it.
|
||||
|
||||
clc
|
||||
lda usergsbuf Text begins after
|
||||
adc #4 four bytes of
|
||||
bcc printit length words.
|
||||
inx
|
||||
printit jsr puts
|
||||
|
||||
pei (usergsbuf+2) Free $USER value buffer
|
||||
pei (usergsbuf)
|
||||
jsl nullfree
|
||||
|
||||
goploop jmp promptloop
|
||||
;
|
||||
; Write date as mm/dd/yy
|
||||
;
|
||||
@ -366,7 +392,7 @@ pdate2 ReadTimeHex (@a,year,monday,@a)
|
||||
; check for \ quote
|
||||
;
|
||||
quoteit lda [prompt]
|
||||
inc prompt
|
||||
incad prompt
|
||||
and #$FF
|
||||
jeq done
|
||||
cmp #'n'
|
||||
@ -391,35 +417,40 @@ WriteNum cmp #10
|
||||
bcs write1
|
||||
adc #'0'
|
||||
jmp putchar
|
||||
|
||||
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)
|
||||
ldx #^num+1
|
||||
lda #num+1
|
||||
jmp puts
|
||||
|
||||
write3 Int2Dec (@a,#num,#4,#0)
|
||||
ldx #^num
|
||||
lda #num
|
||||
jmp puts
|
||||
|
||||
|
||||
; Name of alias to execute before prompt
|
||||
precmdstr dc c'precmd',h'00'
|
||||
|
||||
|
||||
; Parameter block for GetPrefix GS/OS call
|
||||
GPParm dc i2'2'
|
||||
dc i2'0'
|
||||
GPpfx dc a4'0'
|
||||
promptparm dc a4'promptname'
|
||||
dc a4'promptbuf'
|
||||
promptname str 'prompt'
|
||||
|
||||
promptname gsstr 'prompt'
|
||||
username gsstr 'user'
|
||||
|
||||
dfltPrompt dc c'% ',h'00'
|
||||
num dc c'0000',h'00'
|
||||
promptbuf ds 256
|
||||
userparm dc a4'user'
|
||||
dc a4'buf2'
|
||||
user str 'user'
|
||||
buf2 ds 256
|
||||
|
||||
END
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: shell.asm,v 1.3 1998/06/30 17:25:52 tribby Exp $
|
||||
* $Id: shell.asm,v 1.4 1998/07/20 16:23:09 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -201,7 +201,7 @@ gnoloop entry
|
||||
ph2 #0
|
||||
jsl execute
|
||||
|
||||
lda exitamundo
|
||||
lda exit_requested
|
||||
bne done1
|
||||
jsr newlineX
|
||||
stz lastabort
|
||||
@ -217,7 +217,7 @@ done1 ora2 pjoblist,pjoblist+2,@a
|
||||
lda lastabort
|
||||
bne donekiller
|
||||
inc lastabort
|
||||
stz exitamundo
|
||||
stz exit_requested
|
||||
ldx #^stopstr Print message:
|
||||
lda #stopstr "There are stopped jobs"
|
||||
jsr puts
|
||||
@ -227,7 +227,7 @@ done1 ora2 pjoblist,pjoblist+2,@a
|
||||
donekiller jsl jobkiller
|
||||
done2 lda FastFlag
|
||||
bne fastskip5
|
||||
jsr SaveHistory
|
||||
jsl SaveHistory
|
||||
fastskip5 jsr dispose_hash
|
||||
|
||||
quit PopVariablesGS NullPB
|
||||
@ -303,9 +303,13 @@ gshrcName dc c'/gshrc',h'00'
|
||||
END
|
||||
|
||||
|
||||
* 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 GC string.
|
||||
;=========================================================================
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
;=========================================================================
|
||||
|
||||
AppendHome START
|
||||
outPtr equ 0
|
||||
@ -318,9 +322,9 @@ len equ 4
|
||||
stx outPtr+2 value of $HOME and
|
||||
sta outPtr the final result.
|
||||
|
||||
pei (str+2)
|
||||
pei (str)
|
||||
jsr cstrlen
|
||||
pei (str+2) Get length of
|
||||
pei (str) string to be
|
||||
jsr cstrlen appended.
|
||||
sta len
|
||||
|
||||
lda #255 Max len is 255 (leave room
|
||||
@ -370,10 +374,13 @@ foundSep sta [str] Store separator at end of string.
|
||||
|
||||
pei (str+2)
|
||||
pei (str)
|
||||
pei (outPtr+2)
|
||||
ldx outPtr+2
|
||||
lda outPtr
|
||||
clc
|
||||
adc #4
|
||||
bcc pushptr
|
||||
inx
|
||||
pushptr phx
|
||||
pha
|
||||
case on
|
||||
jsl strcat
|
||||
@ -384,25 +391,28 @@ foundSep sta [str] Store separator at end of string.
|
||||
adc #2 get address if GS/OS
|
||||
bcc no_ovf input string.
|
||||
inc outPtr+2
|
||||
clc
|
||||
no_ovf sta outPtr
|
||||
|
||||
lda [outPtr] Adjust string length
|
||||
clc to include appended
|
||||
adc len string (parameter).
|
||||
sta [outPtr]
|
||||
|
||||
;
|
||||
; NOTE: The returned value points to a GS/OS string, two bytes offset
|
||||
; from the allocated memory for a GS/OS result buffer. When the
|
||||
; memory is deallocated, the address must be adjusted back.
|
||||
;
|
||||
return 4:outPtr
|
||||
|
||||
atSign dc c'@',i1'0'
|
||||
|
||||
; Parameter block for Shell call ReadVariable (p 423 in ORCA/M reference)
|
||||
rvbl dc i2'3' pCount
|
||||
dc a4'in' address of variable's name
|
||||
dc a4'home' address of variable's name
|
||||
outPtr1 dc a4'0' pointer to result buffer
|
||||
dc i2'0' value of 'Export' flag (returned)
|
||||
|
||||
in dosin 'HOME'
|
||||
home gsstr 'HOME'
|
||||
|
||||
END
|
||||
|
||||
@ -420,9 +430,8 @@ GSOSDP ds 2
|
||||
cmdloc ds 2
|
||||
cmdlen ds 2
|
||||
cmdline ds cmdbuflen
|
||||
buffer ds 256
|
||||
buffer ds 256
|
||||
wordlen ds 2
|
||||
wordpbuf ds 1
|
||||
wordbuf ds 256
|
||||
nummatch ds 2
|
||||
matchbuf ds 512*4
|
||||
@ -430,7 +439,7 @@ cmdcontext ds 2
|
||||
cmddp ds 2
|
||||
gshtty ds 2
|
||||
gshpid ds 2
|
||||
exitamundo dc i'0' ;!=0 if exit
|
||||
exit_requested dc i'0' ;!=0 if exit
|
||||
signalled dc i'0'
|
||||
|
||||
FastFlag dc i'0'
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: shellutil.asm,v 1.3 1998/06/30 17:25:55 tribby Exp $
|
||||
* $Id: shellutil.asm,v 1.4 1998/07/20 16:23:09 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -213,7 +213,7 @@ end equ p+4
|
||||
sta cstr
|
||||
stx cstr+2
|
||||
lda [p]
|
||||
inc p
|
||||
incad p
|
||||
and #$FF
|
||||
tax
|
||||
|
||||
@ -491,8 +491,8 @@ end equ cstr+4
|
||||
jsl ~NEW
|
||||
sta gstr
|
||||
stx gstr+2
|
||||
inc a
|
||||
inc a
|
||||
incad @xa
|
||||
incad @xa
|
||||
pei (cstr+2)
|
||||
pei (cstr)
|
||||
phx
|
||||
@ -566,7 +566,7 @@ copy2 lda [q]
|
||||
sta [new],y
|
||||
beq done
|
||||
iny
|
||||
inc q
|
||||
incad q
|
||||
bra copy2
|
||||
|
||||
done ldx new+2
|
||||
@ -592,11 +592,11 @@ done ldx new+2
|
||||
|
||||
nullfree START
|
||||
|
||||
lda 6,s
|
||||
and #$FF80
|
||||
beq notbad
|
||||
brk $db
|
||||
notbad anop
|
||||
* lda 6,s DEBUG code: break if
|
||||
* and #$FF80 address is > $007FFFFF
|
||||
* beq notbad
|
||||
* brk $db
|
||||
*notbad anop
|
||||
|
||||
lda 4,s
|
||||
ora 6,s
|
||||
@ -648,16 +648,15 @@ newline ENTRY
|
||||
* library getenv(), but lets stay Orca-free, after all, that's why this
|
||||
* is written in assembly! :)
|
||||
*
|
||||
* Borrowed from termcap
|
||||
* For gsh 2.0: pass in addr of a GS/OS string, and pass back addr of
|
||||
* allocated GS/OS result buffer (with null word added at end), not c-strings.
|
||||
*
|
||||
**************************************************************************
|
||||
|
||||
getenv START
|
||||
|
||||
newval equ 1
|
||||
len equ newval+4
|
||||
namebuf equ len+2
|
||||
retval equ namebuf+4
|
||||
len equ 1
|
||||
retval equ len+2
|
||||
space equ retval+4
|
||||
var equ space+3
|
||||
end equ var+4
|
||||
@ -671,109 +670,59 @@ end equ var+4
|
||||
phd
|
||||
tcd
|
||||
|
||||
stz retval
|
||||
stz retval+2
|
||||
|
||||
lock mutex
|
||||
;
|
||||
; get length of variable name
|
||||
; 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.
|
||||
ReadVariableGS ReadVar Get length.
|
||||
;
|
||||
short a
|
||||
ldy #0
|
||||
findlen lda [var],y
|
||||
beq gotlen
|
||||
iny
|
||||
bra findlen
|
||||
gotlen long a
|
||||
sty len
|
||||
; Allocate memory for value string
|
||||
;
|
||||
; allocate a buffer to put the pascal string
|
||||
;
|
||||
iny
|
||||
pea 0
|
||||
phy
|
||||
jsl ~NEW
|
||||
sta namebuf
|
||||
stx namebuf+2
|
||||
sta varparm
|
||||
stx varparm+2
|
||||
ora namebuf+2
|
||||
jeq exit
|
||||
;
|
||||
; now make a pascal string from the c string
|
||||
;
|
||||
short ai
|
||||
lda len
|
||||
sta [namebuf]
|
||||
ldy #0
|
||||
copyname lda [var],y
|
||||
beq copydone
|
||||
iny
|
||||
sta [namebuf],y
|
||||
bra copyname
|
||||
copydone long ai
|
||||
;
|
||||
; allocate a return buffer
|
||||
;
|
||||
jsl alloc256
|
||||
sta newval
|
||||
stx newval+2
|
||||
sta varparm+4
|
||||
stx varparm+6
|
||||
ora newval+2
|
||||
jeq exit0
|
||||
;
|
||||
; Let's go read the variable
|
||||
;
|
||||
Read_Variable varparm
|
||||
;
|
||||
; Was it defined?
|
||||
;
|
||||
lda [newval]
|
||||
and #$FF
|
||||
jeq exit1 ;return a null if not defined
|
||||
;
|
||||
; Make a return buffer to return the variable value
|
||||
;
|
||||
inc a
|
||||
lda TempRBlen Get length of value.
|
||||
bne notnull Return null if 0.
|
||||
sta retval
|
||||
sta retval+2
|
||||
bra exit
|
||||
|
||||
notnull inc2 a Add 4 bytes for result buf len words.
|
||||
inc2 a
|
||||
sta len Save result buf len.
|
||||
inc a Add 1 more for terminating null byte.
|
||||
pea 0
|
||||
pha
|
||||
jsl ~NEW
|
||||
sta retval
|
||||
jsl ~NEW Request the memory.
|
||||
sta RVresult Store address in ReadVariable
|
||||
stx RVresult+2 parameter block and
|
||||
sta retval direct page pointer.
|
||||
stx retval+2
|
||||
ora retval+2
|
||||
jeq exit1
|
||||
;
|
||||
; And copy the resulting value
|
||||
;
|
||||
short ai
|
||||
lda [newval]
|
||||
tay
|
||||
copyval cpy #0
|
||||
beq val1
|
||||
lda [newval],y
|
||||
dey
|
||||
sta [retval],y
|
||||
bra copyval
|
||||
val1 lda [newval]
|
||||
tay
|
||||
lda #0
|
||||
sta [retval],y
|
||||
long ai
|
||||
;
|
||||
; hasta la vista, baby
|
||||
;
|
||||
exit1 ldx newval+2
|
||||
lda newval
|
||||
jsl free256
|
||||
|
||||
exit0 pei (namebuf+2)
|
||||
pei (namebuf)
|
||||
jsl nullfree
|
||||
ora retval+2 If address == NULL,
|
||||
beq exit return NULL to user.
|
||||
|
||||
lda len Store result buffer length
|
||||
sta [retval] at beginning of buf.
|
||||
;
|
||||
; Read the full value into the allocated memory
|
||||
;
|
||||
ReadVariableGS ReadVar
|
||||
;
|
||||
; Add null byte at end of text to make it work as a C string
|
||||
;
|
||||
ldy TempRBlen Get length of value,
|
||||
iny4 + 4 (for length words at start)
|
||||
lda #0 Store zero at end of string.
|
||||
short a
|
||||
sta [retval],y
|
||||
long a
|
||||
;
|
||||
; All done.
|
||||
;
|
||||
exit unlock mutex
|
||||
|
||||
ldy retval
|
||||
ldx retval+2
|
||||
|
||||
lda space+1
|
||||
sta end-2
|
||||
lda space
|
||||
@ -787,9 +736,20 @@ exit unlock mutex
|
||||
|
||||
rtl
|
||||
|
||||
varparm ds 8
|
||||
mutex key
|
||||
|
||||
; Parameter block for shell ReadVariableGS call (p 423 in ORCA/M manual)
|
||||
ReadVar anop
|
||||
dc i2'3' pCount
|
||||
RVname ds 4 Pointer to name (passed by user)
|
||||
RVresult ds 4 GS/OS Output buffer ptr
|
||||
RVexpflag ds 2 export flag
|
||||
|
||||
; GS/OS result buffer for getting the full length of the PATH env var.
|
||||
TempResultBuf dc i2'5' Only five bytes total.
|
||||
TempRBlen ds 2 Value's length returned here.
|
||||
ds 1 Only 1 byte for value.
|
||||
|
||||
END
|
||||
|
||||
rmemcpy START
|
||||
|
File diff suppressed because it is too large
Load Diff
176
bin/gsh/sv.asm
176
bin/gsh/sv.asm
@ -6,12 +6,13 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: sv.asm,v 1.3 1998/06/30 17:26:02 tribby Exp $
|
||||
* $Id: sv.asm,v 1.4 1998/07/20 16:23:10 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
* SV.ASM
|
||||
* By Tim Meekins
|
||||
* Modified by Dave Tribby for GNO 2.0.6
|
||||
*
|
||||
* String Vector routines.
|
||||
*
|
||||
@ -43,33 +44,31 @@ space equ ptr+4
|
||||
lda size
|
||||
inc a ;for size and count
|
||||
inc a ;at least one null entry
|
||||
asl a
|
||||
asl a Multiply by 4 (bytes/entry).
|
||||
asl a
|
||||
pea 0
|
||||
pha
|
||||
jsl ~NEW
|
||||
sta ptr
|
||||
stx ptr+2
|
||||
jsl ~NEW Allocate the memory
|
||||
sta ptr and save address in
|
||||
stx ptr+2 direct page variable.
|
||||
|
||||
ldy #2
|
||||
lda size
|
||||
sta [ptr],y
|
||||
lda #0
|
||||
ldy #2 Store number of entries
|
||||
lda size as the value of the
|
||||
sta [ptr],y first entry's high byte
|
||||
lda #0 and zero as the low byte.
|
||||
sta [ptr]
|
||||
ldy #4
|
||||
|
||||
ldx size
|
||||
ldy #4 Set Y to index to 2nd entry.
|
||||
ldx size X = num of entries following.
|
||||
|
||||
init sta [ptr],y
|
||||
iny
|
||||
iny
|
||||
init sta [ptr],y Set all entries
|
||||
iny2 to 0x00000000.
|
||||
sta [ptr],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
dex
|
||||
bpl init ;not bne so that extra null at end
|
||||
|
||||
add4 ptr,#4,ptr
|
||||
add4 ptr,#4,ptr Set ptr to point at second entry.
|
||||
|
||||
return 4:ptr
|
||||
|
||||
@ -89,52 +88,54 @@ space equ base+4
|
||||
|
||||
subroutine (4:vect,4:string,2:allocflag),space
|
||||
|
||||
sub4 vect,#4,base
|
||||
sub4 vect,#4,base base points to entry # 0.
|
||||
|
||||
ldy #2
|
||||
lda [base],y
|
||||
cmp [base]
|
||||
beq exit ;ack, the vector is full!
|
||||
lda [base],y If number of entries in table
|
||||
cmp [base] == number in use,
|
||||
beq exit the vector is full!
|
||||
;
|
||||
; 1 = allocate memory, 0 = use string as is...
|
||||
;
|
||||
lda allocflag
|
||||
lda allocflag If "allocate memory" flag is set,
|
||||
beq asis
|
||||
|
||||
pei (string+2)
|
||||
pei (string)
|
||||
pei (string+2) Determine length of
|
||||
pei (string) new string.
|
||||
jsr cstrlen
|
||||
inc a
|
||||
pea 0
|
||||
pha
|
||||
jsl ~NEW
|
||||
sta p
|
||||
jsl ~NEW Allocate memory for it.
|
||||
sta p Store address in p/p+1.
|
||||
stx p+2
|
||||
|
||||
pei (string+2)
|
||||
pei (string)
|
||||
pei (string+2) Copy the string into
|
||||
pei (string) the new memory.
|
||||
phx
|
||||
pha
|
||||
jsr copycstr
|
||||
bra doit
|
||||
bra doit else
|
||||
|
||||
asis mv4 string,p
|
||||
asis mv4 string,p Just copy address to p/p+1.
|
||||
|
||||
;
|
||||
; p contains address of string to be added to the vector.
|
||||
;
|
||||
doit lda [base]
|
||||
tax
|
||||
tax X = number of entries in use.
|
||||
asl a
|
||||
asl a
|
||||
tay
|
||||
lda p
|
||||
tay Y = offset to next avail entry.
|
||||
lda p Set entry to address of added string.
|
||||
sta [vect],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda p+2
|
||||
sta [vect],y
|
||||
|
||||
txa
|
||||
inc a
|
||||
sta [base]
|
||||
sta [base] Bump the number of entries in use.
|
||||
|
||||
exit return
|
||||
|
||||
@ -153,27 +154,27 @@ space equ p+4
|
||||
|
||||
subroutine (4:vect),space
|
||||
|
||||
sub4 vect,#4,p
|
||||
sub4 vect,#4,p p points to head of vector
|
||||
|
||||
loop lda [p]
|
||||
beq done
|
||||
lda [p] Get number of entries in use.
|
||||
beq done Done if zero.
|
||||
|
||||
loop asl a
|
||||
asl a
|
||||
asl a
|
||||
tay
|
||||
tay Y points to last used entry.
|
||||
lda [vect],y
|
||||
tax
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [vect],y
|
||||
pha
|
||||
phx
|
||||
jsl nullfree
|
||||
jsl nullfree Free memory used by this entry.
|
||||
lda [p]
|
||||
dec a
|
||||
sta [p]
|
||||
bra loop
|
||||
sta [p] Number used = number used - 1.
|
||||
bne loop If more to do, stay in loop.
|
||||
|
||||
done pei (p+2)
|
||||
done pei (p+2) Free the vector itself.
|
||||
pei (p)
|
||||
jsl nullfree
|
||||
|
||||
@ -197,35 +198,32 @@ space equ maxlen+2
|
||||
|
||||
subroutine (4:sv),space
|
||||
|
||||
sub4 sv,#4,base
|
||||
sub4 sv,#4,base base = ptr to entry 0.
|
||||
;
|
||||
; Find the maximum string length
|
||||
;
|
||||
lda #1
|
||||
sta maxlen
|
||||
|
||||
ldy #0
|
||||
lda #0
|
||||
lda #0 Keep track of entry number in Acc.
|
||||
lenloop pha
|
||||
asl a
|
||||
asl a
|
||||
tay Y = offset to entry number.
|
||||
lda [sv],y
|
||||
tax
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
iny
|
||||
iny
|
||||
phy
|
||||
pha
|
||||
phx
|
||||
jsr cstrlen
|
||||
cmp maxlen
|
||||
jsr cstrlen Get length of entry's string.
|
||||
cmp maxlen If > maxlen,
|
||||
bcc nextlen
|
||||
sta maxlen
|
||||
nextlen ply
|
||||
pla
|
||||
inc a
|
||||
cmp [base]
|
||||
bcc lenloop
|
||||
sta maxlen set maxlen to this length.
|
||||
nextlen pla
|
||||
inc a Bump entry number.
|
||||
cmp [base] If not done,
|
||||
bcc lenloop stay in loop.
|
||||
;
|
||||
; add one for a space
|
||||
;
|
||||
@ -259,6 +257,7 @@ okcol stx numcol
|
||||
beq foocol
|
||||
inc numrow
|
||||
foocol anop
|
||||
|
||||
;
|
||||
; find the index for each column...
|
||||
;
|
||||
@ -266,22 +265,20 @@ foocol anop
|
||||
tax
|
||||
clc
|
||||
mkidxloop sta offtbl,x
|
||||
inx
|
||||
inx2
|
||||
adc numrow
|
||||
cmp [base]
|
||||
bcc mkidxloop
|
||||
;
|
||||
; well....I think we can print now (yay!)
|
||||
;
|
||||
ldx #0
|
||||
asl numcol Double numcol since it's compared
|
||||
ldx #0 against X to end the loop.
|
||||
printloop lda offtbl,x
|
||||
and #$FF
|
||||
cmp [base]
|
||||
bcs nextprint0
|
||||
inc a
|
||||
short a
|
||||
sta offtbl,x
|
||||
long a
|
||||
phx
|
||||
dec a
|
||||
asl a
|
||||
@ -289,8 +286,7 @@ printloop lda offtbl,x
|
||||
tay
|
||||
lda [sv],y
|
||||
tax
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
pha
|
||||
phx
|
||||
@ -307,7 +303,7 @@ tabit cmp maxlen
|
||||
inc a
|
||||
bra tabit
|
||||
nextprint plx
|
||||
inx
|
||||
inx2
|
||||
cpx numcol
|
||||
bcc printloop
|
||||
nextprint0 jsr newline
|
||||
@ -317,7 +313,10 @@ nextprint0 jsr newline
|
||||
|
||||
doneprint return
|
||||
|
||||
offtbl ds 7
|
||||
;
|
||||
; Offset table: one entry for each column
|
||||
;
|
||||
offtbl ds 14
|
||||
|
||||
END
|
||||
|
||||
@ -375,8 +374,7 @@ space equ idx1+2
|
||||
tay
|
||||
lda [sv],y
|
||||
sta ptr1
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
sta ptr1+2
|
||||
add2 left,right,@a
|
||||
@ -388,8 +386,7 @@ space equ idx1+2
|
||||
sta ptr2
|
||||
lda ptr1
|
||||
sta [sv],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
sta ptr2+2
|
||||
lda ptr1+2
|
||||
@ -397,8 +394,7 @@ space equ idx1+2
|
||||
ldy idx1
|
||||
lda ptr2
|
||||
sta [sv],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda ptr2+2
|
||||
sta [sv],y
|
||||
;
|
||||
@ -412,8 +408,7 @@ space equ idx1+2
|
||||
tay
|
||||
lda [sv],y
|
||||
sta vleft
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
sta vleft+2
|
||||
;
|
||||
@ -435,8 +430,7 @@ okloop anop
|
||||
tay
|
||||
lda [sv],y
|
||||
tax
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
pha
|
||||
phx
|
||||
@ -455,8 +449,7 @@ okloop anop
|
||||
tay
|
||||
lda [sv],y
|
||||
sta ptr1
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
sta ptr1+2
|
||||
lda i
|
||||
@ -467,8 +460,7 @@ okloop anop
|
||||
sta ptr2
|
||||
lda ptr1
|
||||
sta [sv],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
sta ptr2+2
|
||||
lda ptr1+2
|
||||
@ -476,8 +468,7 @@ okloop anop
|
||||
ldy idx1
|
||||
lda ptr2
|
||||
sta [sv],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda ptr2+2
|
||||
sta [sv],y
|
||||
|
||||
@ -493,8 +484,7 @@ endloop lda left
|
||||
tay
|
||||
lda [sv],y
|
||||
sta ptr1
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
sta ptr1+2
|
||||
lda last
|
||||
@ -505,8 +495,7 @@ endloop lda left
|
||||
sta ptr2
|
||||
lda ptr1
|
||||
sta [sv],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda [sv],y
|
||||
sta ptr2+2
|
||||
lda ptr1+2
|
||||
@ -514,8 +503,7 @@ endloop lda left
|
||||
ldy idx1
|
||||
lda ptr2
|
||||
sta [sv],y
|
||||
iny
|
||||
iny
|
||||
iny2
|
||||
lda ptr2+2
|
||||
sta [sv],y
|
||||
;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: term.asm,v 1.3 1998/06/30 17:26:04 tribby Exp $
|
||||
* $Id: term.asm,v 1.4 1998/07/20 16:23:11 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
@ -32,7 +32,7 @@ TIOCGETP gequ $40067408
|
||||
**************************************************************************
|
||||
*
|
||||
* Initialize the system for termcap - checks to see if $TERM exists
|
||||
* and is set, if not, sets to GNOCON
|
||||
* and is set, if not, sets to GNOCON; and allocate termcap buffers.
|
||||
*
|
||||
**************************************************************************
|
||||
|
||||
@ -40,26 +40,55 @@ InitTerm START
|
||||
|
||||
using termdata
|
||||
|
||||
Set_Variable setparm
|
||||
Export expparm
|
||||
;
|
||||
; See if $TERM exists
|
||||
;
|
||||
ReadVariableGS dummyresult
|
||||
|
||||
lda term_len Get length of $TERM
|
||||
bne allocate If 0,
|
||||
SetGS SetPB set to default ("gnocon")
|
||||
|
||||
allocate anop Allocate termcap buffers.
|
||||
|
||||
ph4 #1024
|
||||
jsl ~NEW
|
||||
sta bp
|
||||
stx bp+2
|
||||
|
||||
ph4 #1024
|
||||
jsl ~NEW
|
||||
sta areabuf
|
||||
stx areabuf+2
|
||||
rts
|
||||
|
||||
setparm dc i4'termname' ;default term type
|
||||
dc i4'termval'
|
||||
rts Return to caller.
|
||||
|
||||
expparm dc i4'termname'
|
||||
dc i2'1'
|
||||
;
|
||||
; Parameter block for shell ReadVariableGS call (p 423 in ORCA/M manual)
|
||||
;
|
||||
ReadVarPB anop
|
||||
dc i2'3' pCount
|
||||
dc i4'term' Name (pointer to GS/OS string)
|
||||
dc i4'dummyresult' GS/OS Output buffer ptr
|
||||
ds 2 export flag
|
||||
;
|
||||
; GS/OS result buffer for getting length of TERM env var.
|
||||
;
|
||||
dummyresult dc i2'5' Only five bytes total.
|
||||
term_len ds 2 Value's length returned here.
|
||||
ds 1 Only 1 byte for value.
|
||||
|
||||
termname str 'term'
|
||||
termval str 'gnocon'
|
||||
;
|
||||
; Parameter block for shell SetGS calls (p 427 in ORCA/M manual)
|
||||
;
|
||||
SetPB anop
|
||||
dc i2'3' pCount
|
||||
dc i4'term' Name (pointer to GS/OS string)
|
||||
dc i4'gnocon' Value (pointer to GS/OS string)
|
||||
dc i2'1' Export flag
|
||||
|
||||
term gsstr 'term'
|
||||
gnocon gsstr 'gnocon'
|
||||
|
||||
END
|
||||
|
||||
@ -83,31 +112,38 @@ down_history equ 6
|
||||
|
||||
ph4 #termname
|
||||
jsl getenv
|
||||
phx
|
||||
pha
|
||||
phx Push allocated buffer on stack
|
||||
pha for later call to nullfree.
|
||||
clc Add 4 to GS/OS result buffer
|
||||
adc #4 to get pointer to text.
|
||||
bcc val_addr_set
|
||||
inx
|
||||
val_addr_set sta hold_term_val
|
||||
stx hold_term_val+2
|
||||
tgetent (bp,@xa) ;xa is pushed first
|
||||
beq noentry
|
||||
dec a
|
||||
beq ok
|
||||
|
||||
jsl nullfree
|
||||
jsl nullfree Free buffer allocated by getenv.
|
||||
stz termok
|
||||
ldx #^error1
|
||||
lda #error1
|
||||
jmp errputs
|
||||
|
||||
noentry jsl nullfree
|
||||
noentry anop
|
||||
stz termok
|
||||
ldx #^error2
|
||||
lda #error2
|
||||
jsr errputs
|
||||
ph4 #termname
|
||||
jsl getenv
|
||||
jsr errputs
|
||||
lda #error2 Print error message:
|
||||
jsr errputs 'Termcap entry not found for '
|
||||
lda hold_term_val Get text from buffer allocated
|
||||
ldx hold_term_val+2 by getenv
|
||||
jsr errputs and print it.
|
||||
jsl nullfree Free buffer allocated by getenv.
|
||||
lda #13
|
||||
jmp errputchar
|
||||
|
||||
ok jsl nullfree
|
||||
ok jsl nullfree Free buffer allocated by getenv.
|
||||
lda #1
|
||||
sta termok
|
||||
mv4 areabuf,area
|
||||
@ -183,7 +219,7 @@ ok jsl nullfree
|
||||
|
||||
rts
|
||||
|
||||
termname dc c'term',h'00'
|
||||
termname gsstr 'term'
|
||||
error1 dc c'Error reading termcap file!',h'0d0d00'
|
||||
error2 dc c'Termcap entry not found for ',h'00'
|
||||
isid dc c'is',h'00'
|
||||
@ -210,6 +246,10 @@ sg_ospeed dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
sg_flags dc i2'0'
|
||||
|
||||
; Hold the address of the value of $TERM
|
||||
hold_term_val ds 4
|
||||
|
||||
END
|
||||
|
||||
**************************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user