mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-06-10 18:29:28 +00:00
Initial checkin of gsh v1.1 as provided by Tony Diaz.
This commit is contained in:
parent
99e3b1cd28
commit
1f1b3ada37
477
bin/gsh/M/alias.mac
Normal file
477
bin/gsh/M/alias.mac
Normal file
|
@ -0,0 +1,477 @@
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $200c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab dec2 &a
|
||||||
|
&lab dec &a
|
||||||
|
dec &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny2
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ora2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
ora &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab asl2 &a
|
||||||
|
&lab asl &a
|
||||||
|
asl &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab UDivide &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph2 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
Tool $0b0b
|
||||||
|
pl2 &a2(1)
|
||||||
|
pl2 &a2(2)
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab inx2
|
||||||
|
&lab inx
|
||||||
|
inx
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab dey2
|
||||||
|
&lab dey
|
||||||
|
dey
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ErrWriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $210c
|
||||||
|
mend
|
84
bin/gsh/M/bufpool.mac
Normal file
84
bin/gsh/M/bufpool.mac
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab unlock &a1
|
||||||
|
&lab stz &a1
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab key
|
||||||
|
&lab dc i2'0'
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab lock &a1
|
||||||
|
&lab lda #1
|
||||||
|
tsb &a1
|
||||||
|
beq *+6
|
||||||
|
cop $7F
|
||||||
|
bra *-7
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab WriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $200c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
774
bin/gsh/M/builtin.mac
Normal file
774
bin/gsh/M/builtin.mac
Normal file
|
@ -0,0 +1,774 @@
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab sub2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab sec
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .sub
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .sub
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .sub
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.sub
|
||||||
|
sbc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab jcs &loc
|
||||||
|
&lab bcc *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD2 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #&val
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ora2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
ora &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny2
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Dec2Int &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
Tool $280b
|
||||||
|
pl2 &a2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Int2Dec &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $260b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetPrefix &a1
|
||||||
|
&lab gsos $200A,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ERROR &a1
|
||||||
|
&lab p16 $105,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab asl2 &a
|
||||||
|
&lab asl &a
|
||||||
|
asl &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD4 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #<&val
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda #+(&val)|-16
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab inc2 &a
|
||||||
|
&lab inc &a
|
||||||
|
inc &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jne &loc
|
||||||
|
&lab beq *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab SetPrefix &a1
|
||||||
|
&lab gsos $2009,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetFileInfo &a1
|
||||||
|
&lab gsos $2006,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab dey2
|
||||||
|
&lab dey
|
||||||
|
dey
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab GetBootVol &a1
|
||||||
|
&lab gsos $2028,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Volume &a1
|
||||||
|
&lab gsos $2008,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab DInfo &a1
|
||||||
|
&lab gsos $202C,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Long2Dec &a1
|
||||||
|
&lab ph4 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $270b
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab LongMul &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
Tool $0c0b
|
||||||
|
pl4 &a2(1)
|
||||||
|
pl4 &a2(2)
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab LongDivide &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
Tool $0d0b
|
||||||
|
pl4 &a2(1)
|
||||||
|
pl4 &a2(2)
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab pl4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"<>"{",.chk
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ldy #2
|
||||||
|
pla
|
||||||
|
sta (&parm),y
|
||||||
|
ago .shorten
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"[",.chk2
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ldy #2
|
||||||
|
pla
|
||||||
|
sta &parm,y
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"@",.absolute
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
pl&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
pl&char2
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
pla
|
||||||
|
sta &parm+2
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab setdebug &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl setdebug
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab kvm_open
|
||||||
|
&lab case on
|
||||||
|
jsl kvm_open
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab kvm_close &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl kvm_close
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab kvmnextproc &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl kvmnextproc
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab Int2Hex &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
Tool $220b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab kvmgetproc &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl kvmgetproc
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab unlock &a1
|
||||||
|
&lab stz &a1
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab key
|
||||||
|
&lab dc i2'0'
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab lock &a1
|
||||||
|
&lab lda #1
|
||||||
|
tsb &a1
|
||||||
|
beq *+6
|
||||||
|
cop $7F
|
||||||
|
bra *-7
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab jcc &loc
|
||||||
|
&lab bcs *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab getuid
|
||||||
|
&lab case on
|
||||||
|
jsl getuid
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab UDivide &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph2 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
Tool $0b0b
|
||||||
|
pl2 &a2(1)
|
||||||
|
pl2 &a2(2)
|
||||||
|
mend
|
497
bin/gsh/M/cmd.mac
Normal file
497
bin/gsh/M/cmd.mac
Normal file
|
@ -0,0 +1,497 @@
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny2
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Int2Dec &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $260b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ERROR &a1
|
||||||
|
&lab p16 $105,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD2 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #&val
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab and2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
and &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab asl2 &a
|
||||||
|
&lab asl &a
|
||||||
|
asl &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD4 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #<&val
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda #+(&val)|-16
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jcc &loc
|
||||||
|
&lab bcs *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Set_Variable &a1
|
||||||
|
&lab p16 $106,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab wait &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl wait
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab pipe &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl pipe
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab signal &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl signal
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ErrWriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $210c
|
||||||
|
mend
|
474
bin/gsh/M/dir.mac
Normal file
474
bin/gsh/M/dir.mac
Normal file
|
@ -0,0 +1,474 @@
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab inc2 &a
|
||||||
|
&lab inc &a
|
||||||
|
inc &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab sub2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab sec
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .sub
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .sub
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .sub
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.sub
|
||||||
|
sbc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $200c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add4 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &ch
|
||||||
|
&ch amid &arg2,1,1
|
||||||
|
clc
|
||||||
|
lda &arg1
|
||||||
|
adc &arg2
|
||||||
|
sta &dest
|
||||||
|
lda &arg1+2
|
||||||
|
aif "&ch"="#",.a
|
||||||
|
adc &arg2+2
|
||||||
|
ago .b
|
||||||
|
.a
|
||||||
|
adc &arg2|-16
|
||||||
|
.b
|
||||||
|
sta &dest+2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetPrefix &a1
|
||||||
|
&lab gsos $200A,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab unlock &a1
|
||||||
|
&lab stz &a1
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab key
|
||||||
|
&lab dc i2'0'
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab lock &a1
|
||||||
|
&lab lda #1
|
||||||
|
tsb &a1
|
||||||
|
beq *+6
|
||||||
|
cop $7F
|
||||||
|
bra *-7
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab ErrWriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $210c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetFileInfo &a1
|
||||||
|
&lab gsos $2006,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ERROR &a1
|
||||||
|
&lab p16 $105,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab SetPrefix &a1
|
||||||
|
&lab gsos $2009,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Dec2Int &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
Tool $280b
|
||||||
|
pl2 &a2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab inx4
|
||||||
|
&lab inx
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
mend
|
551
bin/gsh/M/edit.mac
Normal file
551
bin/gsh/M/edit.mac
Normal file
|
@ -0,0 +1,551 @@
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab sub2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab sec
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .sub
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .sub
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .sub
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.sub
|
||||||
|
sbc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab eor2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
eor &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab INIT_WILDCARD &a1
|
||||||
|
&lab p16 $109,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab NEXT_WILDCARD &a1
|
||||||
|
&lab p16 $10A,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetFileInfo &a1
|
||||||
|
&lab gsos $2006,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ioctl &a1
|
||||||
|
&lab ph4 &a1(3)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl ioctl
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add4 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &ch
|
||||||
|
&ch amid &arg2,1,1
|
||||||
|
clc
|
||||||
|
lda &arg1
|
||||||
|
adc &arg2
|
||||||
|
sta &dest
|
||||||
|
lda &arg1+2
|
||||||
|
aif "&ch"="#",.a
|
||||||
|
adc &arg2+2
|
||||||
|
ago .b
|
||||||
|
.a
|
||||||
|
adc &arg2|-16
|
||||||
|
.b
|
||||||
|
sta &dest+2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD4 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #<&val
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda #+(&val)|-16
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tputs &a1
|
||||||
|
&lab ph4 &a1(3)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tputs
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jne &loc
|
||||||
|
&lab beq *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD2 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #&val
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_INDEXED &a1
|
||||||
|
&lab p16 $108,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jcc &loc
|
||||||
|
&lab bcs *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
435
bin/gsh/M/expand.mac
Normal file
435
bin/gsh/M/expand.mac
Normal file
|
@ -0,0 +1,435 @@
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $200c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab INIT_WILDCARD &a1
|
||||||
|
&lab p16 $109,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab NEXT_WILDCARD &a1
|
||||||
|
&lab p16 $10A,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab sub2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab sec
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .sub
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .sub
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .sub
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.sub
|
||||||
|
sbc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab dec2 &a
|
||||||
|
&lab dec &a
|
||||||
|
dec &a
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ReadLine &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $240c
|
||||||
|
pl2 &a2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
571
bin/gsh/M/hash.mac
Normal file
571
bin/gsh/M/hash.mac
Normal file
|
@ -0,0 +1,571 @@
|
||||||
|
MACRO
|
||||||
|
&lab UDivide &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph2 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
Tool $0b0b
|
||||||
|
pl2 &a2(1)
|
||||||
|
pl2 &a2(2)
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab asl2 &a
|
||||||
|
&lab asl &a
|
||||||
|
asl &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab asl3 &a
|
||||||
|
&lab asl &a
|
||||||
|
asl &a
|
||||||
|
asl &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab asl4 &a
|
||||||
|
&lab asl &a
|
||||||
|
asl &a
|
||||||
|
asl &a
|
||||||
|
asl &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny2
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Open &a1
|
||||||
|
&lab gsos $2010,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Close &a1
|
||||||
|
&lab gsos $2014,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetDirEntry &a1
|
||||||
|
&lab gsos $201C,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD2 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #&val
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ora2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
ora &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jge &loc
|
||||||
|
&lab bcc *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Int2Dec &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $260b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $200c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab lsr2 &a
|
||||||
|
&lab lsr &a
|
||||||
|
lsr &a
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jne &loc
|
||||||
|
&lab beq *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny4
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab inc2 &a
|
||||||
|
&lab inc &a
|
||||||
|
inc &a
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ExpandPath &a1
|
||||||
|
&lab gsos $200E,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ErrWriteLine &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $1b0c
|
||||||
|
mend
|
592
bin/gsh/M/history.mac
Normal file
592
bin/gsh/M/history.mac
Normal file
|
@ -0,0 +1,592 @@
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny2
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ora2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
ora &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Dec2Int &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
Tool $280b
|
||||||
|
pl2 &a2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Create &a1
|
||||||
|
&lab gsos $2001,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Open &a1
|
||||||
|
&lab gsos $2010,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Write &a1
|
||||||
|
&lab gsos $2013,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Close &a1
|
||||||
|
&lab gsos $2014,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GSStr &string
|
||||||
|
&lab dc i2'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add4 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &ch
|
||||||
|
&ch amid &arg2,1,1
|
||||||
|
clc
|
||||||
|
lda &arg1
|
||||||
|
adc &arg2
|
||||||
|
sta &dest
|
||||||
|
lda &arg1+2
|
||||||
|
aif "&ch"="#",.a
|
||||||
|
adc &arg2+2
|
||||||
|
ago .b
|
||||||
|
.a
|
||||||
|
adc &arg2|-16
|
||||||
|
.b
|
||||||
|
sta &dest+2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Destroy &a1
|
||||||
|
&lab gsos $2002,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab NewLine &a1
|
||||||
|
&lab gsos $2011,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Read &a1
|
||||||
|
&lab gsos $2012,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jcs &loc
|
||||||
|
&lab bcc *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Int2Dec &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $260b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab sub2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab sec
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .sub
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .sub
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .sub
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.sub
|
||||||
|
sbc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tputs &a1
|
||||||
|
&lab ph4 &a1(3)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tputs
|
||||||
|
case off
|
||||||
|
MEND
|
588
bin/gsh/M/invoke.mac
Normal file
588
bin/gsh/M/invoke.mac
Normal file
|
@ -0,0 +1,588 @@
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab SetInGlobals &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
Tool $090c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GSStr &string
|
||||||
|
&lab dc i2'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Open &a1
|
||||||
|
&lab gsos $2010,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Close &a1
|
||||||
|
&lab gsos $2014,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab jcs &loc
|
||||||
|
&lab bcc *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD2 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #&val
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tcnewpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl tcnewpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab settpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl settpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab ora2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
ora &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jne &loc
|
||||||
|
&lab beq *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab PopVariables &a1
|
||||||
|
&lab p16 $117,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab PushVariables &a1
|
||||||
|
&lab p16 $118,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab SetPrefix &a1
|
||||||
|
&lab gsos $2009,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetFileInfo &a1
|
||||||
|
&lab gsos $2006,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab unlock &a1
|
||||||
|
&lab stz &a1
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab key
|
||||||
|
&lab dc i2'0'
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab lock &a1
|
||||||
|
&lab lda #1
|
||||||
|
tsb &a1
|
||||||
|
beq *+6
|
||||||
|
cop $7F
|
||||||
|
bra *-7
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab REDIRECT &a1
|
||||||
|
&lab p16 $110,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab fork &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl fork
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab SetInputDevice &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
Tool $0f0c
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab SetOutputDevice &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
Tool $100c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tctpgrp &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tctpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab dup2 &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl dup2
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab swait &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl swait
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab ssignal &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl ssignal
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab screate &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl screate
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab sdelete &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl sdelete
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab NewHandle &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph4 &a1(4)
|
||||||
|
tool $0902
|
||||||
|
pl4 &a2
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab FindHandle &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph4 &a1
|
||||||
|
tool $1a02
|
||||||
|
pl4 &a2
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab PtrToHand &a1
|
||||||
|
&lab ph4 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph4 &a1(3)
|
||||||
|
tool $2802
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab pl4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"<>"{",.chk
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ldy #2
|
||||||
|
pla
|
||||||
|
sta (&parm),y
|
||||||
|
ago .shorten
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"[",.chk2
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ldy #2
|
||||||
|
pla
|
||||||
|
sta &parm,y
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"@",.absolute
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
pl&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
pl&char2
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
pla
|
||||||
|
sta &parm+2
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab kill &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl kill
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab getpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl getpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab sigpause &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl sigpause
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab signal &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl signal
|
||||||
|
case off
|
||||||
|
MEND
|
527
bin/gsh/M/jobs.mac
Normal file
527
bin/gsh/M/jobs.mac
Normal file
|
@ -0,0 +1,527 @@
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD2 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #&val
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab getpid
|
||||||
|
&lab case on
|
||||||
|
jsl getpid
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab ora2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
ora &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Dec2Int &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
Tool $280b
|
||||||
|
pl2 &a2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Int2Dec &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $260b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD4 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #<&val
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda #+(&val)|-16
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Set_Variable &a1
|
||||||
|
&lab p16 $106,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab wait &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl wait
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jne &loc
|
||||||
|
&lab beq *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab dey2
|
||||||
|
&lab dey
|
||||||
|
dey
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab kill &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl kill
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab sigsetmask &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl sigsetmask
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab sigblock &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl sigblock
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab tctpgrp &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tctpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab sigpause &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl sigpause
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab getpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl getpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab jcs &loc
|
||||||
|
&lab bcc *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jcc &loc
|
||||||
|
&lab bcs *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
297
bin/gsh/M/main.mac
Normal file
297
bin/gsh/M/main.mac
Normal file
|
@ -0,0 +1,297 @@
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ErrWriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $210c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab kernStatus &a1
|
||||||
|
&lab pha
|
||||||
|
ldx #$603
|
||||||
|
jsl $E10008
|
||||||
|
pl2 &a1
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add4 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &ch
|
||||||
|
&ch amid &arg2,1,1
|
||||||
|
clc
|
||||||
|
lda &arg1
|
||||||
|
adc &arg2
|
||||||
|
sta &dest
|
||||||
|
lda &arg1+2
|
||||||
|
aif "&ch"="#",.a
|
||||||
|
adc &arg2+2
|
||||||
|
ago .b
|
||||||
|
.a
|
||||||
|
adc &arg2|-16
|
||||||
|
.b
|
||||||
|
sta &dest+2
|
||||||
|
mend
|
304
bin/gsh/M/orca.mac
Normal file
304
bin/gsh/M/orca.mac
Normal file
|
@ -0,0 +1,304 @@
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny2
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jcc &loc
|
||||||
|
&lab bcs *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ExpandPath &a1
|
||||||
|
&lab gsos $200E,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab SET_LINFOGS &a1
|
||||||
|
&lab p16 $142,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
374
bin/gsh/M/prompt.mac
Normal file
374
bin/gsh/M/prompt.mac
Normal file
|
@ -0,0 +1,374 @@
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $200c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteChar &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
Tool $180c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Int2Dec &a1
|
||||||
|
&lab ph2 &a1(1)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph2 &a1(4)
|
||||||
|
Tool $260b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ReadTimeHex &a1
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
tool $0d03
|
||||||
|
pl2 &a1(1)
|
||||||
|
pl2 &a1(2)
|
||||||
|
pl2 &a1(3)
|
||||||
|
pl2 &a1(4)
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab sub2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab sec
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .sub
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .sub
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .sub
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.sub
|
||||||
|
sbc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab if2 &var,&rel,&val,&label
|
||||||
|
&lab ago .skip
|
||||||
|
ble
|
||||||
|
bgt
|
||||||
|
.skip
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&char1 amid &var,1,1
|
||||||
|
&char2 amid &var,2,1
|
||||||
|
aif "&char1"="@",.index
|
||||||
|
lda &var
|
||||||
|
.cmp
|
||||||
|
cmp &val
|
||||||
|
ago .branch
|
||||||
|
.index
|
||||||
|
aif "&char2"="x",.x1
|
||||||
|
aif "&char2"="X",.x1
|
||||||
|
aif "&char2"="y",.y1
|
||||||
|
aif "&char2"="Y",.y1
|
||||||
|
ago ^cmp
|
||||||
|
.x1
|
||||||
|
cpx &val
|
||||||
|
ago .branch
|
||||||
|
.y1
|
||||||
|
cpy &val
|
||||||
|
.branch
|
||||||
|
&char1 amid &rel,1,1
|
||||||
|
aif "&char1"="@",.done
|
||||||
|
b&rel &label
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab bgt &loc
|
||||||
|
&lab beq *+4
|
||||||
|
bcs &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ble &loc
|
||||||
|
&lab bcc &loc
|
||||||
|
beq &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GetPrefix &a1
|
||||||
|
&lab gsos $200A,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $1c0c
|
||||||
|
mend
|
405
bin/gsh/M/shell.mac
Normal file
405
bin/gsh/M/shell.mac
Normal file
|
@ -0,0 +1,405 @@
|
||||||
|
MACRO
|
||||||
|
&lab Quit &a1
|
||||||
|
&lab gsos $2029,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab WriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $200c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab GSStr &string
|
||||||
|
&lab dc i2'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Open &a1
|
||||||
|
&lab gsos $2010,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab signal &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl signal
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab setsystemvector &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl setsystemvector
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab tcnewpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl tcnewpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab settpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl settpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab getpid
|
||||||
|
&lab case on
|
||||||
|
jsl getpid
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab ora2 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &char
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
ora &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ErrWriteCString &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
Tool $210c
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab PopVariables &a1
|
||||||
|
&lab p16 $117,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&l dosin &adr
|
||||||
|
&l dc i"l:~&sysname&syscnt"
|
||||||
|
~&sysname&syscnt dc c"&adr"
|
||||||
|
mend
|
185
bin/gsh/M/shellutil.mac
Normal file
185
bin/gsh/M/shellutil.mac
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab unlock &a1
|
||||||
|
&lab stz &a1
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab key
|
||||||
|
&lab dc i2'0'
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab lock &a1
|
||||||
|
&lab lda #1
|
||||||
|
tsb &a1
|
||||||
|
beq *+6
|
||||||
|
cop $7F
|
||||||
|
bra *-7
|
||||||
|
MEND
|
338
bin/gsh/M/shellvar.mac
Normal file
338
bin/gsh/M/shellvar.mac
Normal file
|
@ -0,0 +1,338 @@
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab LD2 &val,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda #&val
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab PopVariables &a1
|
||||||
|
&lab p16 $117,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab PushVariables &a1
|
||||||
|
&lab p16 $118,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jeq &loc
|
||||||
|
&lab bne *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_VARIABLE &a1
|
||||||
|
&lab p16 $10B,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab iny2
|
||||||
|
&lab iny
|
||||||
|
iny
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ERROR &a1
|
||||||
|
&lab p16 $105,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Set_Variable &a1
|
||||||
|
&lab p16 $106,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab READ_INDEXED &a1
|
||||||
|
&lab p16 $108,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab UnsetVariable &a1
|
||||||
|
&lab p16 $115,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab EXPORT &a1
|
||||||
|
&lab p16 $116,&a1
|
||||||
|
mend
|
92
bin/gsh/M/stdio.mac
Normal file
92
bin/gsh/M/stdio.mac
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Write &a1
|
||||||
|
&lab gsos $2013,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab gsos &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab unlock &a1
|
||||||
|
&lab stz &a1
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab lock &a1
|
||||||
|
&lab lda #1
|
||||||
|
tsb &a1
|
||||||
|
beq *+6
|
||||||
|
cop $7F
|
||||||
|
bra *-7
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab key
|
||||||
|
&lab dc i2'0'
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab Read &a1
|
||||||
|
&lab gsos $2012,&a1
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Flush &a1
|
||||||
|
&lab gsos $2015,&a1
|
||||||
|
mend
|
355
bin/gsh/M/sv.mac
Normal file
355
bin/gsh/M/sv.mac
Normal file
|
@ -0,0 +1,355 @@
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add4 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &ch
|
||||||
|
&ch amid &arg2,1,1
|
||||||
|
clc
|
||||||
|
lda &arg1
|
||||||
|
adc &arg2
|
||||||
|
sta &dest
|
||||||
|
lda &arg1+2
|
||||||
|
aif "&ch"="#",.a
|
||||||
|
adc &arg2+2
|
||||||
|
ago .b
|
||||||
|
.a
|
||||||
|
adc &arg2|-16
|
||||||
|
.b
|
||||||
|
sta &dest+2
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab sub4 &arg1,&arg2,&dest
|
||||||
|
&lab anop
|
||||||
|
lclc &ch
|
||||||
|
&ch amid &arg2,1,1
|
||||||
|
sec
|
||||||
|
lda &arg1
|
||||||
|
sbc &arg2
|
||||||
|
sta &dest
|
||||||
|
lda &arg1+2
|
||||||
|
aif "&ch"="#",.a
|
||||||
|
sbc &arg2+2
|
||||||
|
ago .b
|
||||||
|
.a
|
||||||
|
sbc &arg2|-16
|
||||||
|
.b
|
||||||
|
sta &dest+2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab add2 &arg1,&arg2,&dest
|
||||||
|
lclc &char
|
||||||
|
&lab clc
|
||||||
|
&char amid &arg1,1,1
|
||||||
|
aif "&char"="@",.at1
|
||||||
|
lda &arg1
|
||||||
|
ago .add
|
||||||
|
.at1
|
||||||
|
&char amid &arg1,2,1
|
||||||
|
aif "&char"="x",.x1
|
||||||
|
aif "&char"="X",.x1
|
||||||
|
aif "&char"="y",.y1
|
||||||
|
aif "&char"="Y",.y1
|
||||||
|
ago .add
|
||||||
|
.x1
|
||||||
|
txa
|
||||||
|
ago .add
|
||||||
|
.y1
|
||||||
|
tya
|
||||||
|
.add
|
||||||
|
adc &arg2
|
||||||
|
&char amid &dest,1,1
|
||||||
|
aif "&char"="@",.at2
|
||||||
|
sta &dest
|
||||||
|
ago .b
|
||||||
|
.at2
|
||||||
|
&char amid &dest,2,1
|
||||||
|
aif "&char"="x",.x2
|
||||||
|
aif "&char"="X",.x2
|
||||||
|
aif "&char"="y",.y2
|
||||||
|
aif "&char"="Y",.y2
|
||||||
|
ago .b
|
||||||
|
.x2
|
||||||
|
tax
|
||||||
|
ago .b
|
||||||
|
.y2
|
||||||
|
tay
|
||||||
|
.b
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab UDivide &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph2 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
Tool $0b0b
|
||||||
|
pl2 &a2(1)
|
||||||
|
pl2 &a2(2)
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
pl&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing Closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab long &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi on
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa on
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
rep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab short &stat
|
||||||
|
&lab anop
|
||||||
|
lcla &t
|
||||||
|
lcla &len
|
||||||
|
lclc &ch
|
||||||
|
&t seta 0
|
||||||
|
&len seta l:&stat
|
||||||
|
.a
|
||||||
|
aif &len=0,.b
|
||||||
|
&ch amid &stat,&len,1
|
||||||
|
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
|
||||||
|
aif ("&ch"="a").or.("&ch"="m"),.m
|
||||||
|
.c
|
||||||
|
&len seta &len-1
|
||||||
|
ago ^a
|
||||||
|
.i
|
||||||
|
longi off
|
||||||
|
&t seta &t+16
|
||||||
|
ago ^c
|
||||||
|
.m
|
||||||
|
longa off
|
||||||
|
&t seta &t+32
|
||||||
|
ago ^c
|
||||||
|
.b
|
||||||
|
aif &t=0,.d
|
||||||
|
sep #&t
|
||||||
|
.d
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab MV2 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab jmi &loc
|
||||||
|
&lab bpl *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab jcc &loc
|
||||||
|
&lab bcs *+5
|
||||||
|
jmp &loc
|
||||||
|
mend
|
264
bin/gsh/M/term.mac
Normal file
264
bin/gsh/M/term.mac
Normal file
|
@ -0,0 +1,264 @@
|
||||||
|
MACRO
|
||||||
|
&lab tgetent &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tgetent
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab tgetstr &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tgetstr
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab tputs &a1
|
||||||
|
&lab ph4 &a1(3)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tputs
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab MV4 &src,&adr
|
||||||
|
&lab lcla &count
|
||||||
|
lda &src
|
||||||
|
&count seta 1
|
||||||
|
.loop1
|
||||||
|
sta &adr(&count)
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.part2
|
||||||
|
ago ^loop1
|
||||||
|
.part2
|
||||||
|
lda &src+2
|
||||||
|
&count seta 1
|
||||||
|
.loop2
|
||||||
|
sta &adr(&count)+2
|
||||||
|
&count seta &count+1
|
||||||
|
aif &count>c:&adr,.done
|
||||||
|
ago ^loop2
|
||||||
|
.done
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab Str &string
|
||||||
|
&lab dc i1'L:&string'
|
||||||
|
dc c"&string"
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab Set_Variable &a1
|
||||||
|
&lab p16 $106,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab p16 &a1,&a2
|
||||||
|
&lab jsl $E100A8
|
||||||
|
dc i2'&a1'
|
||||||
|
dc i4'&a2'
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab EXPORT &a1
|
||||||
|
&lab p16 $116,&a1
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ioctl &a1
|
||||||
|
&lab ph4 &a1(3)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl ioctl
|
||||||
|
case off
|
||||||
|
MEND
|
87
bin/gsh/Makefile
Normal file
87
bin/gsh/Makefile
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#
|
||||||
|
# GNO Shell Makefile
|
||||||
|
# by T Meekins
|
||||||
|
#
|
||||||
|
|
||||||
|
o/main.root: main.asm
|
||||||
|
purge ; compile main.asm keep=o/main
|
||||||
|
|
||||||
|
o/shell.root: shell.asm m/shell.mac
|
||||||
|
purge ; compile shell.asm keep=o/shell
|
||||||
|
|
||||||
|
o/history.root: history.asm m/history.mac
|
||||||
|
purge ; compile history.asm keep=o/history
|
||||||
|
|
||||||
|
o/prompt.root: prompt.asm m/prompt.mac
|
||||||
|
purge ; compile prompt.asm keep=o/prompt
|
||||||
|
|
||||||
|
o/cmd.root: cmd.asm m/cmd.mac
|
||||||
|
purge ; compile cmd.asm keep=o/cmd
|
||||||
|
|
||||||
|
o/expand.root: expand.asm m/expand.mac
|
||||||
|
purge ; compile expand.asm keep=o/expand
|
||||||
|
|
||||||
|
o/invoke.root: invoke.asm m/invoke.mac
|
||||||
|
purge ; compile invoke.asm keep=o/invoke
|
||||||
|
|
||||||
|
o/shellutil.root: shellutil.asm m/shellutil.mac
|
||||||
|
purge ; compile shellutil.asm keep=o/shellutil
|
||||||
|
|
||||||
|
o/builtin.root: builtin.asm m/builtin.mac
|
||||||
|
purge ; compile builtin.asm keep=o/builtin
|
||||||
|
|
||||||
|
o/hash.root: hash.asm m/hash.mac
|
||||||
|
purge ; compile hash.asm keep=o/hash
|
||||||
|
|
||||||
|
o/alias.root: alias.asm m/alias.mac
|
||||||
|
purge ; compile alias.asm keep=o/alias
|
||||||
|
|
||||||
|
o/dir.root: dir.asm m/dir.mac
|
||||||
|
purge ; compile dir.asm keep=o/dir
|
||||||
|
|
||||||
|
o/shellvar.root: shellvar.asm m/shellvar.mac
|
||||||
|
purge ; compile shellvar.asm keep=o/shellvar
|
||||||
|
|
||||||
|
o/jobs.root: jobs.asm m/jobs.mac
|
||||||
|
purge ; compile jobs.asm keep=o/jobs
|
||||||
|
|
||||||
|
o/sv.root: sv.asm m/sv.mac
|
||||||
|
purge ; compile sv.asm keep=o/sv
|
||||||
|
|
||||||
|
o/stdio.root: stdio.asm m/stdio.mac
|
||||||
|
purge ; compile stdio.asm keep=o/stdio
|
||||||
|
|
||||||
|
o/orca.root: orca.asm m/orca.mac
|
||||||
|
purge ; compile orca.asm keep=o/orca
|
||||||
|
|
||||||
|
o/edit.root: edit.asm m/edit.mac
|
||||||
|
purge ; compile edit.asm keep=o/edit
|
||||||
|
|
||||||
|
o/term.root: term.asm m/term.mac
|
||||||
|
purge ; compile term.asm keep=o/term
|
||||||
|
|
||||||
|
o/bufpool.root: bufpool.asm m/bufpool.mac
|
||||||
|
purge ; compile bufpool.asm keep=o/bufpool
|
||||||
|
|
||||||
|
shell: o/main.root \
|
||||||
|
o/shell.root \
|
||||||
|
o/history.root \
|
||||||
|
o/prompt.root \
|
||||||
|
o/cmd.root \
|
||||||
|
o/expand.root \
|
||||||
|
o/invoke.root \
|
||||||
|
o/shellutil.root \
|
||||||
|
o/builtin.root \
|
||||||
|
o/hash.root \
|
||||||
|
o/alias.root \
|
||||||
|
o/shellvar.root \
|
||||||
|
o/jobs.root \
|
||||||
|
o/dir.root \
|
||||||
|
o/sv.root \
|
||||||
|
o/stdio.root \
|
||||||
|
o/orca.root \
|
||||||
|
o/edit.root \
|
||||||
|
o/term.root \
|
||||||
|
o/bufpool.root \
|
||||||
|
direct.root
|
||||||
|
pwd ; purge ; compile link.script keep=gsh
|
44
bin/gsh/To.Do
Normal file
44
bin/gsh/To.Do
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
Need to modify Tim's mutex code to be:
|
||||||
|
|
||||||
|
t lda #1
|
||||||
|
tsb mutex
|
||||||
|
beq go
|
||||||
|
cop $7F
|
||||||
|
bra t
|
||||||
|
go ; execute code here
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
coolish handling of setdebug by editor.
|
||||||
|
|
||||||
|
When building the EXE hash table, duplicate entries oughta should be ignored.
|
||||||
|
|
||||||
|
When a background process finishes and there's text in the input buffer,
|
||||||
|
the next keypress correctly reprints the edit line but the key itself does
|
||||||
|
not get put in the buffer.
|
||||||
|
|
||||||
|
running a process in the background from inside a script (not 'source',
|
||||||
|
but executing the script as a command) causes the shell to wait for that
|
||||||
|
background process to end - not exactly what we want.
|
||||||
|
|
||||||
|
recursive aliases.
|
||||||
|
|
||||||
|
multiple files for 'edit'.
|
||||||
|
|
||||||
|
'df' lists a bunch appleshare shit.
|
||||||
|
|
||||||
|
change updatevars to do a read_variable for better performance (and
|
||||||
|
for correctness!)
|
||||||
|
|
||||||
|
-a in ps (and any other redeemable switches)
|
||||||
|
|
||||||
|
job control monitor for defunct processes when waiting.
|
||||||
|
|
||||||
|
usage for alias and hash
|
||||||
|
|
||||||
|
job control needs to save tty information.
|
||||||
|
|
||||||
|
echo should use octal and hex \12 is dec, \012 is octal, \x12 is hex.
|
||||||
|
|
||||||
|
write new memory management.
|
||||||
|
|
||||||
|
write history expansion.
|
158
bin/gsh/UpdateLog
Normal file
158
bin/gsh/UpdateLog
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
GSH 1.1 UPDATES...
|
||||||
|
|
||||||
|
2/25/92 d01 - fixed a problem with the command-line aborting after certain
|
||||||
|
built-ins are run.
|
||||||
|
4/03/92 d02 - .ttya and .ttyb are displayed as 'ta' and 'tb' respectively in
|
||||||
|
'ps'.
|
||||||
|
- "USER" field has been renamed to "MMID" in 'ps'.
|
||||||
|
d03 - removed all the extra newlines around 'There are stopped jobs'
|
||||||
|
message.
|
||||||
|
- 'exit' in a shell script aborts the script, instead of quitting
|
||||||
|
gsh itself.
|
||||||
|
- when getting a 'There are stopped jobs' message, a second
|
||||||
|
attempt to exit the shell will result in all jobs being killed
|
||||||
|
and the shell will exit. No commands may appear between the
|
||||||
|
two attempts to exit. This is basically just like csh behaviour.
|
||||||
|
d04 - motd pathname has been changed to '31:etc:motd' where 31 is the
|
||||||
|
location of GNO, not the user directory. eventually motd will
|
||||||
|
be removed from gsh and will be handled by login or something
|
||||||
|
similar.
|
||||||
|
4/07/92 d05 - ^D and TAB expansion now properly works on */ boot prefix.
|
||||||
|
4/13/92 d06 - started work on new string vector library.
|
||||||
|
- started new builtin - 'hash' to display all hashed files.
|
||||||
|
Extremely preliminary.
|
||||||
|
4/14/92 d07 - 'hash' now uses string vectors to build the hash list for
|
||||||
|
displaying
|
||||||
|
- fixed a problem if no files were hashed.
|
||||||
|
- sv_alloc now makes sure there is an extra null at the end
|
||||||
|
of the allocated string vector.
|
||||||
|
4/20/92 d08 - 'which' puts the filename after the path for commands in
|
||||||
|
the current directory.
|
||||||
|
d09 - wrote a string vector function for printing the string
|
||||||
|
vectors in columns like 'ls'. 'hash' now calls this.
|
||||||
|
4/21/92 d10 - wrote routine for sorting string vectors...'hash' now sorts the
|
||||||
|
list...
|
||||||
|
4/23/92 d11 - full directory stack support!! pushd, popd, and dirs!!
|
||||||
|
d12 - 'ps' displays 'nu' for the .null driver under TT field.
|
||||||
|
4/25/92 d13 - Added '-l' option to 'kill'.
|
||||||
|
6/22/92 d14 - Began writing custom stdio for the shell using GS/OS output.
|
||||||
|
6/23/92 - minor optimization to alias hashing.
|
||||||
|
- finished stdout and stderr for gsh.
|
||||||
|
d15 - history file is no longer deleted on gsh start-up
|
||||||
|
- fixed '~' printer used in 'dirs'. /usr2/ was displayed as
|
||||||
|
~2 if $home was /usr. Looked real dumb :) and was incorrect.
|
||||||
|
- optimizations to job control
|
||||||
|
d16 - echo flushes the stdio when finished.
|
||||||
|
6/24/92 - fixed bug in system() call vector..make should work better now :)
|
||||||
|
- added a newline after 'pwd'.
|
||||||
|
- wrote 'edit' built-in.
|
||||||
|
6/26/92 d17 - began work on stdin for gsh. Uses GS/OS, ioctl(), etc...
|
||||||
|
- began rewriting editor. Now uses key translation tables and
|
||||||
|
command jump tables.
|
||||||
|
- editor now accepts multiple character commands.
|
||||||
|
6/27/92 - further work on editor
|
||||||
|
- started work on termcap support in gsh. most command-line
|
||||||
|
editing uses termcap now.
|
||||||
|
6/28/92 - continued work on editor and termcap
|
||||||
|
- 'clear' and 'echo' builtins now use termcap.
|
||||||
|
- prompt now uses termcap.
|
||||||
|
- hacked up a quick 'tset' builtin.
|
||||||
|
- wrote keybinding function, termcap arrow keys now bound!
|
||||||
|
- beta test release sent out
|
||||||
|
6/29/92 d18 - if alias 'precmd' is defined, it is executed before drawing
|
||||||
|
each prompt.
|
||||||
|
- if $pushdsilent is set, then directory stack not displayed
|
||||||
|
after 'pushd' and 'popd'.
|
||||||
|
- termcap optimizations for history mechanism in editor.
|
||||||
|
- termcap optimizations for kill-line and kill-end-of-line.
|
||||||
|
- fixed bug in overwrite mode of editor...required too many
|
||||||
|
returns to end line -> rts's weren't being pulled off the
|
||||||
|
stack :)
|
||||||
|
6/30/92 - fixed a bug in the 'which' command when displaying files in cwd.
|
||||||
|
- the cursor is now left on when running applications.
|
||||||
|
- added '-c' option to gsh command-line
|
||||||
|
- wrote 'source' built-in
|
||||||
|
7/04/92 - fixed two bugs in prompt display code.
|
||||||
|
7/17/92 - fixed puts to not choke on NULL strings.
|
||||||
|
7/21/92 - Temporarily added Push/PopVariables to the code
|
||||||
|
- ospeed is now set so that padding can be done by termcap.
|
||||||
|
This fixed the dropped characters on my Xerox terminal when
|
||||||
|
doing screen clears.
|
||||||
|
- fixed a bug in 'tset'. Was doing a jsr instead of jsl. oops.
|
||||||
|
- set term can be in gshrc w/o manually doing a tset now.
|
||||||
|
- 'ps' now scans job list to find names of 'forked' processes.
|
||||||
|
- 'ps' nows displays tty numbers, since the ttyname is set
|
||||||
|
in 31/etc/ttys and not necessarily second-guessed by gsh.
|
||||||
|
7/25/92 - fixed cursor off problems.
|
||||||
|
8/26/92 d19 - larger number of builtins can be redirected or piped.
|
||||||
|
- Open-Apple is now mapped to meta (ESC).
|
||||||
|
- The editor tells gnocon to translate arrows into VT100 codes.
|
||||||
|
- fixed editor bug clearing entire line.
|
||||||
|
- wrote 'bindkey' built-in.
|
||||||
|
8/27/92 d20 - faster built-in searching.
|
||||||
|
- wrote 'setenv' builtin.
|
||||||
|
8/28/92 - termcap optimizations to word completion
|
||||||
|
- word completion now matches variables if word starts with '$'.
|
||||||
|
8/29/92 - only executuables are expanded if the word is a command. All
|
||||||
|
files are expanded for arguments.
|
||||||
|
8/30/92 - words to complete no longer need to be separated with spaces,
|
||||||
|
';','|', and '&' are now also recognized.
|
||||||
|
9/01/92 - 'cd' no longer reports bad pathname syntax if $home not set.
|
||||||
|
- 'pid' parsing now does syntax checking :)
|
||||||
|
- kill won't allow killing process 0
|
||||||
|
- changed 'jobs' invocation from method 0 to method 1.
|
||||||
|
- word completion will not occur if the word contains an '=',
|
||||||
|
single quote or double quote.
|
||||||
|
9/03/92 - fixed memory trashing problem in 'source'
|
||||||
|
9/04/92 - 'ps' only displays processes with the users uid. Be sure to
|
||||||
|
use login, or you'll be the kernel's uid and get to see all
|
||||||
|
of the kernel's processes as your own.
|
||||||
|
9/10/92 - forgot to 'clc' when alias not found in 'alias foo'.
|
||||||
|
9/20/92 - fixed open-apple mapping
|
||||||
|
- changed keyboard mapping
|
||||||
|
- tab expands directories as the command
|
||||||
|
- set problem with '-f' fixed
|
||||||
|
9/21/92 - fixed 'cd' with no arguments.
|
||||||
|
- fixed 'set foo' and 'setenv foo'.
|
||||||
|
- fixed bug again in 'cd'.
|
||||||
|
- 'set' and 'setenv' list exported variable names in upper case
|
||||||
|
- fixed a probelm in puts when passed a null pointer.
|
||||||
|
- fixed pointer bug in '~' compactor
|
||||||
|
- wrote 256 byte buffer pool
|
||||||
|
9/22/92 - fixed parsing bug when parsing two or more command-lines
|
||||||
|
simultaneously.
|
||||||
|
- wrote 1024 byte buffer pool.
|
||||||
|
- word completion now matches built-ins
|
||||||
|
- wordmatching ignores matches if the suffix is contained in
|
||||||
|
the $fignore variable.
|
||||||
|
10/31/92 d21 - fixed bug in piping mechanism.
|
||||||
|
11/04/92 - fixed hashing problems.
|
||||||
|
11/17/92 - new builtin 'commands' lists all built-in commands. Try aliasing
|
||||||
|
help to this for beginning users.
|
||||||
|
01/17/93 b01 - fixed prefix not printing correctly if zero length prefix.
|
||||||
|
- word completion will expand to proper case.
|
||||||
|
01/20/93 b02 - removed motd printing from gsh
|
||||||
|
02/08/93 - fixed job control setting of terminal when background job
|
||||||
|
completes.
|
||||||
|
02/09/93 - ^C & ^Z printing removed from the shell. The kernel will do
|
||||||
|
this now.
|
||||||
|
02/17/93 b03 - gshrc is now read as '@:gshrc'
|
||||||
|
03/02/93 - 'set' automatically detects changing $term and auto-peforms a
|
||||||
|
tset. manually typing 'tset' is no longer required though it is
|
||||||
|
still included.
|
||||||
|
- prompts can now contain \n,\r,\t,\b.
|
||||||
|
03/10/93 - updated automatic variable setting code. works faster now.
|
||||||
|
- optimized low-level string routines
|
||||||
|
03/25/93 - fixed NULL commands aborting entire command-lines.
|
||||||
|
04/04/93 - history commands can now be greater than 256 characters, though
|
||||||
|
when being read, they are clipped to 1024.
|
||||||
|
- the history file location has been moved to '@:history'
|
||||||
|
- if $ignoreeof is set, then EOF (^D) will not quit the shell.
|
||||||
|
- %U and %u will start and end underlining in prompts.
|
||||||
|
04/22/93 b04 - 'df' displays device numbers
|
||||||
|
- gsh now takes commands as command-line input. ie.,
|
||||||
|
'gsh echo hello, world' will start gsh then gsh will run echo.
|
||||||
|
- fixed a nasty shell script bug that basically rendered it useless.
|
||||||
|
- fixed memory trashing in shell scripts.
|
||||||
|
- fixed memory trashing in histories.
|
||||||
|
04/26/94 b05 - which no longers displays the command-name first.
|
798
bin/gsh/alias.asm
Normal file
798
bin/gsh/alias.asm
Normal file
|
@ -0,0 +1,798 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* ALIAS.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/alias
|
||||||
|
mcopy m/alias.mac
|
||||||
|
|
||||||
|
VTABSIZE gequ 17
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* ALIAS: builtin command
|
||||||
|
* syntax: alias [name [def]]
|
||||||
|
*
|
||||||
|
* set aliases
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
alias START
|
||||||
|
|
||||||
|
arg equ 1
|
||||||
|
space equ arg+4
|
||||||
|
argc equ space+3
|
||||||
|
argv equ argc+2
|
||||||
|
end equ argv+4
|
||||||
|
|
||||||
|
; subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
beq showall
|
||||||
|
dec a
|
||||||
|
beq showone
|
||||||
|
jmp setalias
|
||||||
|
|
||||||
|
showall jsl startalias
|
||||||
|
showloop jsl nextalias
|
||||||
|
sta arg
|
||||||
|
stx arg+2
|
||||||
|
ora arg+2
|
||||||
|
beq noshow
|
||||||
|
ldy #6
|
||||||
|
lda [arg],y
|
||||||
|
tax
|
||||||
|
ldy #4
|
||||||
|
lda [arg],y
|
||||||
|
jsr puts
|
||||||
|
lda #':'
|
||||||
|
jsr putchar
|
||||||
|
lda #' '
|
||||||
|
jsr putchar
|
||||||
|
ldy #10
|
||||||
|
lda [arg],y
|
||||||
|
tax
|
||||||
|
ldy #8
|
||||||
|
lda [arg],y
|
||||||
|
jsr puts
|
||||||
|
jsr newline
|
||||||
|
bra showloop
|
||||||
|
|
||||||
|
noshow jmp exit
|
||||||
|
|
||||||
|
showone ldy #4+2
|
||||||
|
lda [argv],y
|
||||||
|
tax
|
||||||
|
pha ;for findalias
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
jsr puts
|
||||||
|
lda #':'
|
||||||
|
jsr putchar
|
||||||
|
lda #' '
|
||||||
|
jsr putchar
|
||||||
|
jsl findalias
|
||||||
|
sta arg
|
||||||
|
stx arg+2
|
||||||
|
ora arg+2
|
||||||
|
beq notthere
|
||||||
|
lda arg
|
||||||
|
jsr puts
|
||||||
|
jsr newline
|
||||||
|
jmp exit
|
||||||
|
notthere ldx #^noalias
|
||||||
|
lda #noalias
|
||||||
|
jsr puts
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
setalias ldy #4+2 ;put alias name on stack
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
|
||||||
|
ph4 #2
|
||||||
|
jsl ~NEW
|
||||||
|
sta arg
|
||||||
|
stx arg+2
|
||||||
|
lda #0
|
||||||
|
sta [arg]
|
||||||
|
|
||||||
|
add2 argv,#8,argv
|
||||||
|
|
||||||
|
dec2 argc
|
||||||
|
|
||||||
|
buildalias lda argc
|
||||||
|
beq setit
|
||||||
|
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
lda [argv]
|
||||||
|
pha
|
||||||
|
jsr catcstr
|
||||||
|
stx arg+2
|
||||||
|
sta arg
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
ph4 #spacestr
|
||||||
|
jsr catcstr
|
||||||
|
stx arg+2
|
||||||
|
sta arg
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
dec argc
|
||||||
|
add2 argv,#4,argv
|
||||||
|
bra buildalias
|
||||||
|
|
||||||
|
setit pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsl addalias
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
exit lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
noalias dc c'Alias not defined',h'0d00'
|
||||||
|
spacestr dc c' ',h'00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* UNALIAS: builtin command
|
||||||
|
* syntax: unalias [var ...]
|
||||||
|
*
|
||||||
|
* removes each alias listed
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
unalias START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
argc equ space+3
|
||||||
|
argv equ argc+2
|
||||||
|
end equ argv+4
|
||||||
|
|
||||||
|
; subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
bne loop
|
||||||
|
|
||||||
|
ldx #^Usage
|
||||||
|
lda #USage
|
||||||
|
jsr errputs
|
||||||
|
bra done
|
||||||
|
|
||||||
|
loop add2 argv,#4,argv
|
||||||
|
dec argc
|
||||||
|
beq done
|
||||||
|
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
lda [argv]
|
||||||
|
pha
|
||||||
|
jsl removealias
|
||||||
|
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
Usage dc c'Usage: unalias name ...',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Init alias table
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
initalias START
|
||||||
|
|
||||||
|
using AliasData
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
ldy #VTABSIZE
|
||||||
|
tax #0
|
||||||
|
yahaha sta AliasTable,x
|
||||||
|
inx2
|
||||||
|
sta AliasTable,x
|
||||||
|
inx2
|
||||||
|
dey
|
||||||
|
bne yahaha
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Expand alias
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
expandalias START
|
||||||
|
|
||||||
|
outbuf equ 0
|
||||||
|
sub equ outbuf+4
|
||||||
|
word equ sub+4
|
||||||
|
buf equ word+4
|
||||||
|
space equ buf+4
|
||||||
|
|
||||||
|
subroutine (4:cmd),space
|
||||||
|
|
||||||
|
ph4 #1024
|
||||||
|
jsl ~NEW
|
||||||
|
stx buf+2
|
||||||
|
sta buf
|
||||||
|
stx outbuf+2
|
||||||
|
sta outbuf
|
||||||
|
jsl alloc1024
|
||||||
|
stx word+2
|
||||||
|
sta word
|
||||||
|
lda #0
|
||||||
|
sta [buf] ;In case we're called with empty string
|
||||||
|
;
|
||||||
|
; eat leading spaces
|
||||||
|
;
|
||||||
|
eatleader lda [cmd]
|
||||||
|
and #$FF
|
||||||
|
jeq done
|
||||||
|
cmp #' '
|
||||||
|
bne getword
|
||||||
|
inc cmd
|
||||||
|
sta [outbuf]
|
||||||
|
inc outbuf
|
||||||
|
bra eatleader
|
||||||
|
;
|
||||||
|
; find the leading word
|
||||||
|
;
|
||||||
|
getword short a
|
||||||
|
ldy #0
|
||||||
|
makeword lda [cmd],y
|
||||||
|
if2 @a,eq,#0,gotword
|
||||||
|
if2 @a,eq,#' ',gotword
|
||||||
|
if2 @a,eq,#';',gotword
|
||||||
|
if2 @a,eq,#'&',gotword
|
||||||
|
if2 @a,eq,#'|',gotword
|
||||||
|
if2 @a,eq,#'>',gotword
|
||||||
|
if2 @a,eq,#'<',gotword
|
||||||
|
if2 @a,eq,#13,gotword
|
||||||
|
if2 @a,eq,#9,gotword
|
||||||
|
if2 @a,eq,#10,gotword
|
||||||
|
sta [word],y
|
||||||
|
iny
|
||||||
|
bra makeword
|
||||||
|
;
|
||||||
|
; we got a word, now check if it's an alias
|
||||||
|
;
|
||||||
|
gotword lda #0
|
||||||
|
sta [word],y
|
||||||
|
long a
|
||||||
|
add2 @y,cmd,cmd
|
||||||
|
phy
|
||||||
|
pei (word+2)
|
||||||
|
pei (word)
|
||||||
|
jsl findalias
|
||||||
|
sta sub
|
||||||
|
stx sub+2
|
||||||
|
ora sub+2
|
||||||
|
beq noalias
|
||||||
|
;
|
||||||
|
; expand it, if you hadn't figured it out for yourself by now.
|
||||||
|
;
|
||||||
|
pla
|
||||||
|
ldy #0
|
||||||
|
putalias lda [sub],y
|
||||||
|
and #$FF
|
||||||
|
beq next
|
||||||
|
sta [outbuf]
|
||||||
|
inc outbuf
|
||||||
|
iny
|
||||||
|
bra putalias
|
||||||
|
;
|
||||||
|
; no alias, so just copy the original string
|
||||||
|
;
|
||||||
|
noalias plx
|
||||||
|
beq next
|
||||||
|
ldy #0
|
||||||
|
noalias2 lda [word],y
|
||||||
|
sta [outbuf]
|
||||||
|
inc outbuf
|
||||||
|
iny
|
||||||
|
dex
|
||||||
|
bne noalias2
|
||||||
|
;
|
||||||
|
; the alias is expanded, now copy until we reach the next command
|
||||||
|
;
|
||||||
|
next lda [cmd]
|
||||||
|
inc cmd
|
||||||
|
sta [outbuf]
|
||||||
|
inc outbuf
|
||||||
|
and #$FF
|
||||||
|
beq done
|
||||||
|
if2 @a,eq,#13,nextalias
|
||||||
|
if2 @a,eq,#';',nextalias
|
||||||
|
if2 @a,eq,#'&',nextalias
|
||||||
|
if2 @a,eq,#'|',nextalias
|
||||||
|
if2 @a,eq,#'\',backstabber
|
||||||
|
if2 @a,eq,#"'",singquoter
|
||||||
|
if2 @a,eq,#'"',doubquoter
|
||||||
|
bra next
|
||||||
|
backstabber lda [cmd]
|
||||||
|
inc cmd
|
||||||
|
sta [outbuf]
|
||||||
|
inc outbuf
|
||||||
|
and #$FF
|
||||||
|
beq done
|
||||||
|
bra next
|
||||||
|
singquoter lda [cmd]
|
||||||
|
inc cmd
|
||||||
|
sta [outbuf]
|
||||||
|
inc outbuf
|
||||||
|
and #$FF
|
||||||
|
beq done
|
||||||
|
if2 @a,ne,#"'",singquoter
|
||||||
|
bra next
|
||||||
|
doubquoter lda [cmd]
|
||||||
|
inc cmd
|
||||||
|
sta [outbuf]
|
||||||
|
inc outbuf
|
||||||
|
and #$FF
|
||||||
|
beq done
|
||||||
|
if2 @a,ne,#"'",singquoter
|
||||||
|
bra next
|
||||||
|
|
||||||
|
nextalias jmp eatleader
|
||||||
|
|
||||||
|
done ldx word+2
|
||||||
|
lda word
|
||||||
|
jsl free1024
|
||||||
|
|
||||||
|
return 4:buf
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Add alias to table
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
addalias START
|
||||||
|
|
||||||
|
using AliasData
|
||||||
|
|
||||||
|
tmp equ 0
|
||||||
|
ptr equ tmp+4
|
||||||
|
hashval equ ptr+4
|
||||||
|
space equ hashval+4
|
||||||
|
|
||||||
|
subroutine (4:aliasname,4:aliasval),space
|
||||||
|
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
jsl hashalias
|
||||||
|
sta hashval
|
||||||
|
|
||||||
|
tax
|
||||||
|
lda AliasTable,x
|
||||||
|
sta ptr
|
||||||
|
lda AliasTable+2,x
|
||||||
|
sta ptr+2
|
||||||
|
|
||||||
|
search lda ptr
|
||||||
|
ora ptr
|
||||||
|
beq notfound
|
||||||
|
ldy #4
|
||||||
|
lda [ptr],y
|
||||||
|
tax
|
||||||
|
ldy #4+2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
jsr cmpcstr
|
||||||
|
jeq replace
|
||||||
|
ldy #2
|
||||||
|
lda [ptr]
|
||||||
|
tax
|
||||||
|
lda [ptr],y
|
||||||
|
sta ptr+2
|
||||||
|
stx ptr
|
||||||
|
bra search
|
||||||
|
|
||||||
|
replace ldy #8+2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
ldy #8
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
jsl nullfree
|
||||||
|
pei (aliasval+2)
|
||||||
|
pei (aliasval)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta tmp
|
||||||
|
stx tmp+2
|
||||||
|
ldy #8
|
||||||
|
sta [ptr],y
|
||||||
|
ldy #8+2
|
||||||
|
txa
|
||||||
|
sta [ptr],y
|
||||||
|
pei (aliasval+2)
|
||||||
|
pei (aliasval)
|
||||||
|
pei (tmp+2)
|
||||||
|
pei (tmp)
|
||||||
|
jsr copycstr
|
||||||
|
bra done
|
||||||
|
|
||||||
|
notfound ph4 #4*3
|
||||||
|
jsl ~NEW
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
ldy #2
|
||||||
|
ldx hashval
|
||||||
|
lda AliasTable,x
|
||||||
|
sta [ptr]
|
||||||
|
lda AliasTable+2,x
|
||||||
|
sta [ptr],y
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta tmp
|
||||||
|
stx tmp+2
|
||||||
|
ldy #4
|
||||||
|
sta [ptr],y
|
||||||
|
ldy #4+2
|
||||||
|
txa
|
||||||
|
sta [ptr],y
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
pei (tmp+2)
|
||||||
|
pei (tmp)
|
||||||
|
jsr copycstr
|
||||||
|
pei (aliasval+2)
|
||||||
|
pei (aliasval)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta tmp
|
||||||
|
stx tmp+2
|
||||||
|
ldy #8
|
||||||
|
sta [ptr],y
|
||||||
|
ldy #8+2
|
||||||
|
txa
|
||||||
|
sta [ptr],y
|
||||||
|
pei (aliasval+2)
|
||||||
|
pei (aliasval)
|
||||||
|
pei (tmp+2)
|
||||||
|
pei (tmp)
|
||||||
|
jsr copycstr
|
||||||
|
ldx hashval
|
||||||
|
lda ptr
|
||||||
|
sta AliasTable,x
|
||||||
|
lda ptr+2
|
||||||
|
sta AliasTable+2,x
|
||||||
|
|
||||||
|
done return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Remove an alias
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
removealias START
|
||||||
|
|
||||||
|
using AliasData
|
||||||
|
|
||||||
|
oldptr equ 0
|
||||||
|
ptr equ oldptr+4
|
||||||
|
space equ ptr+4
|
||||||
|
|
||||||
|
subroutine (4:aliasname),space
|
||||||
|
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
jsl hashalias
|
||||||
|
tax
|
||||||
|
lda AliasTable,x
|
||||||
|
sta ptr
|
||||||
|
lda AliasTable+2,x
|
||||||
|
sta ptr+2
|
||||||
|
lda #^Aliastable
|
||||||
|
sta oldptr+2
|
||||||
|
clc
|
||||||
|
txa
|
||||||
|
adc #AliasTable
|
||||||
|
sta oldptr
|
||||||
|
|
||||||
|
searchloop ora2 ptr,ptr+2,@a
|
||||||
|
beq done
|
||||||
|
|
||||||
|
ldy #4+2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
ldy #4
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
jsr cmpcstr
|
||||||
|
beq foundit
|
||||||
|
mv4 ptr,oldptr
|
||||||
|
ldy #2
|
||||||
|
lda [ptr],y
|
||||||
|
tax
|
||||||
|
lda [ptr]
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
bra searchloop
|
||||||
|
|
||||||
|
foundit ldy #2
|
||||||
|
lda [ptr],y
|
||||||
|
sta [oldptr],y
|
||||||
|
lda [ptr]
|
||||||
|
sta [oldptr]
|
||||||
|
ldy #4+2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
ldy #4
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
jsl nullfree
|
||||||
|
ldy #8+2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
ldy #8
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
jsl nullfree
|
||||||
|
pei (ptr+2)
|
||||||
|
pei (ptr)
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
done return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Find an alias
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
findalias START
|
||||||
|
|
||||||
|
using AliasData
|
||||||
|
|
||||||
|
ptr equ 0
|
||||||
|
value equ ptr+4
|
||||||
|
space equ value+4
|
||||||
|
|
||||||
|
subroutine (4:aliasname),space
|
||||||
|
|
||||||
|
stz value
|
||||||
|
stz value+2
|
||||||
|
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
jsl hashalias
|
||||||
|
tax
|
||||||
|
lda AliasTable,x
|
||||||
|
sta ptr
|
||||||
|
lda AliasTable+2,x
|
||||||
|
sta ptr+2
|
||||||
|
|
||||||
|
searchloop ora2 ptr,ptr+2,@a
|
||||||
|
beq done
|
||||||
|
|
||||||
|
ldy #4+2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
ldy #4
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
pei (aliasname+2)
|
||||||
|
pei (aliasname)
|
||||||
|
jsr cmpcstr
|
||||||
|
beq foundit
|
||||||
|
ldy #2
|
||||||
|
lda [ptr],y
|
||||||
|
tax
|
||||||
|
lda [ptr]
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
bra searchloop
|
||||||
|
|
||||||
|
foundit ldy #8
|
||||||
|
lda [ptr],y
|
||||||
|
sta value
|
||||||
|
ldy #8+2
|
||||||
|
lda [ptr],y
|
||||||
|
sta value+2
|
||||||
|
|
||||||
|
done return 4:value
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Start alias
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
startalias START
|
||||||
|
|
||||||
|
using AliasData
|
||||||
|
|
||||||
|
stz AliasNum
|
||||||
|
mv4 AliasTable,AliasPtr
|
||||||
|
rtl
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Next alias
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
nextalias START
|
||||||
|
|
||||||
|
using AliasData
|
||||||
|
|
||||||
|
value equ 0
|
||||||
|
space equ value+4
|
||||||
|
|
||||||
|
subroutine (0:fubar),space
|
||||||
|
|
||||||
|
stz value
|
||||||
|
stz value+2
|
||||||
|
puke if2 AliasNum,cs,#VTABSIZE,done
|
||||||
|
|
||||||
|
ora2 AliasPtr,AliasPtr+2,@a
|
||||||
|
bne flush
|
||||||
|
inc AliasNum
|
||||||
|
lda AliasNum
|
||||||
|
asl2 a
|
||||||
|
tax
|
||||||
|
lda AliasTable,x
|
||||||
|
sta AliasPtr
|
||||||
|
lda AliasTable+2,x
|
||||||
|
sta AliasPtr+2
|
||||||
|
bra puke
|
||||||
|
|
||||||
|
flush mv4 AliasPtr,value
|
||||||
|
ldy #2
|
||||||
|
lda [value]
|
||||||
|
sta AliasPtr
|
||||||
|
lda [value],y
|
||||||
|
sta AliasPtr+2
|
||||||
|
|
||||||
|
done return 4:value
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Hash an alias
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
hashalias PRIVATE
|
||||||
|
|
||||||
|
hashval equ 0
|
||||||
|
space equ hashval+2
|
||||||
|
|
||||||
|
subroutine (4:p),space
|
||||||
|
|
||||||
|
lda #11
|
||||||
|
sta hashval
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
loop asl hashval
|
||||||
|
lda [p],y
|
||||||
|
and #$FF
|
||||||
|
beq done
|
||||||
|
clc
|
||||||
|
adc hashval
|
||||||
|
sta hashval
|
||||||
|
iny
|
||||||
|
bra loop
|
||||||
|
done UDivide (hashval,#VTABSIZE),(@a,@a)
|
||||||
|
|
||||||
|
asl2 a ;Make it an index.
|
||||||
|
sta hashval
|
||||||
|
|
||||||
|
return 2:hashval
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Alias data
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
AliasData DATA
|
||||||
|
|
||||||
|
AliasNum dc i2'0'
|
||||||
|
AliasPtr dc i4'0'
|
||||||
|
|
||||||
|
AliasTable ds VTABSIZE*4
|
||||||
|
|
||||||
|
END
|
176
bin/gsh/bufpool.asm
Normal file
176
bin/gsh/bufpool.asm
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* BUFPOOL
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* This is the buffer pool
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/bufpool
|
||||||
|
mcopy m/bufpool.mac
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* get a buffer of size 256
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
alloc256 START
|
||||||
|
|
||||||
|
using bufpool
|
||||||
|
|
||||||
|
lock pool256mutex
|
||||||
|
|
||||||
|
lda pool256
|
||||||
|
ora pool256+2
|
||||||
|
beq allocbuf
|
||||||
|
|
||||||
|
phd
|
||||||
|
ph4 pool256
|
||||||
|
tsc
|
||||||
|
tcd
|
||||||
|
lda [1]
|
||||||
|
sta pool256
|
||||||
|
ldy #2
|
||||||
|
lda [1],y
|
||||||
|
sta pool256+2
|
||||||
|
unlock pool256mutex
|
||||||
|
pla
|
||||||
|
plx
|
||||||
|
pld
|
||||||
|
rtl
|
||||||
|
|
||||||
|
allocbuf unlock pool256mutex
|
||||||
|
ph4 #256
|
||||||
|
jsl ~NEW
|
||||||
|
rtl
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* free a buffer of size 256
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
free256 START
|
||||||
|
|
||||||
|
using bufpool
|
||||||
|
|
||||||
|
phd
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
tsc
|
||||||
|
tcd
|
||||||
|
lock pool256mutex
|
||||||
|
lda pool256
|
||||||
|
sta [1]
|
||||||
|
ldy #2
|
||||||
|
lda pool256+2
|
||||||
|
sta [1],y
|
||||||
|
lda 1
|
||||||
|
sta pool256
|
||||||
|
lda 3
|
||||||
|
sta pool256+2
|
||||||
|
unlock pool256mutex
|
||||||
|
pla
|
||||||
|
plx
|
||||||
|
pld
|
||||||
|
rtl
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* get a buffer of size 1024
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
alloc1024 START
|
||||||
|
|
||||||
|
using bufpool
|
||||||
|
|
||||||
|
lock pool1024mutex
|
||||||
|
|
||||||
|
lda pool1024
|
||||||
|
ora pool1024+2
|
||||||
|
beq allocbuf
|
||||||
|
|
||||||
|
phd
|
||||||
|
ph4 pool1024
|
||||||
|
tsc
|
||||||
|
tcd
|
||||||
|
lda [1]
|
||||||
|
sta pool1024
|
||||||
|
ldy #2
|
||||||
|
lda [1],y
|
||||||
|
sta pool1024+2
|
||||||
|
unlock pool1024mutex
|
||||||
|
pla
|
||||||
|
plx
|
||||||
|
pld
|
||||||
|
rtl
|
||||||
|
|
||||||
|
allocbuf unlock pool1024mutex
|
||||||
|
ph4 #1024
|
||||||
|
jsl ~NEW
|
||||||
|
rtl
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* free a buffer of size 1024
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
free1024 START
|
||||||
|
|
||||||
|
using bufpool
|
||||||
|
|
||||||
|
phd
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
tsc
|
||||||
|
tcd
|
||||||
|
lock pool1024mutex
|
||||||
|
lda pool1024
|
||||||
|
sta [1]
|
||||||
|
ldy #2
|
||||||
|
lda pool1024+2
|
||||||
|
sta [1],y
|
||||||
|
lda 1
|
||||||
|
sta pool1024
|
||||||
|
lda 3
|
||||||
|
sta pool1024+2
|
||||||
|
unlock pool1024mutex
|
||||||
|
pla
|
||||||
|
plx
|
||||||
|
pld
|
||||||
|
rtl
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* buffer pool data
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
bufpool DATA
|
||||||
|
|
||||||
|
pool256 dc i4'0'
|
||||||
|
pool256mutex key
|
||||||
|
pool1024 dc i4'0'
|
||||||
|
pool1024mutex key
|
||||||
|
|
||||||
|
END
|
2061
bin/gsh/builtin.asm
Normal file
2061
bin/gsh/builtin.asm
Normal file
File diff suppressed because it is too large
Load Diff
1166
bin/gsh/cmd.asm
Normal file
1166
bin/gsh/cmd.asm
Normal file
File diff suppressed because it is too large
Load Diff
697
bin/gsh/dir.asm
Normal file
697
bin/gsh/dir.asm
Normal file
|
@ -0,0 +1,697 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* DIR.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Directory stack management
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/dir
|
||||||
|
mcopy m/dir.mac
|
||||||
|
|
||||||
|
MAXD gequ 50
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Initialize directory stack
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
InitDStack START
|
||||||
|
|
||||||
|
using DirData
|
||||||
|
|
||||||
|
stz tods
|
||||||
|
stz dirstack
|
||||||
|
stz dirstack+2
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* DIRS: builtin command
|
||||||
|
* syntax: dirs [-l]
|
||||||
|
*
|
||||||
|
* display the directory stack
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
dirs START
|
||||||
|
|
||||||
|
using DirData
|
||||||
|
|
||||||
|
arg equ 0
|
||||||
|
space equ arg+4
|
||||||
|
|
||||||
|
subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
beq showshort
|
||||||
|
dec a
|
||||||
|
bne using
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
sta arg
|
||||||
|
ldy #6
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
lda [arg]
|
||||||
|
and #$FF
|
||||||
|
cmp #'-'
|
||||||
|
bne using
|
||||||
|
ldy #1
|
||||||
|
lda [arg],y
|
||||||
|
cmp #'l'
|
||||||
|
beq showlong
|
||||||
|
|
||||||
|
using ldx #^usingstr
|
||||||
|
lda #usingstr
|
||||||
|
jsr errputs
|
||||||
|
bra exit
|
||||||
|
|
||||||
|
showlong jsl dotods
|
||||||
|
pea 0
|
||||||
|
jsl showdir
|
||||||
|
bra exit
|
||||||
|
|
||||||
|
showshort jsl dotods
|
||||||
|
pea 1
|
||||||
|
jsl showdir
|
||||||
|
|
||||||
|
exit return
|
||||||
|
|
||||||
|
usingstr dc c'usage: dirs [-l]',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* PUSHD: builtin command
|
||||||
|
* syntax: pushd [+n | dir]
|
||||||
|
*
|
||||||
|
* change directory and push
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
pushd START
|
||||||
|
|
||||||
|
using DirData
|
||||||
|
using vardata
|
||||||
|
|
||||||
|
count equ 0
|
||||||
|
p equ count+2
|
||||||
|
arg equ p+4
|
||||||
|
space equ arg+4
|
||||||
|
|
||||||
|
subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
beq xchange
|
||||||
|
dec a
|
||||||
|
bne usage
|
||||||
|
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
sta arg
|
||||||
|
ldy #6
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
lda [arg]
|
||||||
|
and #$FF
|
||||||
|
cmp #'+'
|
||||||
|
beq rotate
|
||||||
|
jmp godir
|
||||||
|
|
||||||
|
usage ldx #^usagestr
|
||||||
|
lda #usagestr
|
||||||
|
jsr errputs
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
xchange lda tods
|
||||||
|
bne xgoodie
|
||||||
|
ldx #^err1
|
||||||
|
lda #err1
|
||||||
|
jsr errputs
|
||||||
|
jmp exit
|
||||||
|
xgoodie jsl dotods
|
||||||
|
lda tods
|
||||||
|
dec a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tax
|
||||||
|
lda tods
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda dirstack,x
|
||||||
|
pha
|
||||||
|
lda dirstack,y
|
||||||
|
sta dirstack,x
|
||||||
|
pla
|
||||||
|
sta dirstack,y
|
||||||
|
lda dirstack+2,x
|
||||||
|
pha
|
||||||
|
lda dirstack+2,y
|
||||||
|
sta dirstack+2,x
|
||||||
|
pla
|
||||||
|
sta dirstack+2,y
|
||||||
|
jmp gototop
|
||||||
|
|
||||||
|
rotate add4 arg,#1,p
|
||||||
|
pei (p+2)
|
||||||
|
pei (p)
|
||||||
|
jsr cstrlen
|
||||||
|
tax
|
||||||
|
Dec2Int (p,@x,#0),@a
|
||||||
|
sta count
|
||||||
|
cmp #0
|
||||||
|
beq godir
|
||||||
|
lda tods
|
||||||
|
beq roterr
|
||||||
|
lda count
|
||||||
|
cmp tods
|
||||||
|
beq rotloop
|
||||||
|
bcc rotloop
|
||||||
|
|
||||||
|
roterr ldx #^err2
|
||||||
|
lda #err2
|
||||||
|
jsr errputs
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
rotloop lda tods
|
||||||
|
dec a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda dirstack+6,y
|
||||||
|
pha
|
||||||
|
lda dirstack+4,y
|
||||||
|
pha
|
||||||
|
rotloop2 lda dirstack,y
|
||||||
|
sta dirstack+4,y
|
||||||
|
lda dirstack+2,y
|
||||||
|
sta dirstack+6,y
|
||||||
|
cpy #0
|
||||||
|
beq nextrot
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
bra rotloop2
|
||||||
|
nextrot pla
|
||||||
|
sta dirstack
|
||||||
|
pla
|
||||||
|
sta dirstack+2
|
||||||
|
dec count
|
||||||
|
bne rotloop
|
||||||
|
bra gototop
|
||||||
|
|
||||||
|
godir jsl dotods
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsl gotodir
|
||||||
|
bne exit
|
||||||
|
|
||||||
|
inc tods
|
||||||
|
lda tods
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda #0
|
||||||
|
sta dirstack,y
|
||||||
|
sta dirstack+2,y
|
||||||
|
jsl dotods
|
||||||
|
bra done
|
||||||
|
|
||||||
|
gototop lda tods
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda dirstack+2,y
|
||||||
|
pha
|
||||||
|
lda dirstack,y
|
||||||
|
pha
|
||||||
|
jsl gotodir
|
||||||
|
|
||||||
|
done lda varpushdsil
|
||||||
|
bne exit
|
||||||
|
pea 1
|
||||||
|
jsl showdir
|
||||||
|
|
||||||
|
exit return
|
||||||
|
|
||||||
|
usagestr dc c'usage: pushd [+n | dir]',h'0d00'
|
||||||
|
err1 dc c'pushd: No other directory',h'0d00'
|
||||||
|
err2 dc c'pushd: Directory stack not that deep',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* POPD: builtin command
|
||||||
|
* syntax: popd [+n]
|
||||||
|
*
|
||||||
|
* pop a directory from stack and cd to it
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
popd START
|
||||||
|
|
||||||
|
using DirData
|
||||||
|
using vardata
|
||||||
|
|
||||||
|
count equ 0
|
||||||
|
arg equ count+2
|
||||||
|
space equ arg+4
|
||||||
|
|
||||||
|
subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
jeq noarg
|
||||||
|
dec a
|
||||||
|
bne using
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
sta arg
|
||||||
|
ldy #6
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
lda [arg]
|
||||||
|
and #$FF
|
||||||
|
cmp #'+'
|
||||||
|
beq plus
|
||||||
|
|
||||||
|
using ldx #^usingstr
|
||||||
|
lda #usingstr
|
||||||
|
jsr errputs
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
plus add4 arg,#1,arg
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsr cstrlen
|
||||||
|
tax
|
||||||
|
Dec2Int (arg,@x,#0),@a
|
||||||
|
sta count
|
||||||
|
cmp #0
|
||||||
|
beq noarg
|
||||||
|
lda tods
|
||||||
|
beq pluserr
|
||||||
|
lda count
|
||||||
|
cmp tods
|
||||||
|
beq doplus
|
||||||
|
bcc doplus
|
||||||
|
|
||||||
|
pluserr ldx #^err2
|
||||||
|
lda #err2
|
||||||
|
jsr errputs
|
||||||
|
bra exit
|
||||||
|
|
||||||
|
doplus jsl dotods
|
||||||
|
sub2 tods,count,@a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tax
|
||||||
|
phx
|
||||||
|
lda dirstack+2,x
|
||||||
|
pha
|
||||||
|
lda dirstack,x
|
||||||
|
pha
|
||||||
|
jsl nullfree
|
||||||
|
plx
|
||||||
|
plusloop lda dirstack+4,x
|
||||||
|
sta dirstack,x
|
||||||
|
lda dirstack+6,x
|
||||||
|
sta dirstack+2,x
|
||||||
|
inx4
|
||||||
|
dec count
|
||||||
|
bne plusloop
|
||||||
|
dec tods
|
||||||
|
|
||||||
|
bra gototop
|
||||||
|
|
||||||
|
noarg lda tods
|
||||||
|
bne noarg0
|
||||||
|
|
||||||
|
ldx #^err1
|
||||||
|
lda #err1
|
||||||
|
jsr errputs
|
||||||
|
bra exit
|
||||||
|
|
||||||
|
noarg0 lda tods
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda dirstack+2,y
|
||||||
|
pha
|
||||||
|
lda dirstack,y
|
||||||
|
pha
|
||||||
|
jsl nullfree
|
||||||
|
dec tods
|
||||||
|
|
||||||
|
gototop lda tods
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda dirstack+2,y
|
||||||
|
pha
|
||||||
|
lda dirstack,y
|
||||||
|
pha
|
||||||
|
jsl gotodir
|
||||||
|
|
||||||
|
lda varpushdsil
|
||||||
|
bne exit
|
||||||
|
|
||||||
|
pea 1
|
||||||
|
jsl showdir
|
||||||
|
|
||||||
|
exit return
|
||||||
|
|
||||||
|
usingstr dc c'Usage: popd [+n]',h'0d00'
|
||||||
|
err1 dc c'popd: Directory stack empty',h'0d00'
|
||||||
|
err2 dc c'popd: Directory stack not that deep',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Set prefix 0 to the passed c string
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
gotodir PRIVATE
|
||||||
|
|
||||||
|
retval equ 0
|
||||||
|
space equ retval+2
|
||||||
|
|
||||||
|
subroutine (4:dir),space
|
||||||
|
|
||||||
|
stz retval
|
||||||
|
|
||||||
|
pei (dir+2)
|
||||||
|
pei (dir)
|
||||||
|
jsr c2gsstr
|
||||||
|
sta PRecPath
|
||||||
|
sta GRecPath
|
||||||
|
stx PRecPath+2
|
||||||
|
stx GRecPath+2
|
||||||
|
|
||||||
|
lock mutex
|
||||||
|
|
||||||
|
GetFileInfo GRec
|
||||||
|
bcc ok
|
||||||
|
ohshit sta Err
|
||||||
|
Error Err
|
||||||
|
inc retval
|
||||||
|
bra done
|
||||||
|
|
||||||
|
ok if2 GRecFT,eq,#$F,ok2
|
||||||
|
ldx dir+2
|
||||||
|
lda dir
|
||||||
|
jsr errputs
|
||||||
|
ldx #^direrr
|
||||||
|
lda #direrr
|
||||||
|
jsr errputs
|
||||||
|
inc retval
|
||||||
|
bra done
|
||||||
|
|
||||||
|
ok2 SetPrefix PRec
|
||||||
|
bcs ohshit
|
||||||
|
|
||||||
|
done ph4 PRecPath
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
unlock mutex
|
||||||
|
|
||||||
|
return 2:retval
|
||||||
|
|
||||||
|
mutex key
|
||||||
|
|
||||||
|
PRec dc i'2'
|
||||||
|
PRecNum dc i'0'
|
||||||
|
PRecPath ds 4
|
||||||
|
|
||||||
|
GRec dc i'3'
|
||||||
|
GRecPath ds 4
|
||||||
|
GRecAcc ds 2
|
||||||
|
GRecFT ds 2
|
||||||
|
|
||||||
|
Err ds 2
|
||||||
|
dirErr dc c': Not a directory',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Display the directory stack
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
showdir PRIVATE
|
||||||
|
|
||||||
|
using DirData
|
||||||
|
|
||||||
|
idx equ 0
|
||||||
|
space equ idx+2
|
||||||
|
|
||||||
|
subroutine (2:flag),space
|
||||||
|
|
||||||
|
lda tods
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta idx
|
||||||
|
|
||||||
|
loop lda flag
|
||||||
|
beq long
|
||||||
|
ldy idx
|
||||||
|
lda dirstack+2,y
|
||||||
|
pha
|
||||||
|
lda dirstack,y
|
||||||
|
pha
|
||||||
|
jsl path2tilde
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr puts
|
||||||
|
jsl nullfree
|
||||||
|
bra next
|
||||||
|
long ldy idx
|
||||||
|
lda dirstack+2,y
|
||||||
|
tax
|
||||||
|
lda dirstack,y
|
||||||
|
jsr puts
|
||||||
|
next lda #' '
|
||||||
|
jsr putchar
|
||||||
|
lda idx
|
||||||
|
beq done
|
||||||
|
sub2 idx,#4,idx
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done jsr newline
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Set the top of the stack to the current directory
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
dotods PRIVATE
|
||||||
|
|
||||||
|
using DIRDATA
|
||||||
|
|
||||||
|
p equ 0
|
||||||
|
idx equ p+4
|
||||||
|
space equ idx+2
|
||||||
|
|
||||||
|
subroutine (0:dummy),space
|
||||||
|
|
||||||
|
lda tods
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta idx
|
||||||
|
tay
|
||||||
|
lda dirstack,y
|
||||||
|
ora dirstack+2,y
|
||||||
|
beq setit
|
||||||
|
|
||||||
|
lda dirstack+2,y
|
||||||
|
pha
|
||||||
|
lda dirstack,y
|
||||||
|
pha
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
setit lock mutex
|
||||||
|
jsl alloc256
|
||||||
|
sta gppath
|
||||||
|
stx gppath+2
|
||||||
|
sta p
|
||||||
|
stx P+2
|
||||||
|
lda #254
|
||||||
|
sta [p]
|
||||||
|
GetPrefix gpparm
|
||||||
|
ldy #2
|
||||||
|
lda [p],y
|
||||||
|
xba
|
||||||
|
sta [p],y
|
||||||
|
add4 p,#3,p
|
||||||
|
pei (p+2)
|
||||||
|
pei (p)
|
||||||
|
jsr p2cstr
|
||||||
|
sta p
|
||||||
|
stx p+2
|
||||||
|
ldx gppath+2
|
||||||
|
lda gppath
|
||||||
|
jsl free256
|
||||||
|
|
||||||
|
unlock mutex
|
||||||
|
|
||||||
|
ldy idx
|
||||||
|
lda p
|
||||||
|
sta dirstack,y
|
||||||
|
lda p+2
|
||||||
|
sta dirstack+2,y
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
mutex key
|
||||||
|
|
||||||
|
gpparm dc i2'2'
|
||||||
|
dc i2'0'
|
||||||
|
gppath dc i4'0'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Directory stack data
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
DirData DATA
|
||||||
|
|
||||||
|
dirstack ds MAXD*4
|
||||||
|
tods dc i'0'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Replace $HOME with a '~' in string
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
path2tilde START
|
||||||
|
|
||||||
|
ptr equ 0
|
||||||
|
newpath equ ptr+4
|
||||||
|
home equ newpath+4
|
||||||
|
space equ home+4
|
||||||
|
|
||||||
|
subroutine (4:path),space
|
||||||
|
|
||||||
|
pei (path+2)
|
||||||
|
pei (path)
|
||||||
|
jsr cstrlen
|
||||||
|
inc2 a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta newpath
|
||||||
|
stx newpath+2
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
|
||||||
|
jsl alloc256
|
||||||
|
sta home
|
||||||
|
stx home+2
|
||||||
|
sta varparm+4
|
||||||
|
stx varparm+6
|
||||||
|
Read_Variable varparm
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
lda [home]
|
||||||
|
and #$FF
|
||||||
|
beq copyrest
|
||||||
|
tax
|
||||||
|
checkhome lda [path],y
|
||||||
|
and #$FF
|
||||||
|
beq notfound2
|
||||||
|
jsr tolower
|
||||||
|
jsr toslash
|
||||||
|
pha
|
||||||
|
iny
|
||||||
|
lda [home],y
|
||||||
|
and #$FF
|
||||||
|
jsr tolower
|
||||||
|
jsr toslash
|
||||||
|
cmp 1,s
|
||||||
|
bne notfound
|
||||||
|
pla
|
||||||
|
dex
|
||||||
|
bne checkhome
|
||||||
|
cmp #'/'
|
||||||
|
beq found
|
||||||
|
lda [path],y
|
||||||
|
and #$FF
|
||||||
|
beq found
|
||||||
|
jsr toslash
|
||||||
|
cmp #'/'
|
||||||
|
bne notfound2
|
||||||
|
|
||||||
|
found lda #'~'
|
||||||
|
sta [ptr]
|
||||||
|
inc ptr
|
||||||
|
bra copyrest
|
||||||
|
|
||||||
|
notfound pla
|
||||||
|
notfound2 ldy #0
|
||||||
|
copyrest short a
|
||||||
|
copyloop lda [path],y
|
||||||
|
beq endcopy
|
||||||
|
cmp #':'
|
||||||
|
bne copyput
|
||||||
|
lda #'/'
|
||||||
|
copyput sta [ptr]
|
||||||
|
long a
|
||||||
|
inc ptr
|
||||||
|
short a
|
||||||
|
iny
|
||||||
|
bra copyloop
|
||||||
|
endcopy sta [ptr]
|
||||||
|
long a
|
||||||
|
dec ptr
|
||||||
|
lda [ptr]
|
||||||
|
cmp #'/'
|
||||||
|
bne skipshorten
|
||||||
|
lda #0
|
||||||
|
sta [ptr]
|
||||||
|
|
||||||
|
skipshorten ldx home+2
|
||||||
|
lda home
|
||||||
|
jsl free256
|
||||||
|
|
||||||
|
return 4:newpath
|
||||||
|
|
||||||
|
varparm dc i4'homename'
|
||||||
|
ds 4
|
||||||
|
|
||||||
|
homename str 'home'
|
||||||
|
|
||||||
|
END
|
1955
bin/gsh/edit.asm
Normal file
1955
bin/gsh/edit.asm
Normal file
File diff suppressed because it is too large
Load Diff
580
bin/gsh/expand.asm
Normal file
580
bin/gsh/expand.asm
Normal file
|
@ -0,0 +1,580 @@
|
||||||
|
***********************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* EXPAND.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Command line expansion routines.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
mcopy m/expand.mac
|
||||||
|
keep o/expand.mac
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* glob the command line
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
glob START
|
||||||
|
|
||||||
|
using vardata
|
||||||
|
|
||||||
|
count equ 0
|
||||||
|
gname equ count+2
|
||||||
|
sepptr equ gname+4
|
||||||
|
eptr equ sepptr+4
|
||||||
|
exppath equ eptr+4
|
||||||
|
filesep equ exppath+4
|
||||||
|
shallweglob equ filesep+2
|
||||||
|
wordbuf equ shallweglob+2
|
||||||
|
ptr equ wordbuf+4
|
||||||
|
buf equ ptr+4
|
||||||
|
space equ buf+4
|
||||||
|
|
||||||
|
subroutine (4:cmd),space
|
||||||
|
;
|
||||||
|
; Check for noglob variable and exit if it's set to something.
|
||||||
|
;
|
||||||
|
lda varnoglob
|
||||||
|
beq doglob
|
||||||
|
jsl alloc1024 ;create a tmp output buffer buffer
|
||||||
|
sta buf
|
||||||
|
stx buf+2
|
||||||
|
pei (cmd+2)
|
||||||
|
pei (cmd)
|
||||||
|
pei (buf+2)
|
||||||
|
pei (buf)
|
||||||
|
jsr copycstr
|
||||||
|
jmp bye
|
||||||
|
;
|
||||||
|
; noglob isn't set, so now we can actually start.
|
||||||
|
;
|
||||||
|
doglob jsl alloc1024 ;create an output buffer buffer
|
||||||
|
sta buf
|
||||||
|
sta ptr
|
||||||
|
stx buf+2
|
||||||
|
stx ptr+2
|
||||||
|
jsl alloc1024 ;create a word buffer
|
||||||
|
sta wordbuf
|
||||||
|
stx wordbuf+2
|
||||||
|
;
|
||||||
|
; strip some white space
|
||||||
|
;
|
||||||
|
skipit jsr getbyte
|
||||||
|
jeq alldone
|
||||||
|
if2 @a,eq,#' ',whitestuff
|
||||||
|
if2 @a,eq,#009,whitestuff
|
||||||
|
if2 @a,eq,#013,whitestuff
|
||||||
|
if2 @a,eq,#010,whitestuff
|
||||||
|
if2 @a,eq,#';',whitestuff
|
||||||
|
if2 @a,eq,#'&',whitestuff
|
||||||
|
if2 @a,eq,#'|',whitestuff
|
||||||
|
if2 @a,eq,#'>',whitestuff
|
||||||
|
if2 @a,eq,#'<',whitestuff
|
||||||
|
stz shallweglob
|
||||||
|
ldy #0
|
||||||
|
bra grabbingword
|
||||||
|
whitestuff jsr putbyte
|
||||||
|
bra skipit
|
||||||
|
;
|
||||||
|
; single out the next word [y is initialized above]
|
||||||
|
;
|
||||||
|
grabword jsr getbyte
|
||||||
|
grabbingword if2 @a,eq,#"'",grabsingle
|
||||||
|
if2 @a,eq,#'"',grabdouble
|
||||||
|
if2 @a,eq,#'\',grabslash
|
||||||
|
if2 @a,eq,#' ',procword
|
||||||
|
if2 @a,eq,#009,procword
|
||||||
|
if2 @a,eq,#013,procword
|
||||||
|
if2 @a,eq,#010,procword
|
||||||
|
if2 @a,eq,#000,procword
|
||||||
|
if2 @a,eq,#';',procword
|
||||||
|
if2 @a,eq,#'&',procword
|
||||||
|
if2 @a,eq,#'|',procword
|
||||||
|
if2 @a,eq,#'>',procword
|
||||||
|
if2 @a,eq,#'<',procword
|
||||||
|
if2 @a,eq,#'[',grabglob
|
||||||
|
if2 @a,eq,#']',grabglob
|
||||||
|
if2 @a,eq,#'*',grabglob
|
||||||
|
if2 @a,eq,#'?',grabglob
|
||||||
|
grabnext sta [wordbuf],y
|
||||||
|
iny
|
||||||
|
bra grabword
|
||||||
|
grabglob ldx #1
|
||||||
|
stx shallweglob
|
||||||
|
bra grabnext
|
||||||
|
grabslash sta [wordbuf],y
|
||||||
|
iny
|
||||||
|
jsr getbyte
|
||||||
|
beq procword
|
||||||
|
bra grabnext
|
||||||
|
grabsingle sta [wordbuf],y
|
||||||
|
iny
|
||||||
|
jsr getbyte
|
||||||
|
beq procword
|
||||||
|
if2 @a,eq,#"'",grabnext
|
||||||
|
bra grabsingle
|
||||||
|
grabdouble sta [wordbuf],y
|
||||||
|
iny
|
||||||
|
jsr getbyte
|
||||||
|
beq procword
|
||||||
|
if2 @a,eq,#'"',grabnext
|
||||||
|
bra grabdouble
|
||||||
|
;
|
||||||
|
; we've grabbed the next word, now process the word
|
||||||
|
;
|
||||||
|
procword dec cmd
|
||||||
|
lda #0
|
||||||
|
sta [wordbuf],y
|
||||||
|
;
|
||||||
|
; Shall we glob? Shall we scream? What happened, to our postwar dream?
|
||||||
|
;
|
||||||
|
lda [wordbuf]
|
||||||
|
and #$FF
|
||||||
|
if2 @a,eq,#'-',skipdeglob ;This allows '-?' option.
|
||||||
|
lda shallweglob
|
||||||
|
bne globword
|
||||||
|
;
|
||||||
|
; we didn't glob this word, so flush the word buffer
|
||||||
|
;
|
||||||
|
skipdeglob ldy #0
|
||||||
|
flushloop lda [wordbuf],y
|
||||||
|
and #$FF
|
||||||
|
beq doneflush
|
||||||
|
jsr putbyte
|
||||||
|
iny
|
||||||
|
bra flushloop
|
||||||
|
doneflush jmp skipit
|
||||||
|
;
|
||||||
|
; Hello, boys and goils, velcome to Tim's Magik Shoppe
|
||||||
|
;
|
||||||
|
; Ok, here's the plan:
|
||||||
|
; 1. We give _InitWildcard a PATHNAME.
|
||||||
|
; 2. _NextWildcard returns a FILENAME.
|
||||||
|
; 3. We need to expand to the command-line the full pathname.
|
||||||
|
; 4. Therefore, we must put aside the prefix, and cat each file returned
|
||||||
|
; from _NextWildcard to the saved prefix, but, we must still pass
|
||||||
|
; the entire path to _InitWildcard.
|
||||||
|
; 5. This solves our problem with quoting. Expand the quotes before
|
||||||
|
; passing along to _InitWildcard, BUT the saved prefix we saved to cat
|
||||||
|
; to will still have the quotes in it, so that the tokenizer can deal
|
||||||
|
; with it. Whew!
|
||||||
|
;
|
||||||
|
; Well, here goes nuthin'.... [Ya know, and I'm reading Levy's book
|
||||||
|
; 'Hackers' right now...]
|
||||||
|
;
|
||||||
|
;
|
||||||
|
;
|
||||||
|
; Expand out the quoted stuff, and keep an eye out for that ubiquitous last
|
||||||
|
; filename separator... then we can isolate him!
|
||||||
|
;
|
||||||
|
globword stz filesep
|
||||||
|
jsl alloc1024
|
||||||
|
sta eptr
|
||||||
|
stx eptr+2
|
||||||
|
sta exppath
|
||||||
|
stx exppath+2
|
||||||
|
|
||||||
|
inc eptr ;leave room for pascal length
|
||||||
|
mv4 eptr,sepptr
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
exploop lda [wordbuf],y
|
||||||
|
and #$FF
|
||||||
|
beq endexp
|
||||||
|
iny
|
||||||
|
if2 @a,eq,#'\',expslash
|
||||||
|
if2 @a,eq,#"'",expsingle
|
||||||
|
if2 @a,eq,#'"',expdouble
|
||||||
|
if2 @a,eq,#'/',expsep
|
||||||
|
if2 @a,eq,#':',expsep
|
||||||
|
expput sta [eptr]
|
||||||
|
inc eptr
|
||||||
|
bra exploop
|
||||||
|
expsep sty filesep
|
||||||
|
sta [eptr]
|
||||||
|
inc eptr
|
||||||
|
mv4 eptr,sepptr
|
||||||
|
bra exploop
|
||||||
|
expslash lda [wordbuf],y
|
||||||
|
iny
|
||||||
|
and #$FF
|
||||||
|
beq endexp
|
||||||
|
bra expput
|
||||||
|
expsingle lda [wordbuf],y
|
||||||
|
iny
|
||||||
|
and #$FF
|
||||||
|
beq endexp
|
||||||
|
if2 @a,eq,#"'",exploop
|
||||||
|
sta [eptr]
|
||||||
|
inc eptr
|
||||||
|
bra expsingle
|
||||||
|
expdouble lda [wordbuf],y
|
||||||
|
iny
|
||||||
|
and #$FF
|
||||||
|
beq endexp
|
||||||
|
if2 @a,eq,#'"',exploop
|
||||||
|
sta [eptr]
|
||||||
|
inc eptr
|
||||||
|
bra expdouble
|
||||||
|
;
|
||||||
|
; We really didn't mean to expand the filename, so, copy it back again..
|
||||||
|
;
|
||||||
|
endexp ldy filesep
|
||||||
|
copyback lda [wordbuf],y
|
||||||
|
iny
|
||||||
|
and #$FF
|
||||||
|
sta [sepptr]
|
||||||
|
inc sepptr
|
||||||
|
cmp #0
|
||||||
|
bne copyback
|
||||||
|
;
|
||||||
|
; save the length, heh, heh, 16-bit sub will do it!
|
||||||
|
;
|
||||||
|
sub2 sepptr,exppath,@a
|
||||||
|
dec2 a ;don't count length byte or \0!
|
||||||
|
short a
|
||||||
|
sta [exppath]
|
||||||
|
long a
|
||||||
|
;
|
||||||
|
; We now have enough to call _InitWildCard!!!
|
||||||
|
; [ let's mutex the rest so we don't have to fix _InitWC and _NextWC ;-) ]
|
||||||
|
;
|
||||||
|
wait2 lda mutex
|
||||||
|
beq wait2a
|
||||||
|
cop $7F
|
||||||
|
bra wait2
|
||||||
|
wait2a inc mutex
|
||||||
|
;
|
||||||
|
; start 'em up
|
||||||
|
;
|
||||||
|
stz count
|
||||||
|
mv4 exppath,initWCparm
|
||||||
|
Init_Wildcard initWCparm
|
||||||
|
;
|
||||||
|
; hey, we better get some memory for these new files...
|
||||||
|
;
|
||||||
|
ph4 #65
|
||||||
|
jsl ~NEW
|
||||||
|
sta gname
|
||||||
|
stx gname+2
|
||||||
|
sta nWCparm
|
||||||
|
stx nWCparm+2
|
||||||
|
;
|
||||||
|
; start the expansion dudes!
|
||||||
|
;
|
||||||
|
WCloop Next_Wildcard nWCparm
|
||||||
|
lda [gname]
|
||||||
|
and #$FF
|
||||||
|
beq nomore
|
||||||
|
inc count
|
||||||
|
;
|
||||||
|
; get that owiginal path outta here!
|
||||||
|
;
|
||||||
|
ldy #0
|
||||||
|
outtahere if2 @y,eq,filesep,globout
|
||||||
|
lda [wordbuf],y
|
||||||
|
jsr putspecial
|
||||||
|
iny
|
||||||
|
bra outtahere
|
||||||
|
;
|
||||||
|
; now get that newly globbed file outta here
|
||||||
|
;
|
||||||
|
globout lda [gname]
|
||||||
|
and #$FF
|
||||||
|
tax
|
||||||
|
ldy #1
|
||||||
|
globoutta lda [gname],y
|
||||||
|
jsr putspecial
|
||||||
|
iny
|
||||||
|
dex
|
||||||
|
bne globoutta
|
||||||
|
;
|
||||||
|
; well well well, one down, how many to go?
|
||||||
|
;
|
||||||
|
lda #' '
|
||||||
|
jsr putbyte
|
||||||
|
bra WCloop
|
||||||
|
;
|
||||||
|
; no more left, whatta we gonna do now!
|
||||||
|
;
|
||||||
|
nomore anop
|
||||||
|
;
|
||||||
|
; no match
|
||||||
|
;
|
||||||
|
lda count
|
||||||
|
bne yesmore
|
||||||
|
ldx #^nomatch
|
||||||
|
lda #nomatch
|
||||||
|
jsr puts
|
||||||
|
lda #0
|
||||||
|
sta [buf]
|
||||||
|
yesmore anop
|
||||||
|
;
|
||||||
|
; throw em away (we should probably alloc once, not each word... )
|
||||||
|
;
|
||||||
|
pei (gname+2)
|
||||||
|
pei (gname)
|
||||||
|
jsl nullfree
|
||||||
|
ldx exppath+2
|
||||||
|
lda exppath
|
||||||
|
jsl free1024
|
||||||
|
dec mutex
|
||||||
|
lda count
|
||||||
|
beq alldone2
|
||||||
|
jmp skipit
|
||||||
|
;
|
||||||
|
; Goodbye, cruel world, I'm leaving you today, Goodbye, goodbye.
|
||||||
|
;
|
||||||
|
alldone jsr putbyte
|
||||||
|
alldone2 ldx wordbuf+2
|
||||||
|
lda wordbuf
|
||||||
|
jsl free1024
|
||||||
|
|
||||||
|
bye return 4:buf
|
||||||
|
;
|
||||||
|
; get a byte from the original command-line
|
||||||
|
;
|
||||||
|
getbyte lda [cmd]
|
||||||
|
inc cmd
|
||||||
|
and #$FF
|
||||||
|
rts
|
||||||
|
;
|
||||||
|
; put special characters. Same as putbyte, but if it is a special
|
||||||
|
; shell character then quote it.
|
||||||
|
;
|
||||||
|
putspecial and #$7F
|
||||||
|
if2 @a,eq,#' ',special
|
||||||
|
if2 @a,eq,#'.',special
|
||||||
|
if2 @a,eq,#013,special
|
||||||
|
if2 @a,eq,#009,special
|
||||||
|
if2 @a,eq,#';',special
|
||||||
|
if2 @a,eq,#'&',special
|
||||||
|
if2 @a,eq,#'<',special
|
||||||
|
if2 @a,eq,#'>',special
|
||||||
|
if2 @a,eq,#'|',special
|
||||||
|
bra putbyte
|
||||||
|
special pha
|
||||||
|
lda #'\'
|
||||||
|
jsr putbyte
|
||||||
|
pla
|
||||||
|
;
|
||||||
|
; store a byte into the new command-line
|
||||||
|
;
|
||||||
|
putbyte short a
|
||||||
|
sta [ptr]
|
||||||
|
long a
|
||||||
|
inc ptr
|
||||||
|
rts
|
||||||
|
|
||||||
|
mutex dc i'0'
|
||||||
|
|
||||||
|
InitWCParm ds 4
|
||||||
|
dc i2'%00000001'
|
||||||
|
nWCparm ds 4
|
||||||
|
|
||||||
|
nomatch dc c'No match.',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Expand variables not in single quotes
|
||||||
|
*
|
||||||
|
* * Add error checking if out buf gets too big (> 1024)
|
||||||
|
* * Get rid of fixed buffers
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
expandvars START
|
||||||
|
|
||||||
|
ptr equ 1
|
||||||
|
;ptr equ 0
|
||||||
|
buf equ ptr+4
|
||||||
|
space equ buf+4
|
||||||
|
cmd equ space+3
|
||||||
|
end equ cmd+4
|
||||||
|
|
||||||
|
; subroutine (4:cmd),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
jsl alloc1024
|
||||||
|
sta buf
|
||||||
|
sta ptr
|
||||||
|
stx buf+2
|
||||||
|
stx ptr+2
|
||||||
|
|
||||||
|
loop jsr getbyte
|
||||||
|
jeq done
|
||||||
|
if2 @a,eq,#"'",quote
|
||||||
|
if2 @a,eq,#'$',expand
|
||||||
|
if2 @a,eq,#'~',tilde
|
||||||
|
if2 @a,eq,#'\',slasher
|
||||||
|
jsr putbyte
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
slasher jsr putbyte
|
||||||
|
jsr getbyte
|
||||||
|
jsr putbyte
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
quote jsr putbyte
|
||||||
|
jsr getbyte
|
||||||
|
jeq done
|
||||||
|
if2 @a,ne,#"'",quote
|
||||||
|
jsr putbyte
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
tilde anop
|
||||||
|
wait2 lda mutex
|
||||||
|
beq wait2a
|
||||||
|
cop $7F
|
||||||
|
bra wait2
|
||||||
|
wait2a inc mutex
|
||||||
|
|
||||||
|
short a
|
||||||
|
lda #'h'
|
||||||
|
sta name
|
||||||
|
lda #'o'
|
||||||
|
sta name+1
|
||||||
|
lda #'m'
|
||||||
|
sta name+2
|
||||||
|
lda #'e'
|
||||||
|
sta name+3
|
||||||
|
long a
|
||||||
|
ldx #4
|
||||||
|
jmp getval
|
||||||
|
;
|
||||||
|
; expand the variable since a '$' was encountered.
|
||||||
|
;
|
||||||
|
expand anop
|
||||||
|
wait1 lda mutex
|
||||||
|
beq wait1a
|
||||||
|
cop $7F
|
||||||
|
bra wait1
|
||||||
|
wait1a inc mutex
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta name
|
||||||
|
lda [cmd]
|
||||||
|
and #$FF
|
||||||
|
if2 @a,eq,#'{',braceexpand
|
||||||
|
if2 @a,eq,#'<',stdinexpand
|
||||||
|
ldx #0
|
||||||
|
nameloop lda [cmd]
|
||||||
|
and #$FF
|
||||||
|
beq getval
|
||||||
|
if2 @a,cc,#'0',getval
|
||||||
|
if2 @a,cc,#'9'+1,inname
|
||||||
|
if2 @a,cc,#'A',getval
|
||||||
|
if2 @a,cc,#'Z'+1,inname
|
||||||
|
if2 @a,eq,#'_',inname
|
||||||
|
if2 @a,cc,#'a',getval
|
||||||
|
if2 @a,cc,#'z'+1,inname
|
||||||
|
bra getval
|
||||||
|
inname jsr getbyte
|
||||||
|
sta name,x
|
||||||
|
inx
|
||||||
|
bra nameloop
|
||||||
|
;
|
||||||
|
; expand in braces {}
|
||||||
|
;
|
||||||
|
braceexpand jsr getbyte
|
||||||
|
ldx #0
|
||||||
|
braceloop lda [cmd]
|
||||||
|
and #$FF
|
||||||
|
beq getval
|
||||||
|
jsr getbyte
|
||||||
|
if2 @a,eq,#'}',getval
|
||||||
|
sta name,x
|
||||||
|
inx
|
||||||
|
bra braceloop
|
||||||
|
;
|
||||||
|
; get text from standard input
|
||||||
|
;
|
||||||
|
stdinexpand jsr getbyte
|
||||||
|
ReadLine (#value+1,#255,#13,#1),@a
|
||||||
|
bra storeval2
|
||||||
|
;
|
||||||
|
; 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
|
||||||
|
;
|
||||||
|
; store the variable value in the out buffer
|
||||||
|
;
|
||||||
|
storeval lda value
|
||||||
|
storeval2 and #$FF
|
||||||
|
beq expanded
|
||||||
|
tay
|
||||||
|
ldx #0
|
||||||
|
putval lda value+1,x
|
||||||
|
jsr putbyte
|
||||||
|
inx
|
||||||
|
dey
|
||||||
|
bne putval
|
||||||
|
|
||||||
|
expanded dec mutex
|
||||||
|
jmp loop
|
||||||
|
|
||||||
|
done jsr putbyte
|
||||||
|
|
||||||
|
ldx buf+2
|
||||||
|
ldy buf
|
||||||
|
|
||||||
|
lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
rtl
|
||||||
|
|
||||||
|
getbyte lda [cmd]
|
||||||
|
inc cmd
|
||||||
|
and #$FF
|
||||||
|
rts
|
||||||
|
|
||||||
|
putbyte short a
|
||||||
|
sta [ptr]
|
||||||
|
long a
|
||||||
|
inc ptr
|
||||||
|
rts
|
||||||
|
|
||||||
|
mutex dc i'0'
|
||||||
|
|
||||||
|
parm dc a4'name'
|
||||||
|
dc a4'value'
|
||||||
|
|
||||||
|
name ds 256
|
||||||
|
value ds 256
|
||||||
|
|
||||||
|
END
|
928
bin/gsh/hash.asm
Normal file
928
bin/gsh/hash.asm
Normal file
|
@ -0,0 +1,928 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* HASH.ASM
|
||||||
|
* By Tim Meekins & Greg Thompson
|
||||||
|
*
|
||||||
|
* Command hashing routines
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/hash
|
||||||
|
mcopy m/hash.mac
|
||||||
|
|
||||||
|
C1 gequ 11
|
||||||
|
C2 gequ 13
|
||||||
|
TAB_MULT gequ 4
|
||||||
|
;
|
||||||
|
; Structure for filenames
|
||||||
|
;
|
||||||
|
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
|
||||||
|
;
|
||||||
|
tn_dirNum gequ 0
|
||||||
|
tn_name gequ tn_dirNum+2
|
||||||
|
tn_size gequ tn_name+32
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Calculate hash value for a filename
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
hash START
|
||||||
|
|
||||||
|
using hashdata
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
num equ space+2
|
||||||
|
name equ num+2
|
||||||
|
end equ name+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda num
|
||||||
|
bne hasher
|
||||||
|
|
||||||
|
stz h
|
||||||
|
ldy #0
|
||||||
|
loop lda [name],y
|
||||||
|
and #$FF
|
||||||
|
beq hasher
|
||||||
|
sta addit+1
|
||||||
|
lda h ;left shift 7
|
||||||
|
xba
|
||||||
|
and #$FF00
|
||||||
|
lsr a
|
||||||
|
addit adc #0 ;(cf=0)
|
||||||
|
phy
|
||||||
|
UDivide (@a,t_size),(@a,@a)
|
||||||
|
sta h
|
||||||
|
ply
|
||||||
|
iny
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
hasher lda num ;num*num
|
||||||
|
sta tmp
|
||||||
|
lda #0
|
||||||
|
ldx #16
|
||||||
|
mulloop asl a
|
||||||
|
asl tmp
|
||||||
|
bcc nomul
|
||||||
|
clc
|
||||||
|
adc num
|
||||||
|
nomul dex
|
||||||
|
bne mulloop
|
||||||
|
|
||||||
|
pha ;Acc * C2
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sec
|
||||||
|
sbc 1,s
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
adc 1,s
|
||||||
|
sta 1,s
|
||||||
|
|
||||||
|
lda num ;num*C1 + (Acc*C2) + h
|
||||||
|
asl a
|
||||||
|
adc num
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
adc 1,s
|
||||||
|
adc h
|
||||||
|
sec
|
||||||
|
sbc num
|
||||||
|
plx
|
||||||
|
UDivide (@a,t_size),(@a,@y)
|
||||||
|
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
rts
|
||||||
|
|
||||||
|
h ds 2
|
||||||
|
tmp ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* dohash
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
dohash START
|
||||||
|
|
||||||
|
using hashdata
|
||||||
|
|
||||||
|
h equ 1
|
||||||
|
temp equ h+2
|
||||||
|
qh equ temp+4
|
||||||
|
table equ qh+2
|
||||||
|
space equ table+4
|
||||||
|
files equ space+3
|
||||||
|
end equ files+4
|
||||||
|
|
||||||
|
; subroutine (4:files),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda hash_numexe
|
||||||
|
bne mktsize
|
||||||
|
|
||||||
|
stz table
|
||||||
|
stz table+2
|
||||||
|
jmp done
|
||||||
|
;
|
||||||
|
; t_size = (TAB_MULT * numexe) - 1
|
||||||
|
; [Shift since TAB_MULT is 4, change later if needed]
|
||||||
|
;
|
||||||
|
mktsize asl a
|
||||||
|
asl a
|
||||||
|
dec a
|
||||||
|
sta t_size
|
||||||
|
;
|
||||||
|
; table = (tablenode **)malloc(sizeof(tablenode *) * t_size);
|
||||||
|
;
|
||||||
|
inc a ;safety precaution
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta table
|
||||||
|
stx table+2
|
||||||
|
;
|
||||||
|
; for (i=0; i < t_size; ++i) table[i] = NULL;
|
||||||
|
;
|
||||||
|
ldy #0
|
||||||
|
ldx t_size
|
||||||
|
tya
|
||||||
|
clrtbl sta [table],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
sta [table],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
dex
|
||||||
|
bne clrtbl
|
||||||
|
;
|
||||||
|
; files = files->next
|
||||||
|
;
|
||||||
|
mainloop ldy #fn_next
|
||||||
|
lda [files],y
|
||||||
|
tax
|
||||||
|
ldy #fn_next+2
|
||||||
|
lda [files],y
|
||||||
|
sta files+2
|
||||||
|
stx files
|
||||||
|
;
|
||||||
|
; while (files != NULL) {
|
||||||
|
;
|
||||||
|
ora files
|
||||||
|
jeq done
|
||||||
|
stz qh
|
||||||
|
;
|
||||||
|
; while (table[h = hash(files->name, qh))]) { ++qh; ++colls; }
|
||||||
|
;
|
||||||
|
hashloop pei (files+2)
|
||||||
|
lda files
|
||||||
|
inc a
|
||||||
|
inc a
|
||||||
|
pha
|
||||||
|
pei (qh)
|
||||||
|
jsr hash
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta h
|
||||||
|
tay
|
||||||
|
lda [table],y
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
ora [table],y
|
||||||
|
beq gotit
|
||||||
|
|
||||||
|
; let's see if it's the same, skip if so...
|
||||||
|
|
||||||
|
; pei (files+2)
|
||||||
|
; lda files
|
||||||
|
; inc a
|
||||||
|
; inc a
|
||||||
|
; pha
|
||||||
|
; lda [table],y
|
||||||
|
; pha
|
||||||
|
; phx
|
||||||
|
; jsr cmpcstr
|
||||||
|
; beq mainloop
|
||||||
|
|
||||||
|
inc qh
|
||||||
|
bra hashloop
|
||||||
|
;
|
||||||
|
; table[h] = (tablenode *)malloc(sizeof(tablenode))
|
||||||
|
;
|
||||||
|
gotit ph4 #tn_size
|
||||||
|
jsl ~NEW
|
||||||
|
sta temp
|
||||||
|
stx temp+2
|
||||||
|
ldy h
|
||||||
|
sta [table],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
txa
|
||||||
|
sta [table],y
|
||||||
|
;
|
||||||
|
; table[h]->dirnum = files->dirNum
|
||||||
|
;
|
||||||
|
lda [files]
|
||||||
|
sta [temp]
|
||||||
|
;
|
||||||
|
; strcpy(table[h]->name, files->name);
|
||||||
|
;
|
||||||
|
pei (files+2)
|
||||||
|
lda files
|
||||||
|
inc a
|
||||||
|
inc a
|
||||||
|
pha
|
||||||
|
pei (temp+2)
|
||||||
|
lda temp
|
||||||
|
inc a
|
||||||
|
inc a
|
||||||
|
pha
|
||||||
|
jsr copycstr
|
||||||
|
jmp mainloop
|
||||||
|
|
||||||
|
done anop
|
||||||
|
; return 4:table
|
||||||
|
|
||||||
|
ldx table+2
|
||||||
|
ldy table
|
||||||
|
|
||||||
|
lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
rtl
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Search the hash table
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
search START
|
||||||
|
|
||||||
|
ptr equ 1
|
||||||
|
full_path equ ptr+4
|
||||||
|
qh equ full_path+4
|
||||||
|
space equ qh+2
|
||||||
|
paths equ space+3
|
||||||
|
table equ paths+4
|
||||||
|
file equ table+4
|
||||||
|
end equ file+4
|
||||||
|
|
||||||
|
; subroutine (4:file,4:table,4:paths),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
stz qh
|
||||||
|
stz full_path
|
||||||
|
stz full_path+2
|
||||||
|
|
||||||
|
lda table
|
||||||
|
ora table+2
|
||||||
|
jeq done
|
||||||
|
|
||||||
|
pei (file+2)
|
||||||
|
pei (file)
|
||||||
|
jsr lowercstr
|
||||||
|
mainloop pei (file+2)
|
||||||
|
pei (file)
|
||||||
|
pei (qh)
|
||||||
|
jsr hash
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [table],y
|
||||||
|
sta ptr
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
ora [table],y
|
||||||
|
jeq done
|
||||||
|
lda [table],y
|
||||||
|
sta ptr+2
|
||||||
|
pei (file+2)
|
||||||
|
pei (file)
|
||||||
|
pha ;ptr+2
|
||||||
|
inx ;ptr + #2
|
||||||
|
inx
|
||||||
|
phx
|
||||||
|
jsr cmpcstr
|
||||||
|
beq found
|
||||||
|
inc qh
|
||||||
|
bra mainloop
|
||||||
|
|
||||||
|
found lda [ptr]
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
ldx paths+2
|
||||||
|
adc paths ;(cf=0)
|
||||||
|
stx ptr+2
|
||||||
|
sta ptr
|
||||||
|
ldy #2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
lda [ptr]
|
||||||
|
pha
|
||||||
|
jsr cstrlen
|
||||||
|
pha
|
||||||
|
clc
|
||||||
|
adc #33
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta full_path
|
||||||
|
stx full_path+2
|
||||||
|
ldy #2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
lda [ptr]
|
||||||
|
pha
|
||||||
|
pei (full_path+2)
|
||||||
|
pei (full_path)
|
||||||
|
jsr copycstr
|
||||||
|
pla ;length of path
|
||||||
|
pei (file+2)
|
||||||
|
pei (file)
|
||||||
|
pei (full_path+2)
|
||||||
|
clc
|
||||||
|
adc full_path
|
||||||
|
pha
|
||||||
|
jsr copycstr
|
||||||
|
|
||||||
|
done ldx full_path+2
|
||||||
|
ldy full_path
|
||||||
|
lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
rtl
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Dispose the hash table
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
dispose_table START
|
||||||
|
|
||||||
|
using hashdata
|
||||||
|
|
||||||
|
ptr equ 0
|
||||||
|
count equ ptr+4
|
||||||
|
space equ count+2
|
||||||
|
|
||||||
|
subroutine (4:table),space
|
||||||
|
|
||||||
|
mv4 table,ptr
|
||||||
|
mv2 t_size,count
|
||||||
|
loop ldy #2
|
||||||
|
lda [ptr],y
|
||||||
|
pha
|
||||||
|
lda [ptr]
|
||||||
|
pha
|
||||||
|
jsl nullfree
|
||||||
|
add2 ptr,#4,ptr
|
||||||
|
dec count
|
||||||
|
bne loop
|
||||||
|
|
||||||
|
pei (table+2)
|
||||||
|
pei (table)
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Dispose the file table
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
free_files START
|
||||||
|
|
||||||
|
space equ 0
|
||||||
|
|
||||||
|
subroutine (4:files),space
|
||||||
|
|
||||||
|
loop ora2 files,files+2,@a
|
||||||
|
beq done
|
||||||
|
ldy #fn_next
|
||||||
|
lda [files],y
|
||||||
|
tax
|
||||||
|
ldy #fn_next+2
|
||||||
|
lda [files],y
|
||||||
|
pei (files+2)
|
||||||
|
pei (files)
|
||||||
|
stx files
|
||||||
|
sta files+2
|
||||||
|
jsl nullfree
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Directory search
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
dir_search START
|
||||||
|
|
||||||
|
using hashdata
|
||||||
|
|
||||||
|
temp2 equ 0
|
||||||
|
temp equ temp2+4
|
||||||
|
entry equ temp+4
|
||||||
|
numEntries equ entry+2
|
||||||
|
ptr equ numEntries+2
|
||||||
|
space equ ptr+4
|
||||||
|
|
||||||
|
subroutine (4:dir,2:dirNum,4:files),space
|
||||||
|
;
|
||||||
|
; Open directory
|
||||||
|
;
|
||||||
|
ld2 3,ORec
|
||||||
|
pei (dir+2) ;copy this string
|
||||||
|
pei (dir)
|
||||||
|
jsr c2gsstr
|
||||||
|
sta ORecPath
|
||||||
|
stx ORecPath+2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
Open ORec
|
||||||
|
bcc goodopen
|
||||||
|
jsl nullfree
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
goodopen jsl nullfree
|
||||||
|
mv2 ORecRef,DRecRef
|
||||||
|
stz DRecBase
|
||||||
|
stz DRecDisp
|
||||||
|
jsl alloc256
|
||||||
|
sta DRecName
|
||||||
|
sta ptr
|
||||||
|
stx DRecName+2
|
||||||
|
stx ptr+2
|
||||||
|
lda #254 ;Output buffer size (GT never did this?)
|
||||||
|
sta [ptr]
|
||||||
|
GetDirEntry DRec
|
||||||
|
mv2 DRecEntry,numEntries
|
||||||
|
ld2 1,(DRecBase,DRecDisp)
|
||||||
|
stz entry
|
||||||
|
|
||||||
|
loop lda entry
|
||||||
|
cmp numEntries
|
||||||
|
jge done
|
||||||
|
GetDirEntry DRec
|
||||||
|
if2 DRecFileType,eq,#$B3,goodfile
|
||||||
|
if2 @a,eq,#$B5,goodfile
|
||||||
|
cmp #$B0
|
||||||
|
jne nextfile
|
||||||
|
lda DRecAuxType
|
||||||
|
cmp #$06
|
||||||
|
jne nextfile
|
||||||
|
lda DRecAuxType+2
|
||||||
|
jne nextfile
|
||||||
|
goodfile inc hash_numexe
|
||||||
|
ldy #2
|
||||||
|
lda [ptr],y
|
||||||
|
add2 @a,#4,@y
|
||||||
|
lda #0
|
||||||
|
sta [ptr],y
|
||||||
|
add2 ptr,#4,@a
|
||||||
|
pei (ptr+2) ;for copycstr
|
||||||
|
pha
|
||||||
|
pei (ptr+2)
|
||||||
|
pha
|
||||||
|
jsr lowercstr
|
||||||
|
|
||||||
|
ldy #fn_next
|
||||||
|
lda [files],y
|
||||||
|
sta temp
|
||||||
|
ldy #fn_next+2
|
||||||
|
lda [files],y
|
||||||
|
sta temp+2
|
||||||
|
ph4 #fn_size
|
||||||
|
jsl ~NEW
|
||||||
|
sta temp2
|
||||||
|
stx temp2+2
|
||||||
|
ldy #fn_next
|
||||||
|
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 temp
|
||||||
|
sta [temp2],y
|
||||||
|
ldy #fn_next+2
|
||||||
|
lda temp+2
|
||||||
|
sta [temp2],y
|
||||||
|
|
||||||
|
nextfile inc entry
|
||||||
|
jmp loop
|
||||||
|
|
||||||
|
done ldx DRecName+2
|
||||||
|
lda DRecName
|
||||||
|
jsl free256
|
||||||
|
ld2 1,ORec
|
||||||
|
Close ORec
|
||||||
|
|
||||||
|
exit return
|
||||||
|
|
||||||
|
ORec dc i'3'
|
||||||
|
ORecRef ds 2
|
||||||
|
ORecPath ds 4
|
||||||
|
ORecAccess dc i'1' ;read
|
||||||
|
|
||||||
|
DRec dc i'13'
|
||||||
|
DRecRef ds 2
|
||||||
|
DRecFlag ds 2
|
||||||
|
DRecBase dc i'0'
|
||||||
|
DRecDisp dc i'0'
|
||||||
|
DRecName ds 4
|
||||||
|
DRecEntry ds 2
|
||||||
|
DRecFileType ds 2
|
||||||
|
DRecEOF ds 4
|
||||||
|
DRecBlockCnt ds 4
|
||||||
|
DRecCreate ds 8
|
||||||
|
DRecMod ds 8
|
||||||
|
DRecAccess ds 2
|
||||||
|
DRecAuxType ds 4
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Hash the path variable
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
hashpath START
|
||||||
|
|
||||||
|
using hashdata
|
||||||
|
|
||||||
|
len equ 1
|
||||||
|
pathnum equ len+2
|
||||||
|
ptr equ pathnum+2
|
||||||
|
files equ ptr+4
|
||||||
|
pathptr equ files+4
|
||||||
|
space equ pathptr+4
|
||||||
|
end equ space+3
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
;
|
||||||
|
; allocate special file node
|
||||||
|
;
|
||||||
|
ph4 #fn_size
|
||||||
|
jsl ~NEW
|
||||||
|
sta hash_files
|
||||||
|
sta files
|
||||||
|
stx hash_files+2
|
||||||
|
stx files+2
|
||||||
|
|
||||||
|
jsl alloc256
|
||||||
|
sta EPParm+6
|
||||||
|
stx EPParm+6+2
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
lda #254
|
||||||
|
sta [ptr]
|
||||||
|
;
|
||||||
|
; initialize counters and pointers
|
||||||
|
;
|
||||||
|
lda #0
|
||||||
|
sta hash_numexe
|
||||||
|
sta pathnum
|
||||||
|
ldy #fn_next
|
||||||
|
sta [files],y
|
||||||
|
ldy #fn_next+2
|
||||||
|
sta [files],y
|
||||||
|
ldy #fn_name
|
||||||
|
sta [files],y
|
||||||
|
sta [files]
|
||||||
|
;
|
||||||
|
; allocate memory for $path variable
|
||||||
|
;
|
||||||
|
jsl alloc256
|
||||||
|
sta pathparm+4
|
||||||
|
stx pathparm+4+2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
;
|
||||||
|
; read $PATH
|
||||||
|
;
|
||||||
|
Read_Variable pathparm
|
||||||
|
|
||||||
|
jsr p2cstr
|
||||||
|
stx pathptr+2
|
||||||
|
sta pathptr
|
||||||
|
stx pathparm+6 ;for disposal only
|
||||||
|
sta pathparm+4
|
||||||
|
pla
|
||||||
|
plx
|
||||||
|
jsl free256 ;pushed earlier
|
||||||
|
;
|
||||||
|
; begin parsing $path
|
||||||
|
;
|
||||||
|
loop lda [pathptr]
|
||||||
|
and #$FF
|
||||||
|
jeq done
|
||||||
|
;
|
||||||
|
; parse next pathname
|
||||||
|
;
|
||||||
|
mv4 pathptr,ptr
|
||||||
|
ldy #0
|
||||||
|
despace lda [pathptr],y
|
||||||
|
and #$FF
|
||||||
|
beq gotspace0
|
||||||
|
if2 @a,eq,#' ',gotspace1
|
||||||
|
if2 @a,eq,#009,gotspace1
|
||||||
|
if2 @a,eq,#013,gotspace1
|
||||||
|
if2 @a,eq,#'\',gotquote
|
||||||
|
iny
|
||||||
|
bra despace
|
||||||
|
gotquote iny2
|
||||||
|
bra despace
|
||||||
|
gotspace0 tyx
|
||||||
|
bra gotspace3
|
||||||
|
gotspace1 tyx
|
||||||
|
short a
|
||||||
|
lda #0
|
||||||
|
sta [pathptr],y
|
||||||
|
long a
|
||||||
|
gotspace2 iny
|
||||||
|
lda [pathptr],y
|
||||||
|
and #$FF
|
||||||
|
if2 @a,eq,#' ',gotspace2
|
||||||
|
if2 @a,eq,#009,gotspace2
|
||||||
|
if2 @a,eq,#013,gotspace2
|
||||||
|
gotspace3 anop
|
||||||
|
clc
|
||||||
|
tya
|
||||||
|
adc pathptr
|
||||||
|
sta pathptr
|
||||||
|
|
||||||
|
lda pathnum
|
||||||
|
cmp #32*4
|
||||||
|
bcc numok
|
||||||
|
ldx #^toomanyerr
|
||||||
|
lda #toomanyerr
|
||||||
|
jsr errputs
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
numok pei (ptr+2)
|
||||||
|
pei (ptr)
|
||||||
|
jsr c2gsstr
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta EPParm+2
|
||||||
|
stx EPParm+4
|
||||||
|
ExpandPath EPParm
|
||||||
|
bcc epok
|
||||||
|
|
||||||
|
ldx #^eperrstr
|
||||||
|
lda #eperrstr
|
||||||
|
jsr errputs
|
||||||
|
jsl nullfree
|
||||||
|
jmp next
|
||||||
|
|
||||||
|
epok jsl nullfree
|
||||||
|
|
||||||
|
lda EPParm+6+2
|
||||||
|
sta ptr+2
|
||||||
|
lda EPParm+6
|
||||||
|
inc2 a
|
||||||
|
sta ptr
|
||||||
|
lda [ptr]
|
||||||
|
sta len
|
||||||
|
inc2 a
|
||||||
|
tay
|
||||||
|
lda #0
|
||||||
|
sta [ptr],y
|
||||||
|
pea 0
|
||||||
|
phy
|
||||||
|
jsl ~NEW
|
||||||
|
phx ;for dir_search
|
||||||
|
pha
|
||||||
|
pei (ptr+2)
|
||||||
|
inc2 ptr
|
||||||
|
pei (ptr)
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
ldy pathnum
|
||||||
|
sta hash_paths,y
|
||||||
|
txa
|
||||||
|
sta hash_paths+2,y
|
||||||
|
jsr copycstr
|
||||||
|
ldy len
|
||||||
|
beq go4it
|
||||||
|
dey
|
||||||
|
lda [ptr],y
|
||||||
|
and #$FF
|
||||||
|
cmp #':'
|
||||||
|
beq go4it
|
||||||
|
iny
|
||||||
|
lda #':'
|
||||||
|
sta [ptr],y
|
||||||
|
iny
|
||||||
|
lda #0
|
||||||
|
sta [ptr],y
|
||||||
|
|
||||||
|
go4it lda pathnum
|
||||||
|
lsr2 a
|
||||||
|
pha
|
||||||
|
pei (files+2)
|
||||||
|
pei (files)
|
||||||
|
jsl dir_search
|
||||||
|
add2 pathnum,#4,pathnum
|
||||||
|
|
||||||
|
next jmp loop
|
||||||
|
|
||||||
|
done ph4 pathparm+4
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
lda hash_print
|
||||||
|
beq noprint
|
||||||
|
|
||||||
|
Int2Dec (hash_numexe,#hashnum,#3,#0)
|
||||||
|
ldx #^hashmsg
|
||||||
|
lda #hashmsg
|
||||||
|
jsr puts
|
||||||
|
|
||||||
|
noprint ld2 1,hash_print
|
||||||
|
|
||||||
|
ph4 hash_files
|
||||||
|
jsl dohash
|
||||||
|
sta hash_table
|
||||||
|
stx hash_table+2
|
||||||
|
|
||||||
|
lda EPParm+6
|
||||||
|
ldx EPParm+6+2
|
||||||
|
jsl free256
|
||||||
|
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
pathparm dc a4'pathvar'
|
||||||
|
ds 4
|
||||||
|
pathvar str 'path'
|
||||||
|
|
||||||
|
hashmsg dc c'hashed '
|
||||||
|
hashnum dc c'000 files',h'0d00'
|
||||||
|
|
||||||
|
EPParm dc i'2'
|
||||||
|
ds 4
|
||||||
|
ds 4
|
||||||
|
|
||||||
|
eperrstr dc c'rehash: Invalid pathname syntax.',h'0d00'
|
||||||
|
toomanyerr dc c'rehash: Too many paths specified.',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Dispose of hashing tables
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
dispose_hash START
|
||||||
|
|
||||||
|
using hashdata
|
||||||
|
|
||||||
|
ora2 hash_table,hash_table+2,@a
|
||||||
|
beq done
|
||||||
|
|
||||||
|
ldx #32
|
||||||
|
ldy #0
|
||||||
|
loop1 phx
|
||||||
|
phy
|
||||||
|
lda hash_paths+2,y
|
||||||
|
pha
|
||||||
|
lda hash_paths,y
|
||||||
|
pha
|
||||||
|
lda #0
|
||||||
|
sta hash_paths+2,y
|
||||||
|
sta hash_paths,y
|
||||||
|
jsl nullfree
|
||||||
|
next1 ply
|
||||||
|
plx
|
||||||
|
iny4
|
||||||
|
dex
|
||||||
|
bne loop1
|
||||||
|
|
||||||
|
ph4 hash_files
|
||||||
|
jsl free_files
|
||||||
|
stz hash_files
|
||||||
|
stz hash_files+2
|
||||||
|
|
||||||
|
ph4 hash_table
|
||||||
|
jsl dispose_table
|
||||||
|
stz hash_table
|
||||||
|
stz hash_table+2
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Hash data
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
hashdata DATA
|
||||||
|
|
||||||
|
t_size ds 2
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
END
|
574
bin/gsh/history.asm
Normal file
574
bin/gsh/history.asm
Normal file
|
@ -0,0 +1,574 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* HISTORY.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Routines for dealing with history buffers.
|
||||||
|
*
|
||||||
|
* History Data Structures:
|
||||||
|
*
|
||||||
|
* HistoryPtr -> historyRec [HistoryPtr is the most recent history]
|
||||||
|
*
|
||||||
|
* Where historyRec is:
|
||||||
|
*
|
||||||
|
* [+0] NextHistory: pointer to historyRec
|
||||||
|
* [+4] HistoryCmd: string of characters
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/history
|
||||||
|
mcopy m/history.mac
|
||||||
|
|
||||||
|
histNext gequ 0
|
||||||
|
histCmd gequ 4
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Add a C string to the head of the history buffer.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
InsertHistory START
|
||||||
|
|
||||||
|
using HistoryData
|
||||||
|
using global
|
||||||
|
|
||||||
|
ptr2 equ 0
|
||||||
|
ptr equ ptr2+4
|
||||||
|
len equ ptr+4
|
||||||
|
space equ len+2
|
||||||
|
|
||||||
|
subroutine (4:cmd),space
|
||||||
|
|
||||||
|
pei (cmd+2)
|
||||||
|
pei (cmd)
|
||||||
|
jsr cstrlen
|
||||||
|
sta len
|
||||||
|
pea 0
|
||||||
|
clc
|
||||||
|
adc #4+1
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
ora ptr+2
|
||||||
|
beq putdone
|
||||||
|
|
||||||
|
inc lasthist
|
||||||
|
inc numhist
|
||||||
|
|
||||||
|
lda historyptr ;Set up linked list pointers
|
||||||
|
sta [ptr]
|
||||||
|
ldy #histNext+2
|
||||||
|
lda historyptr+2
|
||||||
|
sta [ptr],y
|
||||||
|
mv4 ptr,historyptr
|
||||||
|
|
||||||
|
pei (cmd+2)
|
||||||
|
pei (cmd)
|
||||||
|
pei (ptr+2)
|
||||||
|
clc
|
||||||
|
lda ptr
|
||||||
|
adc #4
|
||||||
|
pha
|
||||||
|
jsr copycstr
|
||||||
|
;
|
||||||
|
; Now, find out what the maximum history is and prune to that value
|
||||||
|
;
|
||||||
|
putdone anop
|
||||||
|
|
||||||
|
Read_Variable RVParm
|
||||||
|
lda buffer
|
||||||
|
and #$FF
|
||||||
|
beq alldone
|
||||||
|
Dec2Int (#buffer+1,@a,#0),@a
|
||||||
|
sta size
|
||||||
|
beq alldone
|
||||||
|
;
|
||||||
|
; Follow linked list until we reach size histories
|
||||||
|
;
|
||||||
|
mv4 historyptr,ptr
|
||||||
|
ldy #histNext+2
|
||||||
|
follow lda [ptr]
|
||||||
|
tax
|
||||||
|
ora [ptr],y
|
||||||
|
beq alldone ;not enough
|
||||||
|
dec size
|
||||||
|
beq prune
|
||||||
|
lda [ptr],y
|
||||||
|
sta ptr+2
|
||||||
|
stx ptr
|
||||||
|
bra follow
|
||||||
|
;
|
||||||
|
; we have enough, start pruning
|
||||||
|
;
|
||||||
|
prune lda [ptr]
|
||||||
|
sta ptr2
|
||||||
|
lda [ptr],y
|
||||||
|
sta ptr2+2
|
||||||
|
lda #0
|
||||||
|
sta [ptr]
|
||||||
|
sta [ptr],y ;terminate last history
|
||||||
|
;
|
||||||
|
; Dispose remaining
|
||||||
|
;
|
||||||
|
dispose lda ptr2
|
||||||
|
ora ptr2+2
|
||||||
|
beq alldone
|
||||||
|
dec numhist
|
||||||
|
lda [ptr2]
|
||||||
|
sta ptr
|
||||||
|
lda [ptr2],y
|
||||||
|
sta ptr+2
|
||||||
|
pei (ptr2+2)
|
||||||
|
pei (ptr2)
|
||||||
|
jsl nullfree
|
||||||
|
lda ptr
|
||||||
|
sta ptr2
|
||||||
|
lda ptr+2
|
||||||
|
sta ptr2+2
|
||||||
|
ldy #histNext+2
|
||||||
|
bra dispose
|
||||||
|
|
||||||
|
alldone return
|
||||||
|
|
||||||
|
RVParm dc a4'historyStr'
|
||||||
|
dc a4'buffer'
|
||||||
|
|
||||||
|
size ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Places the previous history into the command buffer, called when pressing
|
||||||
|
; UP-ARROW.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
PrevHistory START
|
||||||
|
|
||||||
|
using HistoryData
|
||||||
|
using global
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
ora2 historyptr,historyptr+2,@a ;If no history, then skip
|
||||||
|
jeq ctl5a
|
||||||
|
|
||||||
|
ldx cmdloc ;Move cursor to beginning of line
|
||||||
|
jsr moveleft
|
||||||
|
|
||||||
|
lda cdcap
|
||||||
|
ora cdcap
|
||||||
|
beq ctl5b0
|
||||||
|
tputs (cdcap,#0,#outc)
|
||||||
|
bra ctl5g
|
||||||
|
|
||||||
|
ctl5b0 ldx cmdlen ;clear line
|
||||||
|
ctl5b dex
|
||||||
|
bmi ctl5c
|
||||||
|
phx
|
||||||
|
lda #' '
|
||||||
|
jsr putchar
|
||||||
|
plx
|
||||||
|
bra ctl5b
|
||||||
|
ctl5c ldx cmdlen
|
||||||
|
jsr moveleft
|
||||||
|
|
||||||
|
ctl5g ora2 currenthist,currenthist+2,@a
|
||||||
|
bne ctl5i ;If not set up for current hist then
|
||||||
|
lda historyptr+2 ;Set up at start.
|
||||||
|
ldx historyptr
|
||||||
|
ldy #2
|
||||||
|
bra ctl5j
|
||||||
|
|
||||||
|
ctl5i mv4 currenthist,0 ;Otherwise move to previous history
|
||||||
|
stz cmdlen
|
||||||
|
stz cmdloc
|
||||||
|
ldy #HistNext+2
|
||||||
|
lda [0]
|
||||||
|
tax
|
||||||
|
lda [0],y
|
||||||
|
|
||||||
|
ctl5j sta 0+2 ;Save some pointers
|
||||||
|
stx 0
|
||||||
|
sta currenthist+2
|
||||||
|
stx currenthist
|
||||||
|
ora 0 ;If ptr is 0 then at end, quit
|
||||||
|
beq ctl5a
|
||||||
|
|
||||||
|
ldx #0 ;Display and store command
|
||||||
|
iny2
|
||||||
|
ctl5h lda [0],y
|
||||||
|
and #$FF
|
||||||
|
sta cmdline,x
|
||||||
|
beq ctl5ha
|
||||||
|
inx
|
||||||
|
iny
|
||||||
|
bra ctl5h
|
||||||
|
ctl5ha stx cmdlen
|
||||||
|
stx cmdloc
|
||||||
|
|
||||||
|
ldx #^cmdline
|
||||||
|
lda #cmdline
|
||||||
|
jsr puts
|
||||||
|
|
||||||
|
ctl5a rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Places the next history into the command buffer, called when pressing
|
||||||
|
; DOWN-ARROW.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
NextHistory START
|
||||||
|
|
||||||
|
using HistoryData
|
||||||
|
using global
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
ora2 historyptr,historyptr+2,@a ;No hist, then skip
|
||||||
|
jeq ctl6a
|
||||||
|
|
||||||
|
stz 4 ;Walk through linked list searching
|
||||||
|
stz 4+2 ; for hist prior to last hist.
|
||||||
|
mv4 historyptr,0
|
||||||
|
ctl6i if2 0,ne,currenthist,ctl6j
|
||||||
|
if2 0+2,eq,currenthist+2,ctl6k
|
||||||
|
ctl6j mv4 0,4
|
||||||
|
ldy #HistNext+2
|
||||||
|
lda [0]
|
||||||
|
tax
|
||||||
|
lda [0],y
|
||||||
|
sta 0+2
|
||||||
|
stx 0
|
||||||
|
bra ctl6i
|
||||||
|
|
||||||
|
ctl6k ldx cmdloc ;Move cursor to left
|
||||||
|
jsr moveleft
|
||||||
|
|
||||||
|
lda cdcap
|
||||||
|
ora cdcap
|
||||||
|
beq ctl6b0
|
||||||
|
tputs (cdcap,#0,#outc)
|
||||||
|
bra ctl6g
|
||||||
|
|
||||||
|
ctl6b0 ldx cmdlen ;clear line
|
||||||
|
ctl6b dex
|
||||||
|
bmi ctl6c
|
||||||
|
phx
|
||||||
|
lda #' '
|
||||||
|
jsr putchar
|
||||||
|
plx
|
||||||
|
bra ctl6b
|
||||||
|
ctl6c ldx cmdlen
|
||||||
|
jsr moveleft
|
||||||
|
|
||||||
|
ctl6g stz cmdlen ;Get hist info.
|
||||||
|
stz cmdloc
|
||||||
|
mv4 4,currenthist
|
||||||
|
ora2 4,4+2,@a
|
||||||
|
beq ctl6a ;Whoops, back to end, quit
|
||||||
|
|
||||||
|
ldx #0 ;Output the new command
|
||||||
|
ldy #4
|
||||||
|
ctl6h lda [4],y
|
||||||
|
and #$ff
|
||||||
|
sta cmdline,x
|
||||||
|
beq ctl6ha
|
||||||
|
iny
|
||||||
|
inx
|
||||||
|
bra ctl6h
|
||||||
|
ctl6ha stx cmdlen
|
||||||
|
stx cmdloc
|
||||||
|
|
||||||
|
ldx #^cmdline
|
||||||
|
lda #cmdline
|
||||||
|
jsr puts
|
||||||
|
|
||||||
|
ctl6a rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Save History if variable set
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
SaveHistory START
|
||||||
|
|
||||||
|
using HistoryData
|
||||||
|
using global
|
||||||
|
|
||||||
|
lda historyFN
|
||||||
|
sta DestroyParm+2
|
||||||
|
sta CreateParm+2
|
||||||
|
sta OpenParm+4
|
||||||
|
lda historyFN+2
|
||||||
|
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
|
||||||
|
;
|
||||||
|
; Create and write history to file
|
||||||
|
;
|
||||||
|
Destroy DestroyParm
|
||||||
|
Create CreateParm
|
||||||
|
jcs done
|
||||||
|
Open OpenParm
|
||||||
|
bcs done
|
||||||
|
mv2 OpenRef,(WriteRef,WriteCRRef,CloseRef)
|
||||||
|
|
||||||
|
loop1 mv4 historyptr,0
|
||||||
|
mv2 size,count
|
||||||
|
ldy #histNext+2
|
||||||
|
loop2 lda 0
|
||||||
|
ora 0+2
|
||||||
|
beq next
|
||||||
|
lda [0]
|
||||||
|
tax
|
||||||
|
dec count
|
||||||
|
beq write
|
||||||
|
lda [0],y
|
||||||
|
sta 0+2
|
||||||
|
stx 0
|
||||||
|
bra loop2
|
||||||
|
write clc
|
||||||
|
lda 0
|
||||||
|
adc #4
|
||||||
|
tax
|
||||||
|
sta WriteBuf
|
||||||
|
lda 0+2
|
||||||
|
adc #0
|
||||||
|
sta WriteBuf+2
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
jsr cstrlen
|
||||||
|
sta WriteReq
|
||||||
|
Write WriteParm
|
||||||
|
bcs doneclose
|
||||||
|
Write WriteCR
|
||||||
|
bcs doneclose
|
||||||
|
next dec size
|
||||||
|
bne loop1
|
||||||
|
|
||||||
|
doneclose Close CloseParm
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
RVParm dc a4'savehistStr'
|
||||||
|
dc a4'buffer'
|
||||||
|
|
||||||
|
DestroyParm dc i2'1'
|
||||||
|
dc a4'historyFN'
|
||||||
|
|
||||||
|
CreateParm dc i2'3'
|
||||||
|
dc a4'historyFN'
|
||||||
|
dc i2'$C3'
|
||||||
|
dc i2'0'
|
||||||
|
|
||||||
|
OpenParm dc i2'2'
|
||||||
|
OpenRef ds 2
|
||||||
|
dc a4'historyFN'
|
||||||
|
|
||||||
|
WriteParm dc i2'4'
|
||||||
|
WriteRef ds 2
|
||||||
|
WriteBuf dc a4'buffer'
|
||||||
|
WriteReq ds 4
|
||||||
|
ds 4
|
||||||
|
|
||||||
|
WriteCR dc i2'4'
|
||||||
|
WriteCRRef ds 2
|
||||||
|
dc a4'CRBuf'
|
||||||
|
dc i4'1'
|
||||||
|
ds 4
|
||||||
|
CRBuf dc i1'13'
|
||||||
|
|
||||||
|
CloseParm dc i2'1'
|
||||||
|
CloseRef ds 2
|
||||||
|
|
||||||
|
size ds 2
|
||||||
|
count ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Read History file
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
ReadHistory START
|
||||||
|
|
||||||
|
using HistoryData
|
||||||
|
using global
|
||||||
|
|
||||||
|
lda historyFN
|
||||||
|
sta OpenParm+4
|
||||||
|
lda historyFN+2
|
||||||
|
sta OpenParm+6
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta historyptr
|
||||||
|
sta historyptr+2
|
||||||
|
|
||||||
|
Open OpenParm
|
||||||
|
bcs done
|
||||||
|
mv2 OpenRef,(ReadRef,NLRef,CloseRef)
|
||||||
|
NewLine NLParm
|
||||||
|
bcs doneclose
|
||||||
|
|
||||||
|
loop anop
|
||||||
|
Read ReadParm
|
||||||
|
bcs doneclose
|
||||||
|
ldy ReadTrans
|
||||||
|
beq doneclose
|
||||||
|
dey
|
||||||
|
lda #0
|
||||||
|
sta buffer,y
|
||||||
|
ph4 #buffer
|
||||||
|
jsl InsertHistory
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
doneclose Close CloseParm
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
OpenParm dc i2'2'
|
||||||
|
OpenRef ds 2
|
||||||
|
dc a4'historyFN'
|
||||||
|
|
||||||
|
NLParm dc i2'4'
|
||||||
|
NLRef ds 2
|
||||||
|
dc i2'$7F'
|
||||||
|
dc i2'1'
|
||||||
|
dc a4'NLTable'
|
||||||
|
NLTable dc i1'13'
|
||||||
|
|
||||||
|
ReadParm dc i2'4'
|
||||||
|
ReadRef ds 2
|
||||||
|
dc a4'buffer'
|
||||||
|
dc i4'1024'
|
||||||
|
ReadTrans ds 4
|
||||||
|
|
||||||
|
CloseParm dc i2'1'
|
||||||
|
CloseRef ds 2
|
||||||
|
|
||||||
|
size ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Init History
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
InitHistory START
|
||||||
|
using HistoryData
|
||||||
|
|
||||||
|
ph4 #histName
|
||||||
|
jsl AppendHome
|
||||||
|
stx historyFN+2
|
||||||
|
sta historyFN
|
||||||
|
rts
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Print History
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
PrintHistory START
|
||||||
|
|
||||||
|
using HistoryData
|
||||||
|
using global
|
||||||
|
|
||||||
|
ptr equ 0
|
||||||
|
space equ ptr+4
|
||||||
|
|
||||||
|
subroutine (2:argc,4:argv),space
|
||||||
|
|
||||||
|
lda historyptr
|
||||||
|
ora historyptr+2
|
||||||
|
beq done
|
||||||
|
|
||||||
|
lda numhist
|
||||||
|
sta num
|
||||||
|
loop1 mv4 historyptr,ptr
|
||||||
|
lda num
|
||||||
|
bmi done
|
||||||
|
sta count
|
||||||
|
loop2 lda count
|
||||||
|
beq print
|
||||||
|
ldy #histNext+2
|
||||||
|
lda [ptr]
|
||||||
|
tax
|
||||||
|
lda [ptr],y
|
||||||
|
sta ptr+2
|
||||||
|
stx ptr
|
||||||
|
ora ptr
|
||||||
|
beq next
|
||||||
|
dec count
|
||||||
|
bra loop2
|
||||||
|
|
||||||
|
print sub2 lasthist,num,@a
|
||||||
|
Int2Dec (@a,#numbstr,#4,#0)
|
||||||
|
ldx #^numbstr
|
||||||
|
lda #numbstr
|
||||||
|
jsr puts
|
||||||
|
clc
|
||||||
|
ldx ptr+2
|
||||||
|
lda ptr
|
||||||
|
adc #4
|
||||||
|
ok jsr puts
|
||||||
|
jsr newline
|
||||||
|
|
||||||
|
next dec num
|
||||||
|
bra loop1
|
||||||
|
|
||||||
|
done return
|
||||||
|
|
||||||
|
numbstr dc c'0000: ',h'00'
|
||||||
|
num ds 2
|
||||||
|
count ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; History 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'
|
||||||
|
historyFN ds 4
|
||||||
|
|
||||||
|
END
|
709
bin/gsh/invoke.asm
Normal file
709
bin/gsh/invoke.asm
Normal file
|
@ -0,0 +1,709 @@
|
||||||
|
***********************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* INVOKE.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Command invocation routines.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
mcopy m/invoke.mac
|
||||||
|
keep o/invoke.mac
|
||||||
|
|
||||||
|
SIGINT gequ 2
|
||||||
|
SIGKILL gequ 9
|
||||||
|
SIGTERM gequ 15
|
||||||
|
SIGSTOP gequ 17
|
||||||
|
SIGTSTP gequ 18
|
||||||
|
SIGCONT gequ 19
|
||||||
|
SIGCHLD gequ 20
|
||||||
|
SIGTTIN gequ 21
|
||||||
|
SIGTTOU gequ 22
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Redirect
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
redirect START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
pipeout2 equ space+3
|
||||||
|
pipein2 equ pipeout2+2
|
||||||
|
pipeout equ pipein2+2
|
||||||
|
pipein equ pipeout+2
|
||||||
|
eapp equ pipein+2
|
||||||
|
app equ eapp+2
|
||||||
|
efile equ app+2
|
||||||
|
dfile equ efile+4
|
||||||
|
sfile equ dfile+4
|
||||||
|
end equ sfile+4
|
||||||
|
|
||||||
|
; subroutine (4:sfile,4:dfile,4:efile,2:app,2:eapp,2:pipein,2:pipeout,2:pipein2,2:pipeout2),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
;
|
||||||
|
; standard input
|
||||||
|
;
|
||||||
|
ora2 sfile,sfile+2,@a
|
||||||
|
beq execa
|
||||||
|
pei (sfile+2) ;for c2pstr
|
||||||
|
pei (sfile)
|
||||||
|
pei (sfile+2)
|
||||||
|
pei (sfile)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta RedirectFile
|
||||||
|
stx RedirectFile+2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr c2pstr
|
||||||
|
stz RedirectDev
|
||||||
|
stz RedirectApp
|
||||||
|
Redirect RedirectParm
|
||||||
|
php
|
||||||
|
ph4 RedirectFile
|
||||||
|
jsl nullfree
|
||||||
|
plp
|
||||||
|
bcc execa
|
||||||
|
ldx #^err1
|
||||||
|
lda #err1
|
||||||
|
jmp badbye
|
||||||
|
;
|
||||||
|
; standard output
|
||||||
|
;
|
||||||
|
execa ora2 dfile,dfile+2,@a
|
||||||
|
beq execb
|
||||||
|
pei (dfile+2) ;for c2pstr
|
||||||
|
pei (dfile)
|
||||||
|
pei (dfile+2)
|
||||||
|
pei (dfile)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta RedirectFile
|
||||||
|
stx RedirectFile+2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr c2pstr
|
||||||
|
ld2 1,RedirectDev
|
||||||
|
mv2 app,RedirectApp
|
||||||
|
Redirect RedirectParm
|
||||||
|
php
|
||||||
|
ph4 RedirectFile
|
||||||
|
jsl nullfree
|
||||||
|
plp
|
||||||
|
bcc execb
|
||||||
|
ldx #^err2
|
||||||
|
lda #err2
|
||||||
|
jmp badbye
|
||||||
|
;
|
||||||
|
; standard error
|
||||||
|
;
|
||||||
|
execb ora2 efile,efile+2,@a
|
||||||
|
beq execc
|
||||||
|
pei (efile+2) ;for c2pstr
|
||||||
|
pei (efile)
|
||||||
|
pei (efile+2)
|
||||||
|
pei (efile)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta RedirectFile
|
||||||
|
stx RedirectFile+2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr c2pstr
|
||||||
|
ld2 2,RedirectDev
|
||||||
|
mv2 eapp,RedirectApp
|
||||||
|
Redirect RedirectParm
|
||||||
|
php
|
||||||
|
ph4 RedirectFile
|
||||||
|
jsl nullfree
|
||||||
|
plp
|
||||||
|
bcc execc
|
||||||
|
ldx #^err3
|
||||||
|
lda #err3
|
||||||
|
jmp badbye
|
||||||
|
;
|
||||||
|
; is input piped in?
|
||||||
|
;
|
||||||
|
execc lda pipein
|
||||||
|
beq execd
|
||||||
|
dup2 (pipein,#1)
|
||||||
|
mv2 pipein2,CloseRef
|
||||||
|
Close CloseParm
|
||||||
|
ldx #0
|
||||||
|
lda pipein
|
||||||
|
SetInputDevice (#3,@xa)
|
||||||
|
;
|
||||||
|
; is output piped?
|
||||||
|
;
|
||||||
|
execd lda pipeout
|
||||||
|
beq exece
|
||||||
|
dup2 (pipeout,#2)
|
||||||
|
mv2 pipeout2,CloseRef
|
||||||
|
Close CloseParm
|
||||||
|
ldx #0
|
||||||
|
lda pipeout
|
||||||
|
SetOutputDevice (#3,@xa)
|
||||||
|
|
||||||
|
exece anop
|
||||||
|
|
||||||
|
goodbye ldy #0
|
||||||
|
bra exit
|
||||||
|
badbye jsr errputs
|
||||||
|
cop $7F ; get out of the way
|
||||||
|
ldy #1
|
||||||
|
exit lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
cpy #1
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
RedirectParm anop
|
||||||
|
RedirectDev ds 2
|
||||||
|
RedirectApp ds 2
|
||||||
|
RedirectFile ds 4
|
||||||
|
CloseParm dc i'1'
|
||||||
|
CloseRef dc i'0'
|
||||||
|
|
||||||
|
err1 dc c'gsh: Error redirecting standard input.',h'0d00'
|
||||||
|
err2 dc c'gsh: Error redirecting standard output.',h'0d00'
|
||||||
|
err3 dc c'gsh: Error redirecting standard error.',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Invoke a command (PHASE 0)
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
invoke START
|
||||||
|
|
||||||
|
using hashdata
|
||||||
|
using vardata
|
||||||
|
using global
|
||||||
|
using pdata
|
||||||
|
|
||||||
|
p equ 0
|
||||||
|
biflag equ p+4
|
||||||
|
ptr equ biflag+2
|
||||||
|
val equ ptr+4
|
||||||
|
dir equ val+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
|
||||||
|
stz biflag ;not a built-in
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
bne chknull
|
||||||
|
|
||||||
|
lda sfile
|
||||||
|
ora sfile+2
|
||||||
|
ora dfile
|
||||||
|
ora dfile+2
|
||||||
|
ora efile
|
||||||
|
ora efile+2
|
||||||
|
beq nulldone
|
||||||
|
|
||||||
|
ldx #^hehstr
|
||||||
|
lda #hehstr
|
||||||
|
jsr errputs
|
||||||
|
|
||||||
|
nulldone jmp done
|
||||||
|
;
|
||||||
|
; Check for null command
|
||||||
|
;
|
||||||
|
chknull ldy #2
|
||||||
|
lda [argv]
|
||||||
|
sta dir
|
||||||
|
lda [argv],y
|
||||||
|
sta dir+2
|
||||||
|
ora dir
|
||||||
|
beq gonull
|
||||||
|
lda [dir]
|
||||||
|
and #$FF
|
||||||
|
bne checkfile
|
||||||
|
gonull jmp done
|
||||||
|
;
|
||||||
|
; check for file
|
||||||
|
;
|
||||||
|
checkfile anop
|
||||||
|
|
||||||
|
pei (dir+2)
|
||||||
|
pei (dir)
|
||||||
|
jsl IsBuiltin ;check builtin first
|
||||||
|
cmp #-1
|
||||||
|
jne trybuiltin
|
||||||
|
|
||||||
|
pei (dir+2)
|
||||||
|
pei (dir)
|
||||||
|
ph4 hash_table
|
||||||
|
ph4 #hash_paths
|
||||||
|
jsl search
|
||||||
|
cmp #0
|
||||||
|
bne changeit
|
||||||
|
cpx #0
|
||||||
|
beq skip
|
||||||
|
|
||||||
|
changeit sta dir
|
||||||
|
stx dir+2
|
||||||
|
|
||||||
|
skip lock mutex2
|
||||||
|
pei (dir+2)
|
||||||
|
pei (dir)
|
||||||
|
jsr c2gsstr
|
||||||
|
sta GRecPath
|
||||||
|
sta ptr
|
||||||
|
stx GRecPath+2
|
||||||
|
stx ptr+2
|
||||||
|
|
||||||
|
GetFileInfo GRec
|
||||||
|
unlock mutex2
|
||||||
|
jcs notfound
|
||||||
|
|
||||||
|
if2 GRecFileType,eq,#$B5,doExec
|
||||||
|
if2 @a,eq,#$B3,doExec
|
||||||
|
ldx vardirexec
|
||||||
|
bne ft02
|
||||||
|
cmp #$0F
|
||||||
|
jeq doDir
|
||||||
|
ft02 if2 @a,ne,#$B0,badfile
|
||||||
|
if2 GRecAuxType,ne,#6,badfile
|
||||||
|
if2 GRecAuxType+2,ne,#0,badfile
|
||||||
|
jmp doShell
|
||||||
|
badfile ldx dir+2
|
||||||
|
lda dir
|
||||||
|
jsr errputs
|
||||||
|
ldx #^err1
|
||||||
|
lda #err1
|
||||||
|
jsr errputs
|
||||||
|
free pei (ptr+2)
|
||||||
|
pei (ptr)
|
||||||
|
jsl nullfree
|
||||||
|
jmp done
|
||||||
|
;
|
||||||
|
; launch an executable
|
||||||
|
;
|
||||||
|
doExec pei (ptr+2)
|
||||||
|
pei (ptr)
|
||||||
|
jsl nullfree
|
||||||
|
jsr prefork
|
||||||
|
fork #invoke0
|
||||||
|
jsr postfork
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
invoke0 phk
|
||||||
|
plb
|
||||||
|
;
|
||||||
|
; make a a copy of cmd
|
||||||
|
;
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
ldx #0
|
||||||
|
tsc
|
||||||
|
FindHandle @xa,1
|
||||||
|
ldy #6
|
||||||
|
lda [1],y ;This is the UserID!
|
||||||
|
and #$F0FF
|
||||||
|
pha
|
||||||
|
ph4 _cmd
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
ply
|
||||||
|
pha
|
||||||
|
ldx #0
|
||||||
|
NewHandle (@xa,@y,#$4018,#0),1
|
||||||
|
ply
|
||||||
|
ldx #0
|
||||||
|
PtrToHand (_cmd,1,@xy)
|
||||||
|
ldy #2
|
||||||
|
lda [1],y
|
||||||
|
tax
|
||||||
|
lda [1]
|
||||||
|
pld
|
||||||
|
ply
|
||||||
|
ply
|
||||||
|
phx ;_cmd
|
||||||
|
pha
|
||||||
|
;
|
||||||
|
; make a a copy of dir
|
||||||
|
;
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
ldx #0
|
||||||
|
tsc
|
||||||
|
FindHandle @xa,1
|
||||||
|
ldy #6
|
||||||
|
lda [1],y ;This is the UserID!
|
||||||
|
and #$F0FF
|
||||||
|
pha
|
||||||
|
ph4 _dir
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
ply
|
||||||
|
pha
|
||||||
|
ldx #0
|
||||||
|
NewHandle (@xa,@y,#$4018,#0),1
|
||||||
|
ply
|
||||||
|
ldx #0
|
||||||
|
PtrToHand (_dir,1,@xy)
|
||||||
|
ldy #2
|
||||||
|
lda [1],y
|
||||||
|
tax
|
||||||
|
lda [1]
|
||||||
|
pld
|
||||||
|
ply
|
||||||
|
ply
|
||||||
|
phx ;_dir
|
||||||
|
pha
|
||||||
|
|
||||||
|
jsl infork
|
||||||
|
bcs invoke1
|
||||||
|
case on
|
||||||
|
jsl execve
|
||||||
|
case off
|
||||||
|
rtl
|
||||||
|
invoke1 pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
rtl
|
||||||
|
;
|
||||||
|
; do path (it was a directory entry so change to that directory)
|
||||||
|
;
|
||||||
|
doDir lock cdmutex
|
||||||
|
mv4 GRecPath,PRecPath
|
||||||
|
SetPrefix PRec
|
||||||
|
unlock cdmutex
|
||||||
|
stz val
|
||||||
|
jmp free
|
||||||
|
;
|
||||||
|
; fork a shell script
|
||||||
|
;
|
||||||
|
doShell inc biflag ;don't free argv...
|
||||||
|
jsr prefork
|
||||||
|
|
||||||
|
* int fork2(void *subr, int stack, int prio, char *name, word argc, ...)
|
||||||
|
pea 0
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
lda [argv]
|
||||||
|
pha
|
||||||
|
pea 0
|
||||||
|
pea 1024
|
||||||
|
ph4 #exec0
|
||||||
|
case on
|
||||||
|
jsl fork2
|
||||||
|
case off
|
||||||
|
|
||||||
|
* fork #exec0
|
||||||
|
jsr postfork
|
||||||
|
jmp free
|
||||||
|
|
||||||
|
exec0 ph2 _argc ;for argfree
|
||||||
|
ph4 _argv
|
||||||
|
|
||||||
|
ph4 _dir ;for shellexec
|
||||||
|
ph2 _argc
|
||||||
|
ph4 _argv
|
||||||
|
jsl infork
|
||||||
|
bcs exec0c
|
||||||
|
signal (#SIGCHLD,#0)
|
||||||
|
PushVariables 0
|
||||||
|
pea 1
|
||||||
|
jsl ShellExec
|
||||||
|
jsl argfree
|
||||||
|
PopVariables 0
|
||||||
|
rtl
|
||||||
|
exec0c pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
rtl
|
||||||
|
;
|
||||||
|
; file not found, so try a builtin.
|
||||||
|
;
|
||||||
|
trybuiltin inc biflag ;it's a built-in
|
||||||
|
cmp #1
|
||||||
|
beq noforkbuiltin
|
||||||
|
jsr prefork
|
||||||
|
fork #forkbuiltin
|
||||||
|
jsr postfork
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
forkbuiltin cop $7F ;give palloc a chance
|
||||||
|
ph2 _argc
|
||||||
|
ph4 _argv
|
||||||
|
jsl infork
|
||||||
|
bcs fork0c
|
||||||
|
jsl builtin
|
||||||
|
rtl
|
||||||
|
fork0c pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
rtl
|
||||||
|
|
||||||
|
noforkbuiltin anop
|
||||||
|
pei (argc)
|
||||||
|
pei (argv+2)
|
||||||
|
pei (argv)
|
||||||
|
jsl builtin
|
||||||
|
stz val
|
||||||
|
bra done
|
||||||
|
|
||||||
|
notfound pei (ptr+2)
|
||||||
|
pei (ptr)
|
||||||
|
jsl nullfree
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
tax
|
||||||
|
lda [argv]
|
||||||
|
jsr errputs
|
||||||
|
ldx #^err2
|
||||||
|
lda #err2
|
||||||
|
jsr errputs
|
||||||
|
lda pipein
|
||||||
|
beq notfound0
|
||||||
|
ssignal _semaphore
|
||||||
|
sdelete _semaphore
|
||||||
|
mv4 pjoblist,p
|
||||||
|
ldy #16 ;p_jobid
|
||||||
|
lda [p],y
|
||||||
|
getpgrp @a
|
||||||
|
eor #$FFFF
|
||||||
|
inc a
|
||||||
|
kill (@a,#9)
|
||||||
|
sigpause #0
|
||||||
|
notfound0 anop
|
||||||
|
|
||||||
|
done cop $7F
|
||||||
|
lda biflag
|
||||||
|
bne skipfrarg
|
||||||
|
|
||||||
|
pei (argc)
|
||||||
|
pei (argv+2)
|
||||||
|
pei (argv)
|
||||||
|
jsl argfree
|
||||||
|
|
||||||
|
skipfrarg pei (cmd+2)
|
||||||
|
pei (cmd)
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
return 2:val
|
||||||
|
;
|
||||||
|
;
|
||||||
|
; stuff to do just before forking
|
||||||
|
;
|
||||||
|
prefork lock mutex
|
||||||
|
SetInGlobals (#$FF,#00)
|
||||||
|
mv4 sfile,_sfile
|
||||||
|
mv4 dfile,_dfile
|
||||||
|
mv4 efile,_efile
|
||||||
|
mv2 app,_app
|
||||||
|
mv2 eapp,_eapp
|
||||||
|
mv4 cmd,_cmd
|
||||||
|
mv4 dir,_dir
|
||||||
|
mv2 argc,_argc
|
||||||
|
mv4 argv,_argv
|
||||||
|
mv2 pipein,_pipein
|
||||||
|
mv2 pipeout,_pipeout
|
||||||
|
mv2 pipein2,_pipein2
|
||||||
|
mv2 pipeout2,_pipeout2
|
||||||
|
mv2 bg,_bg
|
||||||
|
mv2 jobflag,_jobflag
|
||||||
|
lda [pipesem]
|
||||||
|
sta _semaphore
|
||||||
|
lda pipesem
|
||||||
|
sta putsem+1
|
||||||
|
lda pipesem+1
|
||||||
|
sta putsem+2
|
||||||
|
rts
|
||||||
|
;
|
||||||
|
; stuff to do right after forking
|
||||||
|
;
|
||||||
|
postfork sta val
|
||||||
|
lda pipein
|
||||||
|
beq postfork2
|
||||||
|
sta CloseRef
|
||||||
|
Close CloseParm
|
||||||
|
postfork2 lda pipeout
|
||||||
|
beq postfork3
|
||||||
|
sta CloseRef
|
||||||
|
Close CloseParm
|
||||||
|
postfork3 lda val
|
||||||
|
cmp #-1
|
||||||
|
bne postfork4
|
||||||
|
ldx #^deadstr
|
||||||
|
lda #deadstr
|
||||||
|
jsr errputs
|
||||||
|
unlock mutex
|
||||||
|
jmp done
|
||||||
|
postfork4 ldx jobflag
|
||||||
|
dex
|
||||||
|
beq postfork5
|
||||||
|
pha
|
||||||
|
pei (bg)
|
||||||
|
pei (cmd+2)
|
||||||
|
pei (cmd)
|
||||||
|
lda pipein
|
||||||
|
bne postfork4a
|
||||||
|
jsl palloc
|
||||||
|
bra postfork5
|
||||||
|
postfork4a jsl pallocpipe
|
||||||
|
postfork5 lda >mutex ;DANGER!!!!! Assumes knowledge of
|
||||||
|
beq postfork6 ;lock/unlock structure!!!!!!!!
|
||||||
|
cop $7F
|
||||||
|
bra postfork5
|
||||||
|
postfork6 rts
|
||||||
|
;
|
||||||
|
; stuff to do in fork
|
||||||
|
;
|
||||||
|
infork phk
|
||||||
|
plb
|
||||||
|
|
||||||
|
lda _jobflag
|
||||||
|
bne invoke0b
|
||||||
|
|
||||||
|
Open ttyopen
|
||||||
|
jcs doneinfork
|
||||||
|
|
||||||
|
lda _pipein
|
||||||
|
bne invoke0a
|
||||||
|
tcnewpgrp ttyref
|
||||||
|
invoke0a settpgrp ttyref
|
||||||
|
lda _bg ;if in background then reset tty to
|
||||||
|
and #$FF
|
||||||
|
beq invoke0b ;to the shell process group
|
||||||
|
tctpgrp (gshtty,gshpid)
|
||||||
|
|
||||||
|
invoke0b ph4 _sfile
|
||||||
|
ph4 _dfile
|
||||||
|
ph4 _efile
|
||||||
|
ph2 _app
|
||||||
|
ph2 _eapp
|
||||||
|
ph2 _pipein
|
||||||
|
ph2 _pipeout
|
||||||
|
ph2 _pipein2
|
||||||
|
ph2 _pipeout2
|
||||||
|
jsl redirect
|
||||||
|
jcs doneinfork
|
||||||
|
|
||||||
|
unlock mutex
|
||||||
|
|
||||||
|
lda _pipein
|
||||||
|
bne invoke0c
|
||||||
|
lda _pipeout
|
||||||
|
beq invoke0d
|
||||||
|
screate #0
|
||||||
|
putsem sta >$FFFFFF
|
||||||
|
swait @a
|
||||||
|
bra invoke0d
|
||||||
|
invoke0c lda _pipeout
|
||||||
|
bne invoke0d
|
||||||
|
waitsemy lda _semaphore
|
||||||
|
bne goodsemy
|
||||||
|
cop $7F
|
||||||
|
bra waitsemy
|
||||||
|
goodsemy ssignal _semaphore
|
||||||
|
sdelete _semaphore
|
||||||
|
|
||||||
|
invoke0d anop
|
||||||
|
|
||||||
|
clc
|
||||||
|
bra indone
|
||||||
|
|
||||||
|
doneinfork unlock mutex
|
||||||
|
sec
|
||||||
|
indone rtl
|
||||||
|
|
||||||
|
mutex key
|
||||||
|
mutex2 key
|
||||||
|
cdmutex key
|
||||||
|
|
||||||
|
_argc dc i2'0'
|
||||||
|
_argv dc i4'0'
|
||||||
|
_sfile dc i4'0'
|
||||||
|
_dfile dc i4'0'
|
||||||
|
_efile dc i4'0'
|
||||||
|
_app dc i2'0'
|
||||||
|
_eapp dc i2'0'
|
||||||
|
_cmd dc i4'0'
|
||||||
|
_dir dc i4'0'
|
||||||
|
_pipein dc i2'0'
|
||||||
|
_pipeout dc i2'0'
|
||||||
|
_pipein2 dc i2'0'
|
||||||
|
_pipeout2 dc i2'0'
|
||||||
|
_bg dc i2'0'
|
||||||
|
_jobflag dc i2'0'
|
||||||
|
_semaphore dc i2'0'
|
||||||
|
|
||||||
|
str dc c'[0]',h'0d00'
|
||||||
|
err1 dc c': Not executable.',h'0d00'
|
||||||
|
err2 dc c': Command not found.',h'0d00'
|
||||||
|
hehstr dc c'heh heh, next time you''ll need to specify a command '
|
||||||
|
dc c'before redirecting.',h'0d00'
|
||||||
|
deadstr dc c'Cannot fork (too many processes?)',h'0d00' ;try a spoon
|
||||||
|
|
||||||
|
GRec dc i'4'
|
||||||
|
GRecPath ds 4
|
||||||
|
ds 2
|
||||||
|
GRecFileType ds 2
|
||||||
|
GRecAuxType ds 4
|
||||||
|
|
||||||
|
PRec dc i'2'
|
||||||
|
PRecNum dc i'0'
|
||||||
|
PRecPath ds 4
|
||||||
|
|
||||||
|
CloseParm dc i2'1'
|
||||||
|
CloseRef dc i2'0'
|
||||||
|
|
||||||
|
Err dc i2'0'
|
||||||
|
|
||||||
|
ttyopen dc i2'2'
|
||||||
|
ttyref dc i2'0'
|
||||||
|
dc i4'ttyname'
|
||||||
|
ttyname gsstr '.tty'
|
||||||
|
|
||||||
|
END
|
1721
bin/gsh/jobs.asm
Normal file
1721
bin/gsh/jobs.asm
Normal file
File diff suppressed because it is too large
Load Diff
22
bin/gsh/link.script
Normal file
22
bin/gsh/link.script
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
o/main
|
||||||
|
o/shell
|
||||||
|
o/history
|
||||||
|
o/prompt
|
||||||
|
o/cmd
|
||||||
|
o/expand
|
||||||
|
o/invoke
|
||||||
|
o/shellutil
|
||||||
|
o/builtin
|
||||||
|
o/hash
|
||||||
|
o/alias
|
||||||
|
o/dir
|
||||||
|
o/shellvar
|
||||||
|
o/jobs
|
||||||
|
o/sv
|
||||||
|
o/stdio
|
||||||
|
o/orca
|
||||||
|
o/edit
|
||||||
|
o/term
|
||||||
|
o/bufpool
|
||||||
|
direct
|
||||||
|
keep=gsh
|
347
bin/gsh/m16.gno
Normal file
347
bin/gsh/m16.gno
Normal file
|
@ -0,0 +1,347 @@
|
||||||
|
*************************************************************************
|
||||||
|
*
|
||||||
|
* GNO/ME system call macros for Orca/M.
|
||||||
|
* Copyright (C) 1991 by Procyon, Inc.
|
||||||
|
*
|
||||||
|
*************************************************************************
|
||||||
|
|
||||||
|
;
|
||||||
|
; assembly mutual exclusion macros
|
||||||
|
;
|
||||||
|
MACRO
|
||||||
|
&lab lock &a1
|
||||||
|
&lab lda #1
|
||||||
|
tsb &a1
|
||||||
|
beq *+6
|
||||||
|
cop $7F
|
||||||
|
bra *-7
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab unlock &a1
|
||||||
|
&lab stz &a1
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab key
|
||||||
|
&lab dc i2'0'
|
||||||
|
MEND
|
||||||
|
;
|
||||||
|
; GNO system calls
|
||||||
|
;
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kernVersion &a1
|
||||||
|
&lab pha
|
||||||
|
ldx #$403
|
||||||
|
jsl $E10008
|
||||||
|
pl2 &a1
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kernStatus &a1
|
||||||
|
&lab pha
|
||||||
|
ldx #$603
|
||||||
|
jsl $E10008
|
||||||
|
pl2 &a1
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kill &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl kill
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab fork &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl fork
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab exec &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl exec
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab swait &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl swait
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab ssignal &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl ssignal
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab screate &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl screate
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab sdelete &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl sdelete
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab signal &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl signal
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab wait &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl wait
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tcnewpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl tcnewpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab settpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl settpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tctpgrp &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tctpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab sigsetmask &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl sigsetmask
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab sigblock &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl sigblock
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab execve &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl execve
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab alarm &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl alarm
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab setdebug &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl setdebug
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab setsystemvector &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl setsystemvector
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab sigpause &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl sigpause
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab getpid
|
||||||
|
&lab case on
|
||||||
|
jsl getpid
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kvm_open
|
||||||
|
&lab case on
|
||||||
|
jsl kvm_open
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kvm_close &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl kvm_close
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kvmgetproc &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl kvmgetproc
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kvmnextproc &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl kvmnextproc
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab kvmsetproc &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl kvmsetproc
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab getpgrp &a1
|
||||||
|
&lab ph2 &a1
|
||||||
|
case on
|
||||||
|
jsl getpgrp
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab pipe &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl pipe
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab dup2 &a1
|
||||||
|
&lab ph2 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl dup2
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab ioctl &a1
|
||||||
|
&lab ph4 &a1(3)
|
||||||
|
ph4 &a1(2)
|
||||||
|
ph2 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl ioctl
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tgetent &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tgetent
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tgetstr &a1
|
||||||
|
&lab ph4 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tgetstr
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tgetnum &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl tgetnum
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tgetflag &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
case on
|
||||||
|
jsl tgetflag
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tgoto &a1
|
||||||
|
&lab ph2 &a1(3)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tgoto
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab tputs &a1
|
||||||
|
&lab ph4 &a1(3)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph4 &a1(1)
|
||||||
|
case on
|
||||||
|
jsl tputs
|
||||||
|
case off
|
||||||
|
MEND
|
||||||
|
|
||||||
|
MACRO
|
||||||
|
&lab getuid
|
||||||
|
&lab case on
|
||||||
|
jsl getuid
|
||||||
|
case off
|
||||||
|
MEND
|
143
bin/gsh/main.asm
Normal file
143
bin/gsh/main.asm
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* MAIN.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/main
|
||||||
|
mcopy m/main.mac
|
||||||
|
|
||||||
|
init START
|
||||||
|
jml ~GNO_COMMAND
|
||||||
|
END
|
||||||
|
|
||||||
|
MAIN START
|
||||||
|
|
||||||
|
using global
|
||||||
|
|
||||||
|
p equ 0
|
||||||
|
arg equ p+4
|
||||||
|
space equ arg+4
|
||||||
|
|
||||||
|
subroutine (2:argc,4:argv),space
|
||||||
|
|
||||||
|
kernStatus @a
|
||||||
|
bcc ok
|
||||||
|
|
||||||
|
ErrWriteCString #str
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
ok stz FastFlag
|
||||||
|
stz CmdFlag
|
||||||
|
stz ExecFlag
|
||||||
|
|
||||||
|
argloop dec argc
|
||||||
|
jeq start
|
||||||
|
clc
|
||||||
|
lda argv
|
||||||
|
adc #4
|
||||||
|
sta argv
|
||||||
|
ldy #2
|
||||||
|
lda [argv]
|
||||||
|
sta arg
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
lda [arg]
|
||||||
|
and #$FF
|
||||||
|
cmp #'-'
|
||||||
|
beq intoption
|
||||||
|
|
||||||
|
; parse remaining args as a command to run
|
||||||
|
|
||||||
|
inc ExecFlag
|
||||||
|
inc FastFlag
|
||||||
|
ph4 #1024
|
||||||
|
jsl ~NEW
|
||||||
|
sta ExecCmd
|
||||||
|
sta p
|
||||||
|
stx ExecCmd+2
|
||||||
|
stx p+2
|
||||||
|
|
||||||
|
cmd3 ldy #0
|
||||||
|
cmd0 lda [arg],y
|
||||||
|
and #$ff
|
||||||
|
beq cmd1
|
||||||
|
sta [p],y
|
||||||
|
iny
|
||||||
|
bra cmd0
|
||||||
|
cmd1 lda #' '
|
||||||
|
sta [p],y
|
||||||
|
sec ;inc a
|
||||||
|
tya
|
||||||
|
adc p
|
||||||
|
sta p
|
||||||
|
dec argc
|
||||||
|
beq cmd2
|
||||||
|
clc
|
||||||
|
lda argv
|
||||||
|
adc #4
|
||||||
|
sta argv
|
||||||
|
ldy #2
|
||||||
|
lda [argv]
|
||||||
|
sta arg
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
bra cmd3
|
||||||
|
cmd2 lda #0
|
||||||
|
sta [p]
|
||||||
|
bra start
|
||||||
|
|
||||||
|
intoption ldy #1
|
||||||
|
optloop lda [arg],y
|
||||||
|
and #$FF
|
||||||
|
beq nextarg
|
||||||
|
cmp #'f'
|
||||||
|
beq optf
|
||||||
|
cmp #'c'
|
||||||
|
beq parsec
|
||||||
|
|
||||||
|
showusage ErrWriteCString #usage
|
||||||
|
bra done
|
||||||
|
|
||||||
|
optf inc FastFlag
|
||||||
|
|
||||||
|
nextopt iny
|
||||||
|
bra optloop
|
||||||
|
|
||||||
|
nextarg cpy #1
|
||||||
|
beq showusage
|
||||||
|
jmp argloop
|
||||||
|
|
||||||
|
parsec clc
|
||||||
|
lda argv
|
||||||
|
adc #4
|
||||||
|
sta argv
|
||||||
|
dec argc
|
||||||
|
beq showusage
|
||||||
|
inc CmdFlag
|
||||||
|
inc FastFlag
|
||||||
|
mv4 argv,CmdArgV
|
||||||
|
mv2 argc,CmdArgC
|
||||||
|
|
||||||
|
start case on
|
||||||
|
jsl shell
|
||||||
|
case off
|
||||||
|
|
||||||
|
done return
|
||||||
|
|
||||||
|
str dc h'0d0a0a'
|
||||||
|
dc c'Before gsh may be run, the GNO/ME system, or kernel, must be running.'
|
||||||
|
dc h'0d0a0a00'
|
||||||
|
|
||||||
|
usage dc c'Usage: gsh [-cf] [argument...]',h'0d0a00'
|
||||||
|
|
||||||
|
END
|
281
bin/gsh/mdb.mac
Normal file
281
bin/gsh/mdb.mac
Normal file
|
@ -0,0 +1,281 @@
|
||||||
|
MACRO
|
||||||
|
&lab subroutine &parms,&work
|
||||||
|
&lab anop
|
||||||
|
aif c:&work,.a
|
||||||
|
lclc &work
|
||||||
|
&work setc 0
|
||||||
|
.a
|
||||||
|
gbla &totallen
|
||||||
|
gbla &worklen
|
||||||
|
&worklen seta &work
|
||||||
|
&totallen seta 0
|
||||||
|
aif c:&parms=0,.e
|
||||||
|
lclc &len
|
||||||
|
lclc &p
|
||||||
|
lcla &i
|
||||||
|
&i seta c:&parms
|
||||||
|
.b
|
||||||
|
&p setc &parms(&i)
|
||||||
|
&len amid &p,2,1
|
||||||
|
aif "&len"=":",.c
|
||||||
|
&len amid &p,1,2
|
||||||
|
&p amid &p,4,l:&p-3
|
||||||
|
ago .d
|
||||||
|
.c
|
||||||
|
&len amid &p,1,1
|
||||||
|
&p amid &p,3,l:&p-2
|
||||||
|
.d
|
||||||
|
&p equ &totallen+3+&work
|
||||||
|
&totallen seta &totallen+&len
|
||||||
|
&i seta &i-1
|
||||||
|
aif &i,^b
|
||||||
|
.e
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #&work
|
||||||
|
tcs
|
||||||
|
inc a
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab return &r
|
||||||
|
&lab anop
|
||||||
|
lclc &len
|
||||||
|
aif c:&r,.a
|
||||||
|
lclc &r
|
||||||
|
&r setc 0
|
||||||
|
&len setc 0
|
||||||
|
ago .h
|
||||||
|
.a
|
||||||
|
&len amid &r,2,1
|
||||||
|
aif "&len"=":",.b
|
||||||
|
&len amid &r,1,2
|
||||||
|
&r amid &r,4,l:&r-3
|
||||||
|
ago .c
|
||||||
|
.b
|
||||||
|
&len amid &r,1,1
|
||||||
|
&r amid &r,3,l:&r-2
|
||||||
|
.c
|
||||||
|
aif &len<>2,.d
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.d
|
||||||
|
aif &len<>4,.e
|
||||||
|
ldx &r+2
|
||||||
|
ldy &r
|
||||||
|
ago .h
|
||||||
|
.e
|
||||||
|
aif &len<>10,.g
|
||||||
|
ldy #&r
|
||||||
|
ldx #^&r
|
||||||
|
ago .h
|
||||||
|
.g
|
||||||
|
mnote 'Not a valid return length',16
|
||||||
|
mexit
|
||||||
|
.h
|
||||||
|
aif &totallen=0,.i
|
||||||
|
lda &worklen+1
|
||||||
|
sta &worklen+&totallen+1
|
||||||
|
lda &worklen
|
||||||
|
sta &worklen+&totallen
|
||||||
|
.i
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #&worklen+&totallen
|
||||||
|
tcs
|
||||||
|
aif &len=0,.j
|
||||||
|
tya
|
||||||
|
.j
|
||||||
|
rtl
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab FindHandle &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph4 &a1
|
||||||
|
tool $1a02
|
||||||
|
pl4 &a2
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab pl4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
aif s:longa=1,.start
|
||||||
|
rep #%00100000
|
||||||
|
.start
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"<>"{",.chk
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
pla
|
||||||
|
sta (&parm)
|
||||||
|
ldy #2
|
||||||
|
pla
|
||||||
|
sta (&parm),y
|
||||||
|
ago .shorten
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"[",.chk2
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
ldy #2
|
||||||
|
pla
|
||||||
|
sta &parm,y
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"@",.absolute
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
pl&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
pl&char2
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
pla
|
||||||
|
sta &parm
|
||||||
|
pla
|
||||||
|
sta &parm+2
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab ph4 &parm
|
||||||
|
lclc &char
|
||||||
|
lclc &char1
|
||||||
|
lclc &char2
|
||||||
|
&lab anop
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk1
|
||||||
|
rep #%00100000
|
||||||
|
.chk1
|
||||||
|
aif "&char"<>"{",.chk2
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
ldy #2
|
||||||
|
lda (&parm),y
|
||||||
|
pha
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.chk2
|
||||||
|
aif "&char"<>"[",.absolute
|
||||||
|
ldy #2
|
||||||
|
lda &parm,y
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm+2
|
||||||
|
pha
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.at
|
||||||
|
&char1 amid &parm,2,1
|
||||||
|
&char2 setc &char1
|
||||||
|
ph&char1
|
||||||
|
aif l:&parm<3,.chk2a
|
||||||
|
&char2 amid &parm,3,1
|
||||||
|
.chk2a
|
||||||
|
ph&char2
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea +(&parm)|-16
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab tool &a1
|
||||||
|
&lab ldx #&a1
|
||||||
|
jsl $e10000
|
||||||
|
mend
|
||||||
|
MACRO
|
||||||
|
&lab name
|
||||||
|
&lab anop
|
||||||
|
aif DebugSymbols=0,.pastName
|
||||||
|
brl pastName&SYSCNT
|
||||||
|
dc i'$7771'
|
||||||
|
dc i1'L:&lab',c'&lab'
|
||||||
|
pastName&SYSCNT anop
|
||||||
|
.pastName
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&lab NewHandle &a1,&a2
|
||||||
|
&lab pha
|
||||||
|
pha
|
||||||
|
ph4 &a1(1)
|
||||||
|
ph2 &a1(2)
|
||||||
|
ph2 &a1(3)
|
||||||
|
ph4 &a1(4)
|
||||||
|
tool $0902
|
||||||
|
pl4 &a2
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab DisposeHandle &a1
|
||||||
|
&lab ph4 &a1
|
||||||
|
tool $1002
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&lab ph2 &parm
|
||||||
|
lclc &char
|
||||||
|
&lab anop
|
||||||
|
aif c:&parm=0,.done
|
||||||
|
&char amid &parm,1,1
|
||||||
|
aif "&char"="#",.immediate
|
||||||
|
aif "&char"="@",.at
|
||||||
|
aif s:longa=1,.chk
|
||||||
|
rep #%00100000
|
||||||
|
.chk
|
||||||
|
aif "&char"<>"{",.absolute
|
||||||
|
&char amid &parm,l:&parm,1
|
||||||
|
aif "&char"<>"}",.error
|
||||||
|
&parm amid &parm,2,l:&parm-2
|
||||||
|
lda (&parm)
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.absolute
|
||||||
|
lda &parm
|
||||||
|
pha
|
||||||
|
ago .shorten
|
||||||
|
.immediate
|
||||||
|
&parm amid &parm,2,l:&parm-1
|
||||||
|
pea &parm
|
||||||
|
ago .done
|
||||||
|
.at
|
||||||
|
&char amid &parm,2,1
|
||||||
|
ph&char
|
||||||
|
.shorten
|
||||||
|
aif s:longa=1,.done
|
||||||
|
sep #%00100000
|
||||||
|
.done
|
||||||
|
mexit
|
||||||
|
.error
|
||||||
|
mnote "Missing closing '}'",16
|
||||||
|
mend
|
41
bin/gsh/mmdebug.asm
Normal file
41
bin/gsh/mmdebug.asm
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
mcopy mdb.mac
|
||||||
|
|
||||||
|
~NEW START
|
||||||
|
hand equ 0
|
||||||
|
ptr equ 4
|
||||||
|
_~NEW name
|
||||||
|
|
||||||
|
subroutine (4:size),8
|
||||||
|
|
||||||
|
NewHandle (size,~USER_ID,#$C018,#0),hand
|
||||||
|
lda [hand]
|
||||||
|
sta ptr
|
||||||
|
ldy #2
|
||||||
|
lda [hand],y
|
||||||
|
sta ptr+2
|
||||||
|
return 4:ptr
|
||||||
|
END
|
||||||
|
|
||||||
|
~DISPOSE START
|
||||||
|
hand equ 0
|
||||||
|
checkptr equ 4
|
||||||
|
_~DISPOSE name
|
||||||
|
|
||||||
|
subroutine (4:ptr),8
|
||||||
|
|
||||||
|
FindHandle ptr,hand
|
||||||
|
lda [hand]
|
||||||
|
sta checkptr
|
||||||
|
ldy #2
|
||||||
|
lda [hand],y
|
||||||
|
sta checkptr+2
|
||||||
|
eor ptr+2
|
||||||
|
eor ptr
|
||||||
|
eor checkptr
|
||||||
|
beq okay
|
||||||
|
|
||||||
|
brk $55
|
||||||
|
|
||||||
|
okay DisposeHandle hand
|
||||||
|
return
|
||||||
|
END
|
2
bin/gsh/mods
Normal file
2
bin/gsh/mods
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Removed two references to $E0C000 in shell.asm (signal handlers).
|
||||||
|
Bad Timmy!
|
175
bin/gsh/oldorca.asm
Normal file
175
bin/gsh/oldorca.asm
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
*************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* ORCA.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Builtin commands for Orca compiling/editing, etc.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/orca
|
||||||
|
mcopy m/orca.mac
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* EDIT: builtin command
|
||||||
|
* syntax: edit [pathname]
|
||||||
|
*
|
||||||
|
* Invokes an editor and edits a file.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
edit START
|
||||||
|
|
||||||
|
waitstatus equ 0
|
||||||
|
pid equ waitstatus+4
|
||||||
|
editfile equ pid+2
|
||||||
|
outpath equ editfile+4
|
||||||
|
errcode equ outpath+4
|
||||||
|
space equ errcode+2
|
||||||
|
|
||||||
|
subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
stz errcode
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
cmp #2
|
||||||
|
beq ok
|
||||||
|
bcc toofew
|
||||||
|
|
||||||
|
ldx #^err2
|
||||||
|
lda #err2
|
||||||
|
jmp error
|
||||||
|
toofew ldx #^err1
|
||||||
|
lda #err1
|
||||||
|
error jsr errputs
|
||||||
|
lda #2
|
||||||
|
sta errcode
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
ok lock mutex
|
||||||
|
|
||||||
|
ldy #6 ;argv[1] -> ep.inputPath
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
jsr c2gsstr ;make it a GS/OS filename
|
||||||
|
sta ep_inputPath
|
||||||
|
stx ep_inputPath+2
|
||||||
|
jsl alloc256
|
||||||
|
sta outpath
|
||||||
|
stx outpath+2
|
||||||
|
sta ep_outputPath
|
||||||
|
stx ep_outputPath+2
|
||||||
|
lda #256
|
||||||
|
sta [outpath]
|
||||||
|
ExpandPath ep
|
||||||
|
bcc ok2
|
||||||
|
ldx #^err3
|
||||||
|
lda #err3
|
||||||
|
jsr errputs
|
||||||
|
lda #-1
|
||||||
|
sta errcode
|
||||||
|
ldx outpath+2
|
||||||
|
lda outpath
|
||||||
|
jsl free256
|
||||||
|
ph4 ep_inputpath
|
||||||
|
jsl nullfree
|
||||||
|
unlock mutex
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
ok2 ph4 ep_inputpath
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
ldy #2
|
||||||
|
lda [outpath],y
|
||||||
|
xba
|
||||||
|
sta [outpath],y
|
||||||
|
add4 outpath,#3,gl ;gl.sfile
|
||||||
|
|
||||||
|
; convert ':'s to '/'s
|
||||||
|
|
||||||
|
lda [outpath],y
|
||||||
|
xba
|
||||||
|
tax
|
||||||
|
ldy #4
|
||||||
|
short a
|
||||||
|
conv lda [outpath],y
|
||||||
|
cmp #':'
|
||||||
|
bne next
|
||||||
|
lda #'/'
|
||||||
|
sta [outpath],y
|
||||||
|
next iny
|
||||||
|
dex
|
||||||
|
bne conv
|
||||||
|
long a
|
||||||
|
|
||||||
|
Set_LInfo gl ;now set up the environment
|
||||||
|
|
||||||
|
ph4 #editorvar
|
||||||
|
jsl getenv
|
||||||
|
sta editfile
|
||||||
|
stx editfile+2
|
||||||
|
ora editfile+2
|
||||||
|
bne gotedit
|
||||||
|
ph4 #defedit
|
||||||
|
jsr p2cstr
|
||||||
|
sta editfile
|
||||||
|
stx editfile+2
|
||||||
|
|
||||||
|
gotedit unlock mutex
|
||||||
|
|
||||||
|
pei (editfile+2)
|
||||||
|
pei (editfile)
|
||||||
|
ph2 #0 ;tells execute we're called by system
|
||||||
|
jsl execute
|
||||||
|
sta errcode
|
||||||
|
|
||||||
|
ldx outpath+2
|
||||||
|
lda outpath
|
||||||
|
jsl free256
|
||||||
|
|
||||||
|
pei (editfile+2)
|
||||||
|
pei (editfile)
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
done return 2:errcode
|
||||||
|
|
||||||
|
err1 dc c'edit: no filename specified',h'0d00'
|
||||||
|
err2 dc c'edit: only one filename allowed',h'0d00'
|
||||||
|
err3 dc c'edit: invalid path name',h'0d00'
|
||||||
|
|
||||||
|
mutex key
|
||||||
|
|
||||||
|
gl dc i4'0'
|
||||||
|
dc i4'nullparm'
|
||||||
|
dc i4'nullparm'
|
||||||
|
dc i4'nullparm'
|
||||||
|
dc i1'8'
|
||||||
|
dc i1'0'
|
||||||
|
dc i1'0'
|
||||||
|
dc i1'0'
|
||||||
|
dc i4'0'
|
||||||
|
dc i4'$8000000'
|
||||||
|
dc i4'0'
|
||||||
|
|
||||||
|
ep dc i2'2'
|
||||||
|
ep_inputPath dc i4'0'
|
||||||
|
ep_outputPath dc i4'0'
|
||||||
|
|
||||||
|
nullparm dc i2'0'
|
||||||
|
|
||||||
|
editorvar dc c'editor',h'00'
|
||||||
|
defedit str '4/editor'
|
||||||
|
|
||||||
|
END
|
286
bin/gsh/orca.asm
Normal file
286
bin/gsh/orca.asm
Normal file
|
@ -0,0 +1,286 @@
|
||||||
|
*************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* ORCA.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Builtin commands for Orca compiling/editing, etc.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/orca
|
||||||
|
mcopy m/orca.mac
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* EDIT: builtin command
|
||||||
|
* syntax: edit pathname...
|
||||||
|
*
|
||||||
|
* Invokes an editor and edits a file or files.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
MAXPARMBUF gequ 1023
|
||||||
|
|
||||||
|
edit START
|
||||||
|
strPtr equ 0
|
||||||
|
inLoopPtr equ strPtr+4
|
||||||
|
argLoopPtr equ inLoopPtr+4
|
||||||
|
sLen equ argLoopPtr+4
|
||||||
|
k equ sLen+2
|
||||||
|
j equ k+2
|
||||||
|
editcommand equ j+2
|
||||||
|
retval equ editcommand+4
|
||||||
|
sFile equ retval+2 GSString255Ptr
|
||||||
|
inPath equ sFile+4
|
||||||
|
outPath equ inPath+4
|
||||||
|
space equ outPath+4
|
||||||
|
|
||||||
|
subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
stz retval
|
||||||
|
stz sLen
|
||||||
|
|
||||||
|
lda #1
|
||||||
|
sta j
|
||||||
|
|
||||||
|
lda argc make sure there are two or
|
||||||
|
cmp #2 more parameters, otherwise we
|
||||||
|
bcs enoughparms
|
||||||
|
|
||||||
|
ldx #^enofile
|
||||||
|
lda #enofile
|
||||||
|
jsr errputs
|
||||||
|
lda #1
|
||||||
|
sta retval
|
||||||
|
jmp goaway
|
||||||
|
|
||||||
|
enoughparms anop
|
||||||
|
jsl alloc1024
|
||||||
|
sta sFile
|
||||||
|
stx sFile+2
|
||||||
|
ora sFile+2
|
||||||
|
beq memerr1
|
||||||
|
|
||||||
|
jsl alloc1024
|
||||||
|
sta inPath
|
||||||
|
stx inPath+2
|
||||||
|
ora inPath+2
|
||||||
|
beq memerr1
|
||||||
|
|
||||||
|
jsl alloc1024
|
||||||
|
sta outPath
|
||||||
|
stx outPath+2
|
||||||
|
ora outPath+2
|
||||||
|
bne noerr1
|
||||||
|
|
||||||
|
memerr1 ldx #^enomem
|
||||||
|
lda #enomem
|
||||||
|
jsr errputs
|
||||||
|
lda #-1
|
||||||
|
sta retval
|
||||||
|
jmp goaway
|
||||||
|
|
||||||
|
noerr1 anop
|
||||||
|
lda sFile
|
||||||
|
clc
|
||||||
|
adc #2
|
||||||
|
sta strPtr
|
||||||
|
lda sFile+2
|
||||||
|
adc #0
|
||||||
|
sta strPtr+2
|
||||||
|
|
||||||
|
doloop lda j
|
||||||
|
cmp #2
|
||||||
|
bcc nodelimit
|
||||||
|
short m
|
||||||
|
lda #10 ; newline
|
||||||
|
sta [strPtr]
|
||||||
|
long m
|
||||||
|
inc sLen
|
||||||
|
inc strPtr
|
||||||
|
bne nodelimit
|
||||||
|
inc strPtr+2
|
||||||
|
|
||||||
|
nodelimit anop
|
||||||
|
lda j
|
||||||
|
asl a ; get the proper argv pointer
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [argv],y
|
||||||
|
sta argLoopPtr
|
||||||
|
iny2
|
||||||
|
lda [argv],y
|
||||||
|
sta argLoopPtr+2
|
||||||
|
|
||||||
|
lda inPath get text field of inPath
|
||||||
|
clc
|
||||||
|
adc #2
|
||||||
|
sta inLoopPtr
|
||||||
|
lda inPath+2
|
||||||
|
adc #0
|
||||||
|
sta inLoopPtr+2
|
||||||
|
|
||||||
|
stz k
|
||||||
|
|
||||||
|
whileloop lda [argLoopPtr]
|
||||||
|
and #$00FF
|
||||||
|
beq donewhile
|
||||||
|
|
||||||
|
short m
|
||||||
|
sta [inLoopPtr]
|
||||||
|
long m
|
||||||
|
inc argLoopPtr
|
||||||
|
bne noinc2
|
||||||
|
inc argLoopPtr+2
|
||||||
|
noinc2 inc inLoopPtr
|
||||||
|
bne noinc3
|
||||||
|
inc inLoopPtr+2
|
||||||
|
noinc3 inc k
|
||||||
|
lda k
|
||||||
|
cmp #255
|
||||||
|
bcc whileloop
|
||||||
|
ldx #^einval
|
||||||
|
lda #einval
|
||||||
|
jsr errputs
|
||||||
|
lda #2
|
||||||
|
sta retval
|
||||||
|
jmp goaway
|
||||||
|
donewhile lda k
|
||||||
|
sta [inPath]
|
||||||
|
lda #1024
|
||||||
|
sta [outPath]
|
||||||
|
mv4 inPath,ep_inputPath
|
||||||
|
mv4 outPath,ep_outputPath
|
||||||
|
|
||||||
|
ExpandPath ep
|
||||||
|
bcc noeperror
|
||||||
|
ldx #^err3
|
||||||
|
lda #err3
|
||||||
|
jsr errputs
|
||||||
|
lda #-1
|
||||||
|
sta retval
|
||||||
|
jmp goaway
|
||||||
|
|
||||||
|
noeperror anop
|
||||||
|
ldy #2
|
||||||
|
lda [outPath],y
|
||||||
|
sta k
|
||||||
|
clc
|
||||||
|
adc sLen
|
||||||
|
cmp #MAXPARMBUF
|
||||||
|
bcs doloopend
|
||||||
|
|
||||||
|
pei (k)
|
||||||
|
pei (outPath+2)
|
||||||
|
lda outPath
|
||||||
|
clc
|
||||||
|
adc #4
|
||||||
|
pha
|
||||||
|
pei (strPtr+2)
|
||||||
|
pei (strPtr)
|
||||||
|
jsl rmemcpy
|
||||||
|
|
||||||
|
lda sLen
|
||||||
|
clc
|
||||||
|
adc k
|
||||||
|
sta sLen
|
||||||
|
lda strPtr
|
||||||
|
clc
|
||||||
|
adc k
|
||||||
|
sta strPtr
|
||||||
|
lda strPtr+2
|
||||||
|
adc #0
|
||||||
|
sta strPtr+2
|
||||||
|
doloopend inc j
|
||||||
|
lda j
|
||||||
|
cmp argc
|
||||||
|
jcc doloop
|
||||||
|
|
||||||
|
lda sLen
|
||||||
|
sta [sFile]
|
||||||
|
mv4 sFile,gl_sFile
|
||||||
|
|
||||||
|
Set_LInfoGS gl ;now set up the environment
|
||||||
|
|
||||||
|
ph4 #editorvar
|
||||||
|
jsl getenv
|
||||||
|
sta editcommand
|
||||||
|
stx editcommand+2
|
||||||
|
ora editcommand+2
|
||||||
|
bne goteditvar
|
||||||
|
|
||||||
|
ph4 #defedit
|
||||||
|
jsr p2cstr
|
||||||
|
sta editcommand
|
||||||
|
stx editcommand+2
|
||||||
|
|
||||||
|
goteditvar anop
|
||||||
|
pei (editcommand+2)
|
||||||
|
pei (editcommand)
|
||||||
|
ph2 #0 ;tells execute we're called by system
|
||||||
|
jsl execute
|
||||||
|
sta retval
|
||||||
|
|
||||||
|
pei (editcommand+2)
|
||||||
|
pei (editcommand)
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
goaway lda sFile
|
||||||
|
ora sFile+2
|
||||||
|
beq donedealloc
|
||||||
|
ldx sFile+2
|
||||||
|
lda sFile
|
||||||
|
jsl free1024
|
||||||
|
|
||||||
|
lda inPath
|
||||||
|
ora inPath+2
|
||||||
|
beq donedealloc
|
||||||
|
ldx inPath+2
|
||||||
|
lda inPath
|
||||||
|
jsl free1024
|
||||||
|
|
||||||
|
lda outPath
|
||||||
|
ora outPath+2
|
||||||
|
beq donedealloc
|
||||||
|
ldx outPath+2
|
||||||
|
lda outPath
|
||||||
|
jsl free1024
|
||||||
|
|
||||||
|
donedealloc return 2:retval
|
||||||
|
|
||||||
|
ep dc i2'2'
|
||||||
|
ep_inputPath dc i4'0'
|
||||||
|
ep_outputPath dc i4'0'
|
||||||
|
|
||||||
|
enofile dc c'edit: no filename specified',h'0D00'
|
||||||
|
enomem dc c'edit: out of memory',h'0D00'
|
||||||
|
einval dc c'edit: invalid argument (filename too long)',h'0D00'
|
||||||
|
err3 dc c'edit: invalid path name',h'0d00'
|
||||||
|
|
||||||
|
gl anop
|
||||||
|
dc i2'11'
|
||||||
|
gl_sfile dc i4'0'
|
||||||
|
dc i4'nullparm'
|
||||||
|
dc i4'nullparm'
|
||||||
|
dc i4'nullparm'
|
||||||
|
dc i1'8'
|
||||||
|
dc i1'0'
|
||||||
|
dc i1'0'
|
||||||
|
dc i1'0'
|
||||||
|
dc i4'0'
|
||||||
|
dc i4'$8000000'
|
||||||
|
dc i4'0'
|
||||||
|
|
||||||
|
nullparm dc i2'0'
|
||||||
|
|
||||||
|
editorvar dc c'editor',h'00'
|
||||||
|
defedit str '4:editor'
|
||||||
|
END
|
415
bin/gsh/prompt.asm
Normal file
415
bin/gsh/prompt.asm
Normal file
|
@ -0,0 +1,415 @@
|
||||||
|
*************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* PROMPT.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* This displays the command-line prompt
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/prompt
|
||||||
|
mcopy m/prompt.mac
|
||||||
|
|
||||||
|
WritePrompt START
|
||||||
|
|
||||||
|
using HistoryData
|
||||||
|
|
||||||
|
|
||||||
|
prompt equ 0
|
||||||
|
hour equ prompt+4
|
||||||
|
minute equ hour+2
|
||||||
|
offset equ minute+2
|
||||||
|
pfx equ offset+2
|
||||||
|
space equ pfx+4
|
||||||
|
|
||||||
|
year equ hour
|
||||||
|
monday equ minute
|
||||||
|
precmd equ prompt
|
||||||
|
|
||||||
|
subroutine (0:dummy),space
|
||||||
|
|
||||||
|
ph4 #precmdstr
|
||||||
|
jsl findalias
|
||||||
|
sta precmd
|
||||||
|
stx precmd+2
|
||||||
|
ora precmd+2
|
||||||
|
beq getvar
|
||||||
|
|
||||||
|
pei (precmd+2)
|
||||||
|
pei (precmd)
|
||||||
|
ph2 #0
|
||||||
|
jsl execute
|
||||||
|
|
||||||
|
getvar Read_Variable promptparm
|
||||||
|
|
||||||
|
php
|
||||||
|
sei ;interrupt free environment
|
||||||
|
|
||||||
|
lda promptbuf
|
||||||
|
and #$FF
|
||||||
|
bne parseprompt
|
||||||
|
|
||||||
|
ldx #^dfltPrompt
|
||||||
|
lda #dfltPrompt
|
||||||
|
jsr puts
|
||||||
|
|
||||||
|
bra donemark2
|
||||||
|
|
||||||
|
precmdstr dc c'precmd',h'00'
|
||||||
|
|
||||||
|
parseprompt anop
|
||||||
|
|
||||||
|
ph4 #promptbuf
|
||||||
|
jsr p2cstr
|
||||||
|
phx ;for disposal
|
||||||
|
pha
|
||||||
|
stx prompt+2
|
||||||
|
sta prompt
|
||||||
|
|
||||||
|
promptloop lda [prompt]
|
||||||
|
inc prompt
|
||||||
|
and #$FF
|
||||||
|
beq done
|
||||||
|
cmp #'%'
|
||||||
|
beq special
|
||||||
|
cmp #'!'
|
||||||
|
jeq phist
|
||||||
|
cmp #'\'
|
||||||
|
jeq quoteit
|
||||||
|
_putchar jsr putchar
|
||||||
|
bra promptloop
|
||||||
|
|
||||||
|
done jsr standend
|
||||||
|
jsr cursoron
|
||||||
|
jsl nullfree
|
||||||
|
donemark2 plp
|
||||||
|
jsr flush
|
||||||
|
return
|
||||||
|
|
||||||
|
special lda [prompt]
|
||||||
|
inc prompt
|
||||||
|
and #$FF
|
||||||
|
beq done
|
||||||
|
cmp #'%'
|
||||||
|
beq _putchar
|
||||||
|
cmp #'h'
|
||||||
|
beq phist
|
||||||
|
cmp #'!'
|
||||||
|
beq phist
|
||||||
|
cmp #'t'
|
||||||
|
beq ptime
|
||||||
|
cmp #'@'
|
||||||
|
beq ptime
|
||||||
|
cmp #'S'
|
||||||
|
jeq pstandout
|
||||||
|
cmp #'s'
|
||||||
|
jeq pstandend
|
||||||
|
cmp #'U'
|
||||||
|
jeq punderline
|
||||||
|
cmp #'u'
|
||||||
|
jeq punderend
|
||||||
|
cmp #'d'
|
||||||
|
jeq pcwd
|
||||||
|
cmp #'/'
|
||||||
|
jeq pcwd
|
||||||
|
cmp #'c'
|
||||||
|
jeq pcwdend
|
||||||
|
cmp #'C'
|
||||||
|
jeq pcwdend
|
||||||
|
cmp #'.'
|
||||||
|
jeq pcwdend
|
||||||
|
cmp #'n'
|
||||||
|
jeq puser
|
||||||
|
cmp #'W'
|
||||||
|
jeq pdate1
|
||||||
|
cmp #'D'
|
||||||
|
jeq pdate2
|
||||||
|
cmp #'~'
|
||||||
|
jeq ptilde
|
||||||
|
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Put history number
|
||||||
|
;
|
||||||
|
phist lda lasthist
|
||||||
|
inc a
|
||||||
|
jsr WriteNum
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Print current time
|
||||||
|
;
|
||||||
|
ptime ReadTimeHex (minute,hour,@a,@a)
|
||||||
|
lda hour
|
||||||
|
and #$FF
|
||||||
|
if2 @a,cc,#13,ptime2
|
||||||
|
sub2 @a,#12,@a
|
||||||
|
ptime2 if2 @a,ne,#0,ptime2b
|
||||||
|
lda #12
|
||||||
|
ptime2b jsr WriteNum
|
||||||
|
lda #':'
|
||||||
|
jsr putchar
|
||||||
|
lda minute
|
||||||
|
xba
|
||||||
|
and #$FF
|
||||||
|
pha
|
||||||
|
cmp #10
|
||||||
|
bcs ptime2a
|
||||||
|
lda #'0'
|
||||||
|
jsr putchar
|
||||||
|
ptime2a pla
|
||||||
|
jsr WriteNum
|
||||||
|
lda hour
|
||||||
|
and #$FF
|
||||||
|
if2 @a,cs,#12,ptime3
|
||||||
|
ptime5 lda #'a'
|
||||||
|
bra ptime4
|
||||||
|
ptime3 lda #'p'
|
||||||
|
ptime4 jsr putchar
|
||||||
|
lda #'m'
|
||||||
|
jmp _putchar
|
||||||
|
;
|
||||||
|
; Set Stand Out
|
||||||
|
;
|
||||||
|
pstandout jsr standout
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; UnSet Stand Out
|
||||||
|
;
|
||||||
|
pstandend jsr standend
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Set Underline
|
||||||
|
;
|
||||||
|
punderline jsr underline
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; UnSet Underline
|
||||||
|
;
|
||||||
|
punderend jsr underend
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Current working directory
|
||||||
|
;
|
||||||
|
pcwd jsl alloc1024
|
||||||
|
sta pfx
|
||||||
|
stx pfx+2
|
||||||
|
sta GPpfx
|
||||||
|
stx GPpfx+2
|
||||||
|
lda #1024
|
||||||
|
sta [pfx]
|
||||||
|
|
||||||
|
GetPrefix GPParm
|
||||||
|
ldy #2
|
||||||
|
lda [pfx],y
|
||||||
|
clc
|
||||||
|
adc #3
|
||||||
|
sta offset
|
||||||
|
ldy #4
|
||||||
|
pcwd1 lda [pfx],y
|
||||||
|
and #$FF
|
||||||
|
jsr toslash
|
||||||
|
phy
|
||||||
|
jsr putchar
|
||||||
|
ply
|
||||||
|
iny
|
||||||
|
cpy offset
|
||||||
|
bcc pcwd1
|
||||||
|
ldx pfx+2
|
||||||
|
lda pfx
|
||||||
|
jsl free1024
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Current tail of working directory
|
||||||
|
;
|
||||||
|
pcwdend anop
|
||||||
|
jsl alloc1024
|
||||||
|
sta pfx
|
||||||
|
stx pfx+2
|
||||||
|
sta GPpfx
|
||||||
|
stx GPpfx+2
|
||||||
|
lda #1024
|
||||||
|
sta [pfx]
|
||||||
|
|
||||||
|
GetPrefix GPParm
|
||||||
|
ldy #2
|
||||||
|
lda [pfx],y
|
||||||
|
clc
|
||||||
|
adc #3
|
||||||
|
sta offset
|
||||||
|
tay
|
||||||
|
pcwdend1 dey
|
||||||
|
bmi pcwdend2
|
||||||
|
lda [pfx],y
|
||||||
|
and #$FF
|
||||||
|
cmp #':'
|
||||||
|
bne pcwdend1
|
||||||
|
pcwdend2 iny
|
||||||
|
cpy offset
|
||||||
|
beq pcwdend3
|
||||||
|
lda [pfx],y
|
||||||
|
and #$FF
|
||||||
|
cmp #':'
|
||||||
|
beq pcwdend3
|
||||||
|
phy
|
||||||
|
jsr putchar
|
||||||
|
ply
|
||||||
|
bra pcwdend2
|
||||||
|
pcwdend3 ldx pfx+2
|
||||||
|
lda pfx
|
||||||
|
jsl free1024
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Current working directory substituting '~' if necessary
|
||||||
|
;
|
||||||
|
ptilde anop
|
||||||
|
jsl alloc1024
|
||||||
|
sta pfx
|
||||||
|
stx pfx+2
|
||||||
|
sta GPpfx
|
||||||
|
stx GPpfx+2
|
||||||
|
lda #1024
|
||||||
|
sta [pfx]
|
||||||
|
|
||||||
|
GetPrefix GPParm
|
||||||
|
ldy #2
|
||||||
|
lda [pfx],y
|
||||||
|
clc
|
||||||
|
adc #4
|
||||||
|
tay
|
||||||
|
lda #0
|
||||||
|
sta [pfx],y
|
||||||
|
pei (pfx+2)
|
||||||
|
lda pfx
|
||||||
|
clc
|
||||||
|
adc #4
|
||||||
|
pha
|
||||||
|
jsl path2tilde
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr puts
|
||||||
|
jsl ~DISPOSE
|
||||||
|
ldx pfx+2
|
||||||
|
lda pfx
|
||||||
|
jsl free1024
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Write user name
|
||||||
|
;
|
||||||
|
puser Read_Variable userparm
|
||||||
|
ldx #^buf2
|
||||||
|
lda #buf2
|
||||||
|
jsr putp
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Write date as mm/dd/yy
|
||||||
|
;
|
||||||
|
pdate1 ReadTimeHex (@a,year,monday,@a)
|
||||||
|
lda monday
|
||||||
|
and #$FF00
|
||||||
|
xba
|
||||||
|
inc a
|
||||||
|
jsr WriteNum
|
||||||
|
lda #'/'
|
||||||
|
jsr putchar
|
||||||
|
lda monday
|
||||||
|
and #$FF
|
||||||
|
inc a
|
||||||
|
jsr WriteNum
|
||||||
|
lda #'/'
|
||||||
|
jsr putchar
|
||||||
|
lda year
|
||||||
|
and #$FF00
|
||||||
|
xba
|
||||||
|
jsr WriteNum
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; Write date as yy-mm-dd
|
||||||
|
;
|
||||||
|
pdate2 ReadTimeHex (@a,year,monday,@a)
|
||||||
|
lda year
|
||||||
|
and #$FF00
|
||||||
|
xba
|
||||||
|
jsr WriteNum
|
||||||
|
lda #'-'
|
||||||
|
jsr putchar
|
||||||
|
lda monday
|
||||||
|
and #$FF00
|
||||||
|
xba
|
||||||
|
inc a
|
||||||
|
jsr WriteNum
|
||||||
|
lda #'-'
|
||||||
|
jsr putchar
|
||||||
|
lda monday
|
||||||
|
and #$FF
|
||||||
|
inc a
|
||||||
|
jsr WriteNum
|
||||||
|
jmp promptloop
|
||||||
|
;
|
||||||
|
; check for \ quote
|
||||||
|
;
|
||||||
|
quoteit lda [prompt]
|
||||||
|
inc prompt
|
||||||
|
and #$FF
|
||||||
|
jeq done
|
||||||
|
cmp #'n'
|
||||||
|
beq newline
|
||||||
|
cmp #'r'
|
||||||
|
beq newline
|
||||||
|
cmp #'t'
|
||||||
|
beq tab
|
||||||
|
cmp #'b'
|
||||||
|
beq backspace
|
||||||
|
jmp _putchar
|
||||||
|
newline lda #13
|
||||||
|
jmp _putchar
|
||||||
|
tab lda #9
|
||||||
|
jmp _putchar
|
||||||
|
backspace lda #8
|
||||||
|
jmp _putchar
|
||||||
|
;
|
||||||
|
; Write a number between 0 and 9,999
|
||||||
|
;
|
||||||
|
WriteNum cmp #10
|
||||||
|
bcs write1
|
||||||
|
adc #'0'
|
||||||
|
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
|
||||||
|
|
||||||
|
GPParm dc i2'2'
|
||||||
|
dc i2'0'
|
||||||
|
GPpfx dc a4'0'
|
||||||
|
promptparm dc a4'promptname'
|
||||||
|
dc a4'promptbuf'
|
||||||
|
promptname str 'prompt'
|
||||||
|
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
|
401
bin/gsh/shell.asm
Normal file
401
bin/gsh/shell.asm
Normal file
|
@ -0,0 +1,401 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* SHELL.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* This is the main routines for the shell.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/shell
|
||||||
|
mcopy m/shell.mac
|
||||||
|
|
||||||
|
SIGINT gequ 2
|
||||||
|
SIGTSTP gequ 18
|
||||||
|
SIGCHLD gequ 20
|
||||||
|
|
||||||
|
cmdbuflen gequ 1024
|
||||||
|
|
||||||
|
case on
|
||||||
|
shell start
|
||||||
|
case off
|
||||||
|
|
||||||
|
using global
|
||||||
|
using pdata
|
||||||
|
using HistoryData
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
p equ 0
|
||||||
|
space equ p+4
|
||||||
|
|
||||||
|
subroutine (0:dummy),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sta cmdcontext
|
||||||
|
tdc
|
||||||
|
sta cmddp
|
||||||
|
|
||||||
|
* PushVariables 0
|
||||||
|
|
||||||
|
Open ttyopen
|
||||||
|
bcc settty
|
||||||
|
ErrWriteCString #ttyerr
|
||||||
|
jmp quit
|
||||||
|
ttyerr dc c'gsh: Failed opening tty.',h'0d00'
|
||||||
|
|
||||||
|
settty mv2 ttyref,gshtty
|
||||||
|
tcnewpgrp gshtty
|
||||||
|
settpgrp gshtty
|
||||||
|
getpid
|
||||||
|
sta gshpid
|
||||||
|
|
||||||
|
jsr InitTerm
|
||||||
|
|
||||||
|
lda FastFlag
|
||||||
|
bne fastskip1
|
||||||
|
lda gshpid ; only print the copyright msg
|
||||||
|
cmp #2 ; if not using login
|
||||||
|
bne fastskip1
|
||||||
|
ldx #^gnostr
|
||||||
|
lda #gnostr
|
||||||
|
jsr puts
|
||||||
|
fastskip1 anop
|
||||||
|
|
||||||
|
signal (#SIGINT,#signal2)
|
||||||
|
signal (#SIGTSTP,#signal18)
|
||||||
|
signal (#SIGCHLD,#pchild)
|
||||||
|
setsystemvector #system
|
||||||
|
;
|
||||||
|
; Initialize some stuff
|
||||||
|
;
|
||||||
|
lda FastFlag
|
||||||
|
bne fastskip2
|
||||||
|
jsr InitHistory
|
||||||
|
jsr ReadHistory ;Read in history from disk
|
||||||
|
fastskip2 jsr initalias ;initialize alias
|
||||||
|
jsr InitDStack ;initialize directory stack
|
||||||
|
lda FastFlag
|
||||||
|
bne fastskip3
|
||||||
|
jsr DoLogin ;Read gshrc
|
||||||
|
jsr newline
|
||||||
|
fastskip3 anop
|
||||||
|
lda didReadTerm
|
||||||
|
bne didit
|
||||||
|
jsr readterm
|
||||||
|
didit jsl hashpath ;hash $path
|
||||||
|
|
||||||
|
lda CmdFlag
|
||||||
|
beq cmdskip
|
||||||
|
|
||||||
|
mv4 CmdArgV,p
|
||||||
|
ldy #2
|
||||||
|
lda [p],y
|
||||||
|
pha
|
||||||
|
lda [p]
|
||||||
|
pha
|
||||||
|
ph2 CmdArgc
|
||||||
|
pei (p+2)
|
||||||
|
pei (p)
|
||||||
|
pea 0
|
||||||
|
jsl ShellExec
|
||||||
|
jmp done1
|
||||||
|
|
||||||
|
cmdskip lda ExecFlag
|
||||||
|
beq execskip
|
||||||
|
|
||||||
|
ph4 ExecCmd
|
||||||
|
ph2 #0
|
||||||
|
jsl Execute
|
||||||
|
jmp done1
|
||||||
|
|
||||||
|
execskip anop
|
||||||
|
|
||||||
|
stz lastabort
|
||||||
|
|
||||||
|
gnoloop entry
|
||||||
|
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
|
||||||
|
lda cmdcontext ;dare you to make a mistake
|
||||||
|
tcs
|
||||||
|
lda cmddp
|
||||||
|
tcd
|
||||||
|
|
||||||
|
jsl WritePrompt
|
||||||
|
jsr GetCmdLine
|
||||||
|
bcs done
|
||||||
|
jsr newline
|
||||||
|
lda cmdlen
|
||||||
|
beq gnoloop
|
||||||
|
jsr cursoron
|
||||||
|
jsr newlineX
|
||||||
|
jsr flush
|
||||||
|
ph4 #cmdline
|
||||||
|
ph2 #0
|
||||||
|
jsl execute
|
||||||
|
lda exitamundo
|
||||||
|
bne done1
|
||||||
|
jsr newlineX
|
||||||
|
stz lastabort
|
||||||
|
bra gnoloop
|
||||||
|
;
|
||||||
|
; shut down gsh
|
||||||
|
;
|
||||||
|
done jsr newline
|
||||||
|
jsr newlineX
|
||||||
|
done1 ora2 pjoblist,pjoblist+2,@a
|
||||||
|
beq done2
|
||||||
|
lda lastabort
|
||||||
|
bne donekiller
|
||||||
|
inc lastabort
|
||||||
|
stz exitamundo
|
||||||
|
ldx #^stopstr
|
||||||
|
lda #stopstr
|
||||||
|
jsr puts
|
||||||
|
jsr newlineX
|
||||||
|
bra gnoloop
|
||||||
|
donekiller jsl jobkiller
|
||||||
|
done2 lda FastFlag
|
||||||
|
bne fastskip5
|
||||||
|
jsr SaveHistory
|
||||||
|
fastskip5 jsr dispose_hash
|
||||||
|
|
||||||
|
quit PopVariables 0
|
||||||
|
Quit QuitParm
|
||||||
|
QuitParm dc i'0'
|
||||||
|
|
||||||
|
gnostr dc h'0d',c'GNO/Shell 2.0.4',h'0d'
|
||||||
|
dc c'Copyright 1991-1993, Procyon, Inc. & Tim Meekins. '
|
||||||
|
dc c'ALL RIGHTS RESERVED',h'0d'
|
||||||
|
dc h'0d00'
|
||||||
|
stopstr dc c'gsh: There are stopped jobs.',h'0d00'
|
||||||
|
|
||||||
|
ttyopen dc i2'2'
|
||||||
|
ttyref dc i2'0'
|
||||||
|
dc i4'ttyname'
|
||||||
|
ttyname gsstr '.tty'
|
||||||
|
|
||||||
|
exitstr dc c'000000',h'0d00'
|
||||||
|
|
||||||
|
lastabort ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Interpret the login file (gshrc).
|
||||||
|
; If $HOME is set, we presume the gshrc file is there. If not,
|
||||||
|
; or if an error occurs getting the $HOME variable, we use
|
||||||
|
; @:gshrc.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
|
||||||
|
* Appends 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. Call DisposeHome/AX to deallocate the
|
||||||
|
* string.
|
||||||
|
|
||||||
|
DisposeHome START
|
||||||
|
dec a
|
||||||
|
dec a
|
||||||
|
jsl free256
|
||||||
|
rtl
|
||||||
|
END
|
||||||
|
|
||||||
|
AppendHome START
|
||||||
|
outPtr equ 0
|
||||||
|
len equ 4
|
||||||
|
subroutine (4:str),6
|
||||||
|
|
||||||
|
jsl alloc256
|
||||||
|
stx outPtr1+2
|
||||||
|
sta outPtr1
|
||||||
|
stx outPtr+2
|
||||||
|
sta outPtr
|
||||||
|
|
||||||
|
pei (str+2)
|
||||||
|
pei (str)
|
||||||
|
jsr cstrlen
|
||||||
|
sta len
|
||||||
|
|
||||||
|
lda #256
|
||||||
|
sta [outPtr]
|
||||||
|
|
||||||
|
GSOS $014B,rvbl ;ReadVariable
|
||||||
|
bcs doAtSign
|
||||||
|
|
||||||
|
ldy #2
|
||||||
|
lda [outPtr],y
|
||||||
|
beq doAtSign ; $HOME not defined?
|
||||||
|
clc
|
||||||
|
adc #4 ; turn into a cstring
|
||||||
|
tay
|
||||||
|
short m
|
||||||
|
lda #0
|
||||||
|
sta [outPtr],y
|
||||||
|
long m
|
||||||
|
bra doAppend
|
||||||
|
|
||||||
|
doAtSign lda atSign
|
||||||
|
ldy #4
|
||||||
|
sta [outPtr],y
|
||||||
|
lda #1
|
||||||
|
ldy #2
|
||||||
|
sta [outPtr],y
|
||||||
|
|
||||||
|
doAppend anop
|
||||||
|
ldy #0
|
||||||
|
short m
|
||||||
|
lp lda [outPtr],y
|
||||||
|
beq noSep
|
||||||
|
cmp #':'
|
||||||
|
beq foundSep
|
||||||
|
cmp #'/'
|
||||||
|
beq foundSep
|
||||||
|
iny
|
||||||
|
bra lp
|
||||||
|
noSep lda #':'
|
||||||
|
|
||||||
|
foundSep sta [str]
|
||||||
|
long m
|
||||||
|
|
||||||
|
pei (str+2)
|
||||||
|
pei (str)
|
||||||
|
pei (outPtr+2)
|
||||||
|
lda outPtr
|
||||||
|
clc
|
||||||
|
adc #4
|
||||||
|
pha
|
||||||
|
case on
|
||||||
|
jsl strcat
|
||||||
|
case off
|
||||||
|
|
||||||
|
inc outPtr
|
||||||
|
inc outPtr
|
||||||
|
lda [outPtr]
|
||||||
|
clc
|
||||||
|
adc len
|
||||||
|
sta [outPtr] ; adjust GS/OS string length
|
||||||
|
return 4:outPtr
|
||||||
|
|
||||||
|
atSign dc c'@',i1'0'
|
||||||
|
rvbl dc i2'3'
|
||||||
|
dc a4'in'
|
||||||
|
outPtr1 dc a4'0'
|
||||||
|
dc i2'0' ; value of 'Export' flag
|
||||||
|
|
||||||
|
in dosin 'HOME'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
DoLogin START
|
||||||
|
|
||||||
|
ph4 #gshrcName
|
||||||
|
jsl AppendHome
|
||||||
|
phx ; saved pointer for later
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
inc a
|
||||||
|
inc a ; adjust to the C string
|
||||||
|
pha
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
pea 0
|
||||||
|
jsl shellexec
|
||||||
|
|
||||||
|
pla
|
||||||
|
plx
|
||||||
|
jsl DisposeHome
|
||||||
|
rts
|
||||||
|
|
||||||
|
gshrcName dc c'/gshrc',h'00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; GLOBAL data
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
global DATA
|
||||||
|
|
||||||
|
ID ds 2
|
||||||
|
GSOSDP ds 2
|
||||||
|
cmdloc ds 2
|
||||||
|
cmdlen ds 2
|
||||||
|
cmdline ds cmdbuflen
|
||||||
|
buffer ds 256
|
||||||
|
wordlen ds 2
|
||||||
|
wordpbuf ds 1
|
||||||
|
wordbuf ds 256
|
||||||
|
nummatch ds 2
|
||||||
|
matchbuf ds 512*4
|
||||||
|
cmdcontext ds 2
|
||||||
|
cmddp ds 2
|
||||||
|
gshtty ds 2
|
||||||
|
gshpid ds 2
|
||||||
|
exitamundo dc i'0' ;!=0 if exit
|
||||||
|
signalled dc i'0'
|
||||||
|
|
||||||
|
FastFlag dc i'0'
|
||||||
|
CmdFlag dc i'0'
|
||||||
|
CmdArgV ds 4
|
||||||
|
CmdArgC ds 2
|
||||||
|
ExecFlag dc i'0'
|
||||||
|
ExecCmd ds 4
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; SIGINT handler when typed at command-line
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
signal2 START
|
||||||
|
|
||||||
|
using global
|
||||||
|
|
||||||
|
subroutine (4:fubar),0
|
||||||
|
WriteCString #msg
|
||||||
|
inc signalled
|
||||||
|
; ld2 $80,$E0C000
|
||||||
|
return
|
||||||
|
|
||||||
|
msg dc c'^C',h'0d0a00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; SIGTSTP handler when typed at command-line
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
signal18 START
|
||||||
|
|
||||||
|
using global
|
||||||
|
|
||||||
|
subroutine (4:fubar),0
|
||||||
|
WriteCString #msg
|
||||||
|
inc signalled
|
||||||
|
; ld2 $80,$E0C000
|
||||||
|
return
|
||||||
|
|
||||||
|
msg dc c'^Z',h'0d0a00'
|
||||||
|
|
||||||
|
END
|
744
bin/gsh/shellutil.asm
Normal file
744
bin/gsh/shellutil.asm
Normal file
|
@ -0,0 +1,744 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* SHELLUTIL.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Utility functions used by the shell. Mainly string functions.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/shellutil
|
||||||
|
mcopy m/shellutil.mac
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Convert the accumulator to lower case.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
tolower START
|
||||||
|
|
||||||
|
cmp #'A'
|
||||||
|
bcc done
|
||||||
|
cmp #'Z'+1
|
||||||
|
bcs done
|
||||||
|
adc #'a'-'A'
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Convert ':' to '/'
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
toslash START
|
||||||
|
|
||||||
|
cmp #':'
|
||||||
|
bne done
|
||||||
|
lda #'/'
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Convert a c string to lower case
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
lowercstr START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
p equ space+2
|
||||||
|
end equ p+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
short a
|
||||||
|
|
||||||
|
ldy #-1
|
||||||
|
loop iny
|
||||||
|
lda [p],y
|
||||||
|
beq done
|
||||||
|
cmp #'A'
|
||||||
|
bcc loop
|
||||||
|
cmp #'Z'+1
|
||||||
|
bcs loop
|
||||||
|
adc #'a'-'A'
|
||||||
|
sta [p],y
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done rep #$21
|
||||||
|
longa on
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Get the length of a c string.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
cstrlen START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
p equ space+2
|
||||||
|
end equ p+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
short a
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
loop lda [p],y
|
||||||
|
beq done
|
||||||
|
iny
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done rep #$21
|
||||||
|
longa on
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Copy one string to another. Assumes an alloccstr has been performed on
|
||||||
|
; destination.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
copycstr START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
q equ space+2
|
||||||
|
p equ q+4
|
||||||
|
end equ p+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
short a
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
loop lda [p],y
|
||||||
|
beq done
|
||||||
|
sta [q],y
|
||||||
|
iny
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done sta [q],y
|
||||||
|
|
||||||
|
rep #$21
|
||||||
|
longa on
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Converts a pascal string to a c string. This allocates memory for the
|
||||||
|
; new c string.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
p2cstr START
|
||||||
|
|
||||||
|
cstr equ 1
|
||||||
|
space equ cstr+4
|
||||||
|
p equ space+2
|
||||||
|
end equ p+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda [p]
|
||||||
|
and #$FF
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta cstr
|
||||||
|
stx cstr+2
|
||||||
|
lda [p]
|
||||||
|
inc p
|
||||||
|
and #$FF
|
||||||
|
tax
|
||||||
|
|
||||||
|
short a
|
||||||
|
ldy #0
|
||||||
|
cpx #0
|
||||||
|
beq done
|
||||||
|
loop lda [p],y
|
||||||
|
sta [cstr],y
|
||||||
|
iny
|
||||||
|
dex
|
||||||
|
bne loop
|
||||||
|
|
||||||
|
done lda #0
|
||||||
|
sta [cstr],y
|
||||||
|
|
||||||
|
ldx cstr+2
|
||||||
|
ldy cstr
|
||||||
|
|
||||||
|
rep #$21
|
||||||
|
longa on
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Converts a c string to a pascal string. Does not allocate memory.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
c2pstr START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
p equ space+2
|
||||||
|
cstr equ p+4
|
||||||
|
end equ cstr+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
short a
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
loop lda [cstr],y
|
||||||
|
beq endstr
|
||||||
|
iny
|
||||||
|
sta [p],y
|
||||||
|
bra loop
|
||||||
|
endstr tya
|
||||||
|
sta [p]
|
||||||
|
|
||||||
|
rep #$21
|
||||||
|
longa on
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Converts a c string to a pascal string. Allocates memory for p string.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
c2pstr2 START
|
||||||
|
|
||||||
|
p equ 1
|
||||||
|
space equ p+4
|
||||||
|
cstr equ space+2
|
||||||
|
end equ cstr+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
pei (cstr+2)
|
||||||
|
pei (cstr)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta p
|
||||||
|
stx p+2
|
||||||
|
|
||||||
|
short a
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
loop lda [cstr],y
|
||||||
|
beq endstr
|
||||||
|
iny
|
||||||
|
sta [p],y
|
||||||
|
bra loop
|
||||||
|
endstr tya
|
||||||
|
sta [p]
|
||||||
|
|
||||||
|
ldx p+2
|
||||||
|
ldy p
|
||||||
|
|
||||||
|
rep #$21
|
||||||
|
longa on
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Compare two c strings. Return 0 if equal, -1 if less than, +1 greater
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
cmpcstr START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
q equ space+2
|
||||||
|
p equ q+4
|
||||||
|
end equ p+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
short a
|
||||||
|
|
||||||
|
ldx #0
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
strloop lda [p],y
|
||||||
|
beq strchk
|
||||||
|
cmp [q],y
|
||||||
|
bne notequal
|
||||||
|
iny
|
||||||
|
bra strloop
|
||||||
|
|
||||||
|
strchk lda [q],y
|
||||||
|
beq done
|
||||||
|
|
||||||
|
lessthan dex
|
||||||
|
bra done
|
||||||
|
|
||||||
|
notequal bcc lessthan
|
||||||
|
inx
|
||||||
|
|
||||||
|
done rep #$21
|
||||||
|
longa on
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
txa
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Convert a c string to a GS/OS string (don't forget to dispose when done)
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
c2gsstr START
|
||||||
|
|
||||||
|
len equ 1
|
||||||
|
gstr equ len+2
|
||||||
|
space equ gstr+4
|
||||||
|
cstr equ space+2
|
||||||
|
end equ cstr+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
pei (cstr+2)
|
||||||
|
pei (cstr)
|
||||||
|
jsr cstrlen
|
||||||
|
sta len
|
||||||
|
adc #3
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta gstr
|
||||||
|
stx gstr+2
|
||||||
|
inc a
|
||||||
|
inc a
|
||||||
|
pei (cstr+2)
|
||||||
|
pei (cstr)
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr copycstr
|
||||||
|
lda len
|
||||||
|
sta [gstr]
|
||||||
|
|
||||||
|
ldx gstr+2
|
||||||
|
ldy gstr
|
||||||
|
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=========================================================================
|
||||||
|
;
|
||||||
|
; Takes two strings, concats into a newly created string.
|
||||||
|
;
|
||||||
|
;=========================================================================
|
||||||
|
|
||||||
|
catcstr START
|
||||||
|
|
||||||
|
new equ 1
|
||||||
|
space equ new+4
|
||||||
|
q equ space+2
|
||||||
|
p equ q+4
|
||||||
|
end equ p+4
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
pei (p+2)
|
||||||
|
pei (p)
|
||||||
|
jsr cstrlen
|
||||||
|
pha
|
||||||
|
pei (q+2)
|
||||||
|
pei (q)
|
||||||
|
jsr cstrlen
|
||||||
|
adc 1,s
|
||||||
|
inc a
|
||||||
|
inc a
|
||||||
|
plx
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta new
|
||||||
|
stx new+2
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
copy1 lda [p],y
|
||||||
|
and #$FF
|
||||||
|
beq copy2
|
||||||
|
sta [new],y
|
||||||
|
iny
|
||||||
|
bra copy1
|
||||||
|
copy2 lda [q]
|
||||||
|
and #$FF
|
||||||
|
sta [new],y
|
||||||
|
beq done
|
||||||
|
iny
|
||||||
|
inc q
|
||||||
|
bra copy2
|
||||||
|
|
||||||
|
done ldx new+2
|
||||||
|
ldy new
|
||||||
|
lda space
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-3
|
||||||
|
tcs
|
||||||
|
|
||||||
|
tya
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=====================================================================
|
||||||
|
;
|
||||||
|
; call ~DISPOSE if pointer is not NULL
|
||||||
|
;
|
||||||
|
;=====================================================================
|
||||||
|
|
||||||
|
nullfree START
|
||||||
|
|
||||||
|
lda 4,s
|
||||||
|
ora 6,s
|
||||||
|
bne ok
|
||||||
|
lda 2,s
|
||||||
|
sta 6,s
|
||||||
|
lda 1,s
|
||||||
|
sta 5,s
|
||||||
|
plx
|
||||||
|
plx
|
||||||
|
rtl
|
||||||
|
|
||||||
|
ok jml ~DISPOSE
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;=====================================================================
|
||||||
|
;
|
||||||
|
; Print a carriage return and a newline, unless "newline" shell var
|
||||||
|
; is set.
|
||||||
|
;
|
||||||
|
;=====================================================================
|
||||||
|
|
||||||
|
newlineX START
|
||||||
|
|
||||||
|
using vardata
|
||||||
|
|
||||||
|
lda varnewline
|
||||||
|
beq newline
|
||||||
|
rts
|
||||||
|
|
||||||
|
;=====================================================================
|
||||||
|
;
|
||||||
|
; Print a carriage return and a newline
|
||||||
|
;
|
||||||
|
;=====================================================================
|
||||||
|
|
||||||
|
newline ENTRY
|
||||||
|
|
||||||
|
lda #13
|
||||||
|
jmp putchar
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Quick little routine for reading variables and converting to
|
||||||
|
* null terminated strings. We could probably just link the Orca/C
|
||||||
|
* library getenv(), but lets stay Orca-free, after all, that's why this
|
||||||
|
* is written in assembly! :)
|
||||||
|
*
|
||||||
|
* Borrowed from termcap
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
getenv START
|
||||||
|
|
||||||
|
newval equ 1
|
||||||
|
len equ newval+4
|
||||||
|
namebuf equ len+2
|
||||||
|
retval equ namebuf+4
|
||||||
|
space equ retval+4
|
||||||
|
var equ space+3
|
||||||
|
end equ var+4
|
||||||
|
|
||||||
|
; subroutine (4:var),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
stz retval
|
||||||
|
stz retval+2
|
||||||
|
|
||||||
|
lock mutex
|
||||||
|
;
|
||||||
|
; get length of variable name
|
||||||
|
;
|
||||||
|
short a
|
||||||
|
ldy #0
|
||||||
|
findlen lda [var],y
|
||||||
|
beq gotlen
|
||||||
|
iny
|
||||||
|
bra findlen
|
||||||
|
gotlen long a
|
||||||
|
sty len
|
||||||
|
;
|
||||||
|
; 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
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta retval
|
||||||
|
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
|
||||||
|
|
||||||
|
exit unlock mutex
|
||||||
|
ldy retval
|
||||||
|
ldx retval+2
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
lda space
|
||||||
|
sta end-3
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
tya
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
varparm ds 8
|
||||||
|
mutex key
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
rmemcpy START
|
||||||
|
subroutine (2:num,4:src,4:dest),0
|
||||||
|
|
||||||
|
ldy num
|
||||||
|
beq done
|
||||||
|
tya
|
||||||
|
dey
|
||||||
|
bit #1
|
||||||
|
bne odd
|
||||||
|
dey
|
||||||
|
bra lp1
|
||||||
|
odd short m
|
||||||
|
lda [src],y
|
||||||
|
sta [dest],y
|
||||||
|
long m
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
bmi done
|
||||||
|
lp1 lda [src],y
|
||||||
|
sta [dest],y
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
bpl lp1
|
||||||
|
done return
|
||||||
|
END
|
920
bin/gsh/shellvar.asm
Normal file
920
bin/gsh/shellvar.asm
Normal file
|
@ -0,0 +1,920 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
* Derek Taubert
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* SHELLVAR.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Routines for handling variables in the shell
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/shellvar
|
||||||
|
mcopy m/shellvar.mac
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* SET: builtin command
|
||||||
|
* syntax: set - displays all variables
|
||||||
|
* set ... [var] - displays the value of var
|
||||||
|
* set [var=value]... - sets var to value
|
||||||
|
* set [var value]... - sets var to value
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
set START
|
||||||
|
|
||||||
|
arg equ 1
|
||||||
|
valbuf equ arg+4
|
||||||
|
varbuf equ valbuf+4
|
||||||
|
space equ varbuf+4
|
||||||
|
argc equ space+3
|
||||||
|
argv equ argc+2
|
||||||
|
end equ argv+4
|
||||||
|
|
||||||
|
; subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
beq showvars
|
||||||
|
;
|
||||||
|
; If one parameter check for a '-' starting the parm
|
||||||
|
;
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
sta arg
|
||||||
|
iny2
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
lda [arg]
|
||||||
|
and #$FF
|
||||||
|
cmp #'-'
|
||||||
|
beq showusage
|
||||||
|
jmp skipvar
|
||||||
|
|
||||||
|
showusage ldx #^Usage
|
||||||
|
lda #Usage
|
||||||
|
jsr errputs
|
||||||
|
jmp exit
|
||||||
|
;
|
||||||
|
; show variables
|
||||||
|
;
|
||||||
|
showvars anop
|
||||||
|
|
||||||
|
jsl alloc256
|
||||||
|
sta varbuf
|
||||||
|
stx varbuf+2
|
||||||
|
ora varbuf+2
|
||||||
|
beq svwhoops
|
||||||
|
jsl alloc256
|
||||||
|
sta valbuf
|
||||||
|
stx valbuf+2
|
||||||
|
ora valbuf+2
|
||||||
|
bne startshow
|
||||||
|
ldx varbuf+2
|
||||||
|
lda varbuf
|
||||||
|
jsl free256
|
||||||
|
svwhoops ld2 $201,Err
|
||||||
|
Error Err
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
startshow lda #254
|
||||||
|
sta [valbuf]
|
||||||
|
sta [varbuf]
|
||||||
|
lda setmutex
|
||||||
|
beq wait0
|
||||||
|
cop $7F
|
||||||
|
bra startshow
|
||||||
|
wait0 inc setmutex
|
||||||
|
mv4 varbuf,idxParm+2
|
||||||
|
mv4 valbuf,idxParm+6
|
||||||
|
ld2 1,idxParm+10
|
||||||
|
showloop GSOS $0148,idxParm ;ReadIndexed 2.0
|
||||||
|
ldy #2
|
||||||
|
lda [varbuf],y
|
||||||
|
and #$FF
|
||||||
|
beq showdone
|
||||||
|
xba
|
||||||
|
sta [varbuf],y
|
||||||
|
ldy idxParm+12
|
||||||
|
beq noexp
|
||||||
|
xba
|
||||||
|
tax
|
||||||
|
ldy #4
|
||||||
|
short a
|
||||||
|
upper lda [varbuf],y
|
||||||
|
cmp #'a'
|
||||||
|
bcc upperfoo
|
||||||
|
cmp #'z'+1
|
||||||
|
bcs upperfoo
|
||||||
|
sec
|
||||||
|
sbc #'a'-'A'
|
||||||
|
sta [varbuf],y
|
||||||
|
upperfoo iny
|
||||||
|
dex
|
||||||
|
bne upper
|
||||||
|
long a
|
||||||
|
noexp ldx varbuf+2
|
||||||
|
lda varbuf
|
||||||
|
clc
|
||||||
|
adc #3
|
||||||
|
jsr putp
|
||||||
|
ldx #^showeq
|
||||||
|
lda #showeq
|
||||||
|
jsr puts
|
||||||
|
ldy #2
|
||||||
|
lda [valbuf],y
|
||||||
|
xba
|
||||||
|
sta [valbuf],y
|
||||||
|
lda valbuf
|
||||||
|
ldx valbuf+2
|
||||||
|
clc
|
||||||
|
adc #3
|
||||||
|
jsr putp
|
||||||
|
jsr newline
|
||||||
|
inc idxParm+10
|
||||||
|
bra showloop
|
||||||
|
|
||||||
|
showdone dec setmutex
|
||||||
|
ldx varbuf+2
|
||||||
|
lda varbuf
|
||||||
|
jsl free256
|
||||||
|
ldx valbuf+2
|
||||||
|
lda valbuf
|
||||||
|
jsl free256
|
||||||
|
jmp exit
|
||||||
|
;
|
||||||
|
; set variables
|
||||||
|
;
|
||||||
|
setvar lda setmutex
|
||||||
|
beq wait1
|
||||||
|
cop $7F
|
||||||
|
bra setvar
|
||||||
|
wait1 inc setmutex
|
||||||
|
lda argc
|
||||||
|
jeq doneset
|
||||||
|
ldy #2
|
||||||
|
lda [argv]
|
||||||
|
sta arg
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
ldy #0
|
||||||
|
chkeql lda [arg],y
|
||||||
|
and #$FF
|
||||||
|
beq orcastyle
|
||||||
|
cmp #'='
|
||||||
|
jeq unixstyle
|
||||||
|
iny
|
||||||
|
bra chkeql
|
||||||
|
;
|
||||||
|
; Orca style set. Uses two arguments.
|
||||||
|
;
|
||||||
|
orcastyle add2 argv,#4,argv
|
||||||
|
dec argc
|
||||||
|
beq showonevar
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
pea 1
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm
|
||||||
|
stx varParm+2
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
lda [argv]
|
||||||
|
pha
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm+4
|
||||||
|
stx varParm+4+2
|
||||||
|
Set_Variable varParm
|
||||||
|
jsl nullfree
|
||||||
|
jsl nullfree
|
||||||
|
jsl updatevars
|
||||||
|
jmp nextvar
|
||||||
|
|
||||||
|
showonevar jsl alloc256
|
||||||
|
sta valbuf
|
||||||
|
sta varParm+4
|
||||||
|
stx valbuf+2
|
||||||
|
stx varParm+4+2
|
||||||
|
ora varParm+4+2
|
||||||
|
jeq nextvar
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm
|
||||||
|
stx varParm+2
|
||||||
|
Read_Variable varParm
|
||||||
|
lda [valbuf]
|
||||||
|
and #$FF
|
||||||
|
beq notdef
|
||||||
|
lda varParm
|
||||||
|
ldx varParm+2
|
||||||
|
jsr putp
|
||||||
|
lda #showeq
|
||||||
|
ldx #^showeq
|
||||||
|
jsr puts
|
||||||
|
lda varParm+4
|
||||||
|
ldx varParm+6
|
||||||
|
jsr putp
|
||||||
|
jsr newline
|
||||||
|
doneone jsl nullfree
|
||||||
|
lda valbuf
|
||||||
|
ldx valbuf+2
|
||||||
|
jsl free256
|
||||||
|
bra doneset
|
||||||
|
|
||||||
|
notdef ldx #^error2
|
||||||
|
lda #error2
|
||||||
|
jsr errputs
|
||||||
|
bra doneone
|
||||||
|
|
||||||
|
unixstyle cpy #0
|
||||||
|
bne unix0
|
||||||
|
ldx #^error1
|
||||||
|
lda #error1
|
||||||
|
jsr errputs
|
||||||
|
bra doneset
|
||||||
|
unix0 short a
|
||||||
|
lda #0
|
||||||
|
sta [arg],y
|
||||||
|
long a
|
||||||
|
tya
|
||||||
|
sec
|
||||||
|
adc arg
|
||||||
|
pei (arg+2)
|
||||||
|
pha
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm+4
|
||||||
|
stx varParm+4+2
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
pea 1
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm
|
||||||
|
stx varParm+2
|
||||||
|
Set_Variable varParm
|
||||||
|
jsl nullfree
|
||||||
|
jsl updatevars
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
nextvar dec setmutex
|
||||||
|
skipvar add2 argv,#4,argv
|
||||||
|
dec argc
|
||||||
|
jmp setvar
|
||||||
|
|
||||||
|
doneset dec setmutex
|
||||||
|
|
||||||
|
exit lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
varParm ds 4
|
||||||
|
ds 4
|
||||||
|
ds 2
|
||||||
|
|
||||||
|
idxParm dc i2'4'
|
||||||
|
ds 4
|
||||||
|
ds 4
|
||||||
|
ds 2
|
||||||
|
ds 2
|
||||||
|
|
||||||
|
setmutex dc i'0'
|
||||||
|
showeq dc c' = ',h'00'
|
||||||
|
Usage dc c'Usage:',h'0d'
|
||||||
|
dc c' set - displays all variables',h'0d'
|
||||||
|
dc c' set ... [var] - displays the value of var',h'0d'
|
||||||
|
dc c' set [var value]... - sets var to value',h'0d'
|
||||||
|
dc c' set [var=value]... - sets var to value',h'0d'
|
||||||
|
dc h'00'
|
||||||
|
error1 dc c'set: Variable not specified',h'0d00'
|
||||||
|
error2 dc c'set: Variable not defined',h'0d00'
|
||||||
|
|
||||||
|
Err ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* SETENV: builtin command
|
||||||
|
* syntax: setenv - displays all variables
|
||||||
|
* setenv ... [var] - displays the value of var
|
||||||
|
* setenv [var=value]... - sets var to value
|
||||||
|
* setenv [var value]... - sets var to value
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
setenv START
|
||||||
|
|
||||||
|
arg equ 1
|
||||||
|
valbuf equ arg+4
|
||||||
|
varbuf equ valbuf+4
|
||||||
|
space equ varbuf+4
|
||||||
|
argc equ space+3
|
||||||
|
argv equ argc+2
|
||||||
|
end equ argv+4
|
||||||
|
|
||||||
|
; subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
sec
|
||||||
|
sbc #space-1
|
||||||
|
tcs
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
beq showvars
|
||||||
|
;
|
||||||
|
; If one parameter check for a '-' starting the parm
|
||||||
|
;
|
||||||
|
ldy #4
|
||||||
|
lda [argv],y
|
||||||
|
sta arg
|
||||||
|
iny2
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
lda [arg]
|
||||||
|
and #$FF
|
||||||
|
cmp #'-'
|
||||||
|
beq showusage
|
||||||
|
jmp skipvar
|
||||||
|
|
||||||
|
showusage ldx #^Usage
|
||||||
|
lda #Usage
|
||||||
|
jsr errputs
|
||||||
|
jmp exit
|
||||||
|
;
|
||||||
|
; show variables
|
||||||
|
;
|
||||||
|
showvars anop
|
||||||
|
|
||||||
|
jsl alloc256
|
||||||
|
sta varbuf
|
||||||
|
stx varbuf+2
|
||||||
|
ora varbuf+2
|
||||||
|
beq svwhoops
|
||||||
|
jsl alloc256
|
||||||
|
sta valbuf
|
||||||
|
stx valbuf+2
|
||||||
|
ora valbuf+2
|
||||||
|
bne startshow
|
||||||
|
ldx varbuf+2
|
||||||
|
lda varbuf
|
||||||
|
jsl free256
|
||||||
|
svwhoops ld2 $201,Err
|
||||||
|
Error Err
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
startshow lda setmutex
|
||||||
|
beq wait0
|
||||||
|
cop $7F
|
||||||
|
bra startshow
|
||||||
|
wait0 inc setmutex
|
||||||
|
mv4 varbuf,varParm+0
|
||||||
|
mv4 valbuf,varParm+4
|
||||||
|
ld2 1,varParm+8
|
||||||
|
PushVariables 0
|
||||||
|
showloop Read_Indexed varParm
|
||||||
|
lda [varbuf]
|
||||||
|
and #$FF
|
||||||
|
beq showdone
|
||||||
|
tax
|
||||||
|
ldy #1
|
||||||
|
short a
|
||||||
|
upper lda [varbuf],y
|
||||||
|
cmp #'a'
|
||||||
|
bcc upperfoo
|
||||||
|
cmp #'z'+1
|
||||||
|
bcs upperfoo
|
||||||
|
sec
|
||||||
|
sbc #'a'-'A'
|
||||||
|
sta [varbuf],y
|
||||||
|
upperfoo iny
|
||||||
|
dex
|
||||||
|
bne upper
|
||||||
|
long a
|
||||||
|
lda varParm
|
||||||
|
ldx varParm+2
|
||||||
|
jsr putp
|
||||||
|
ldx #^showeq
|
||||||
|
lda #showeq
|
||||||
|
jsr puts
|
||||||
|
lda varParm+4
|
||||||
|
ldx varParm+6
|
||||||
|
jsr putp
|
||||||
|
jsr newline
|
||||||
|
inc varParm+8
|
||||||
|
bra showloop
|
||||||
|
|
||||||
|
showdone PopVariables 0
|
||||||
|
dec setmutex
|
||||||
|
ldx varbuf+2
|
||||||
|
lda varbuf
|
||||||
|
jsl free256
|
||||||
|
ldx valbuf+2
|
||||||
|
lda valbuf
|
||||||
|
jsl free256
|
||||||
|
jmp exit
|
||||||
|
;
|
||||||
|
; set variables
|
||||||
|
;
|
||||||
|
setvar lda setmutex
|
||||||
|
beq wait1
|
||||||
|
cop $7F
|
||||||
|
bra setvar
|
||||||
|
wait1 inc setmutex
|
||||||
|
lda argc
|
||||||
|
jeq doneset
|
||||||
|
ldy #2
|
||||||
|
lda [argv]
|
||||||
|
sta arg
|
||||||
|
lda [argv],y
|
||||||
|
sta arg+2
|
||||||
|
ldy #0
|
||||||
|
chkeql lda [arg],y
|
||||||
|
and #$FF
|
||||||
|
beq orcastyle
|
||||||
|
cmp #'='
|
||||||
|
jeq unixstyle
|
||||||
|
iny
|
||||||
|
bra chkeql
|
||||||
|
;
|
||||||
|
; Orca style set. Uses two arguments.
|
||||||
|
;
|
||||||
|
orcastyle add2 argv,#4,argv
|
||||||
|
dec argc
|
||||||
|
beq showonevar
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
pea 1
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm
|
||||||
|
stx varParm+2
|
||||||
|
sta exportparm
|
||||||
|
stx exportparm+2
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
lda [argv]
|
||||||
|
pha
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm+4
|
||||||
|
stx varParm+4+2
|
||||||
|
Set_Variable varParm
|
||||||
|
Export exportparm
|
||||||
|
jsl nullfree
|
||||||
|
jsl nullfree
|
||||||
|
jsl updatevars
|
||||||
|
jmp nextvar
|
||||||
|
|
||||||
|
showonevar jsl alloc256
|
||||||
|
sta valbuf
|
||||||
|
sta varParm+4
|
||||||
|
stx valbuf+2
|
||||||
|
stx varParm+4+2
|
||||||
|
ora varParm+4+2
|
||||||
|
jeq nextvar
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm
|
||||||
|
stx varParm+2
|
||||||
|
PushVariables 0
|
||||||
|
Read_Variable varParm
|
||||||
|
PopVariables 0
|
||||||
|
lda [valbuf]
|
||||||
|
and #$FF
|
||||||
|
beq notthere
|
||||||
|
lda varParm
|
||||||
|
ldx varParm+2
|
||||||
|
jsr putp
|
||||||
|
lda #showeq
|
||||||
|
ldx #^showeq
|
||||||
|
jsr puts
|
||||||
|
lda varParm+4
|
||||||
|
ldx varParm+6
|
||||||
|
jsr putp
|
||||||
|
jsr newline
|
||||||
|
doneone jsl nullfree
|
||||||
|
ldx valbuf+2
|
||||||
|
lda valbuf
|
||||||
|
jsl free256
|
||||||
|
jmp doneset
|
||||||
|
|
||||||
|
notthere ldx #^error2
|
||||||
|
lda #error2
|
||||||
|
jsr errputs
|
||||||
|
bra doneone
|
||||||
|
|
||||||
|
unixstyle cpy #0
|
||||||
|
bne unix0
|
||||||
|
ldx #^error1
|
||||||
|
lda #error1
|
||||||
|
jsr errputs
|
||||||
|
bra doneset
|
||||||
|
unix0 short a
|
||||||
|
lda #0
|
||||||
|
sta [arg],y
|
||||||
|
long a
|
||||||
|
clc ;use sec and kill the iny :)
|
||||||
|
iny
|
||||||
|
tya
|
||||||
|
adc arg
|
||||||
|
pei (arg+2)
|
||||||
|
pha
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm+4
|
||||||
|
stx varParm+4+2
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
pea 1
|
||||||
|
pei (arg+2)
|
||||||
|
pei (arg)
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta varParm
|
||||||
|
stx varParm+2
|
||||||
|
sta exportparm
|
||||||
|
stx exportparm+2
|
||||||
|
Set_Variable varParm
|
||||||
|
Export exportparm
|
||||||
|
jsl nullfree
|
||||||
|
jsl updatevars
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
nextvar dec setmutex
|
||||||
|
skipvar add2 argv,#4,argv
|
||||||
|
dec argc
|
||||||
|
jmp setvar
|
||||||
|
|
||||||
|
doneset dec setmutex
|
||||||
|
|
||||||
|
exit lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
varParm ds 4
|
||||||
|
ds 4
|
||||||
|
ds 2
|
||||||
|
|
||||||
|
exportparm ds 4
|
||||||
|
dc i'1'
|
||||||
|
|
||||||
|
setmutex dc i'0'
|
||||||
|
showeq dc c' = ',h'00'
|
||||||
|
Usage dc c'Usage:',h'0d'
|
||||||
|
dc c' setenv - displays all variables',h'0d'
|
||||||
|
dc c' setenv ... [var] - displays the value of var',h'0d'
|
||||||
|
dc c' setenv [var value]... - sets var to value',h'0d'
|
||||||
|
dc c' setenv [var=value]... - sets var to value',h'0d'
|
||||||
|
dc h'00'
|
||||||
|
error1 dc c'setenv: Variable not specified',h'0d00'
|
||||||
|
error2 dc c'setenv: Variable not defined',h'0d00'
|
||||||
|
|
||||||
|
Err ds 2
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* EXPORT: builtin command
|
||||||
|
* syntax: export [var] ...
|
||||||
|
*
|
||||||
|
* exports each variable given in the list
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
export START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
argc equ space+3
|
||||||
|
argv equ argc+2
|
||||||
|
end equ argv+4
|
||||||
|
|
||||||
|
; subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
bne loop
|
||||||
|
ldx #^Usage
|
||||||
|
lda #Usage
|
||||||
|
jsr errputs
|
||||||
|
bra done
|
||||||
|
|
||||||
|
loop add2 argv,#4,argv
|
||||||
|
dec argc
|
||||||
|
beq done
|
||||||
|
|
||||||
|
wait lda expmutex
|
||||||
|
beq wait0
|
||||||
|
cop $7F
|
||||||
|
bra wait
|
||||||
|
wait0 inc expmutex
|
||||||
|
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
pha
|
||||||
|
lda [argv]
|
||||||
|
pha
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta exportparm
|
||||||
|
stx exportparm+2
|
||||||
|
Export exportparm
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
dec expmutex
|
||||||
|
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
expmutex dc i'0'
|
||||||
|
|
||||||
|
exportparm ds 4
|
||||||
|
dc i'1'
|
||||||
|
|
||||||
|
Usage dc c'Usage: export var ...',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* UNSET: builtin command
|
||||||
|
* syntax: unset [var] ...
|
||||||
|
*
|
||||||
|
* unsets each variable given in the list
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
unset START
|
||||||
|
|
||||||
|
space equ 1
|
||||||
|
argc equ space+3
|
||||||
|
argv equ argc+2
|
||||||
|
end equ argv+4
|
||||||
|
|
||||||
|
; subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
tsc
|
||||||
|
phd
|
||||||
|
tcd
|
||||||
|
|
||||||
|
lda argc
|
||||||
|
dec a
|
||||||
|
bne loop
|
||||||
|
|
||||||
|
ldx #^Usage
|
||||||
|
lda #Usage
|
||||||
|
jsr errputs
|
||||||
|
bra done
|
||||||
|
|
||||||
|
loop add2 argv,#4,argv
|
||||||
|
dec argc
|
||||||
|
beq done
|
||||||
|
|
||||||
|
wait lda unsmutex
|
||||||
|
beq wait0
|
||||||
|
cop $7F
|
||||||
|
bra wait
|
||||||
|
wait0 inc unsmutex
|
||||||
|
|
||||||
|
ldy #2
|
||||||
|
lda [argv],y
|
||||||
|
tax
|
||||||
|
lda [argv]
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
pea 0
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr c2pstr2
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
sta unsetparm
|
||||||
|
stx unsetparm+2
|
||||||
|
UnsetVariable unsetparm
|
||||||
|
jsl nullfree
|
||||||
|
jsl updatevars
|
||||||
|
|
||||||
|
dec unsmutex
|
||||||
|
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done lda space
|
||||||
|
sta end-3
|
||||||
|
lda space+1
|
||||||
|
sta end-2
|
||||||
|
pld
|
||||||
|
tsc
|
||||||
|
clc
|
||||||
|
adc #end-4
|
||||||
|
tcs
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
unsmutex dc i'0'
|
||||||
|
|
||||||
|
unsetparm ds 4
|
||||||
|
|
||||||
|
Usage dc c'Usage: unset var ...',h'0d00'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;====================================================================
|
||||||
|
;
|
||||||
|
; update shell variable flags
|
||||||
|
;
|
||||||
|
; CHANGE TO JUST DO A READVARIABLES ON THE PASSED VAR
|
||||||
|
;
|
||||||
|
;====================================================================
|
||||||
|
|
||||||
|
updatevars START
|
||||||
|
|
||||||
|
using vardata
|
||||||
|
|
||||||
|
space equ 0
|
||||||
|
|
||||||
|
subroutine (4:var,2:flag),space ;flag 1: set, 0: unset
|
||||||
|
|
||||||
|
pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #varechoname
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up2
|
||||||
|
lda flag
|
||||||
|
sta varecho
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up2 pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #direxecname
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up3
|
||||||
|
lda flag
|
||||||
|
sta vardirexec
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up3 pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #newlinename
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up4
|
||||||
|
lda flag
|
||||||
|
sta varnewline
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up4 pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #noglobname
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up5
|
||||||
|
lda flag
|
||||||
|
sta varnoglob
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up5 pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #nobeepname
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up6
|
||||||
|
lda flag
|
||||||
|
sta varnobeep
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up6 pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #pushdsilname
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up7
|
||||||
|
lda flag
|
||||||
|
sta varpushdsil
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up7 pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #termname
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up8
|
||||||
|
jsr readterm
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up8 pei (var+2)
|
||||||
|
pei (var)
|
||||||
|
ph4 #ignorename
|
||||||
|
jsr cmpcstr
|
||||||
|
bne up9
|
||||||
|
lda flag
|
||||||
|
sta varignore
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
up9 anop
|
||||||
|
|
||||||
|
done return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
;===================================================================
|
||||||
|
;
|
||||||
|
; variable settings
|
||||||
|
;
|
||||||
|
;===================================================================
|
||||||
|
|
||||||
|
vardata DATA
|
||||||
|
|
||||||
|
varechoname dc c'echo',h'00'
|
||||||
|
direxecname dc c'nodirexec',h'00'
|
||||||
|
newlinename dc c'nonewline',h'00'
|
||||||
|
noglobname dc c'noglob',h'00'
|
||||||
|
nobeepname dc c'nobeep',h'00'
|
||||||
|
pushdsilname dc c'pushdsilent',h'00'
|
||||||
|
termname dc c'term',h'00'
|
||||||
|
ignorename dc c'ignoreeof',h'00'
|
||||||
|
|
||||||
|
varecho dc i'0'
|
||||||
|
vardirexec dc i'0'
|
||||||
|
varnewline dc i'0'
|
||||||
|
varnoglob dc i'0'
|
||||||
|
varnobeep dc i'0'
|
||||||
|
varpushdsil dc i'0'
|
||||||
|
varignore dc i'0'
|
||||||
|
|
||||||
|
END
|
441
bin/gsh/stdio.asm
Normal file
441
bin/gsh/stdio.asm
Normal file
|
@ -0,0 +1,441 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* STDIO.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* This is the custom stdio for the shell
|
||||||
|
*
|
||||||
|
* stdout buffer size: 512 bytes
|
||||||
|
* stderr buffer size: 256 bytes
|
||||||
|
* stdin buffer size: 128 bytes
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/stdio
|
||||||
|
mcopy m/stdio.mac
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* putchar - output a character to standard out
|
||||||
|
* On entry: A = character
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
putchar START
|
||||||
|
|
||||||
|
using stdout
|
||||||
|
|
||||||
|
tay ;lock destroys Acc
|
||||||
|
lock mutex
|
||||||
|
tya
|
||||||
|
and #$FF
|
||||||
|
ldx index
|
||||||
|
sta stream,x ;we're still in long mode, note extra
|
||||||
|
inx ; length of stream by one :)
|
||||||
|
cmp #13
|
||||||
|
beq _flush
|
||||||
|
cpx #512
|
||||||
|
bcc done
|
||||||
|
_flush stx index
|
||||||
|
Write WriteParm
|
||||||
|
ldx #0
|
||||||
|
done stx index
|
||||||
|
unlock mutex
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* puts - output a c string to standard out
|
||||||
|
* On entry: A/X = pointer to string
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
puts START
|
||||||
|
|
||||||
|
using stdout
|
||||||
|
|
||||||
|
tay ;lock destroys Acc
|
||||||
|
lock mutex
|
||||||
|
sty getchar+1
|
||||||
|
txa
|
||||||
|
|
||||||
|
short a
|
||||||
|
sta getchar+3
|
||||||
|
ora getchar+2
|
||||||
|
ora getchar+1
|
||||||
|
beq exit
|
||||||
|
|
||||||
|
ldy index
|
||||||
|
ldx #0
|
||||||
|
|
||||||
|
getchar lda >$FFFFFF,x
|
||||||
|
beq done
|
||||||
|
sta stream,y
|
||||||
|
iny
|
||||||
|
inx
|
||||||
|
cmp #13
|
||||||
|
beq _flush
|
||||||
|
cpy #512
|
||||||
|
bcc getchar
|
||||||
|
|
||||||
|
_flush sty index
|
||||||
|
phx
|
||||||
|
long a
|
||||||
|
Write WriteParm
|
||||||
|
Flush flushparm
|
||||||
|
short a
|
||||||
|
plx
|
||||||
|
ldy #0
|
||||||
|
bra getchar
|
||||||
|
|
||||||
|
done sty index
|
||||||
|
exit long a
|
||||||
|
unlock mutex
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* putp - output a p string to standard out
|
||||||
|
* On entry: A/X = pointer to string
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
putp START
|
||||||
|
|
||||||
|
using stdout
|
||||||
|
|
||||||
|
tay ;lock destroys Acc
|
||||||
|
lock mutex
|
||||||
|
sty getchar+1
|
||||||
|
sty cmpchar+1
|
||||||
|
txa
|
||||||
|
|
||||||
|
short a
|
||||||
|
sta getchar+3
|
||||||
|
sta cmpchar+3
|
||||||
|
|
||||||
|
ldy index
|
||||||
|
ldx #1
|
||||||
|
bra next
|
||||||
|
|
||||||
|
getchar lda >$FFFFFF,x
|
||||||
|
sta stream,y
|
||||||
|
iny
|
||||||
|
inx
|
||||||
|
cmp #13
|
||||||
|
beq _flush
|
||||||
|
next txa
|
||||||
|
cmpchar cmp >$FFFFFF
|
||||||
|
beq check2
|
||||||
|
bcs done
|
||||||
|
check2 cpy #512
|
||||||
|
bcc getchar
|
||||||
|
|
||||||
|
_flush sty index
|
||||||
|
phx
|
||||||
|
long a
|
||||||
|
Write WriteParm
|
||||||
|
Flush flushparm
|
||||||
|
short a
|
||||||
|
plx
|
||||||
|
ldy #0
|
||||||
|
bra next
|
||||||
|
|
||||||
|
done sty index
|
||||||
|
long a
|
||||||
|
unlock mutex
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* flush - flush stdout
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
flush START
|
||||||
|
|
||||||
|
using stdout
|
||||||
|
|
||||||
|
lock mutex
|
||||||
|
lda index
|
||||||
|
beq skip
|
||||||
|
Write WriteParm
|
||||||
|
Flush flushparm
|
||||||
|
stz index
|
||||||
|
skip unlock mutex
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* data for standard out
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
stdout PRIVDATA
|
||||||
|
|
||||||
|
mutex key
|
||||||
|
|
||||||
|
WriteParm dc i2'4'
|
||||||
|
dc i2'2' ;2 is standard out
|
||||||
|
dc i4'stream'
|
||||||
|
index dc i4'0'
|
||||||
|
dc i4'0'
|
||||||
|
|
||||||
|
flushparm dc i2'1'
|
||||||
|
dc i2'2'
|
||||||
|
|
||||||
|
stream ds 512+1
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* errputchar - output a character to standard error
|
||||||
|
* On entry: A = character
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
errputchar START
|
||||||
|
|
||||||
|
using stderr
|
||||||
|
|
||||||
|
tay ;lock destroys Acc
|
||||||
|
lock errmutex
|
||||||
|
tya
|
||||||
|
and #$FF
|
||||||
|
ldx errindex
|
||||||
|
sta errstream,x
|
||||||
|
inx
|
||||||
|
cmp #13
|
||||||
|
beq _flush
|
||||||
|
cpx #256
|
||||||
|
bcc done
|
||||||
|
_flush stx errindex
|
||||||
|
Write errWriteParm
|
||||||
|
ldx #0
|
||||||
|
done stx errindex
|
||||||
|
unlock errmutex
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* errputs - output a c string to standard error
|
||||||
|
* On entry: A/X = pointer to string
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
errputs START
|
||||||
|
|
||||||
|
using stderr
|
||||||
|
|
||||||
|
tay ;lock destroys Acc
|
||||||
|
lock errmutex
|
||||||
|
sty getchar+1
|
||||||
|
txa
|
||||||
|
|
||||||
|
short a
|
||||||
|
sta getchar+3
|
||||||
|
|
||||||
|
ldy errindex
|
||||||
|
ldx #0
|
||||||
|
|
||||||
|
getchar lda >$FFFFFF,x
|
||||||
|
beq done
|
||||||
|
sta errstream,y
|
||||||
|
iny
|
||||||
|
inx
|
||||||
|
cmp #13
|
||||||
|
beq _flush
|
||||||
|
cpy #256
|
||||||
|
bcc getchar
|
||||||
|
|
||||||
|
_flush sty errindex
|
||||||
|
phx
|
||||||
|
long a
|
||||||
|
Write errWriteParm
|
||||||
|
short a
|
||||||
|
plx
|
||||||
|
ldy #0
|
||||||
|
bra getchar
|
||||||
|
|
||||||
|
done sty errindex
|
||||||
|
long a
|
||||||
|
unlock errmutex
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* errputp - output a p string to standard error
|
||||||
|
* On entry: A/X = pointer to string
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
errputp START
|
||||||
|
|
||||||
|
using stderr
|
||||||
|
|
||||||
|
tay ;lock destroys Acc
|
||||||
|
lock errmutex
|
||||||
|
sty getchar+1
|
||||||
|
sty cmpchar+1
|
||||||
|
txa
|
||||||
|
|
||||||
|
short a
|
||||||
|
sta getchar+3
|
||||||
|
sta cmpchar+3
|
||||||
|
|
||||||
|
ldy errindex
|
||||||
|
ldx #1
|
||||||
|
|
||||||
|
getchar lda >$FFFFFF,x
|
||||||
|
sta errstream,y
|
||||||
|
iny
|
||||||
|
inx
|
||||||
|
cmp #13
|
||||||
|
beq _flush
|
||||||
|
next txa
|
||||||
|
cmpchar cmp >$FFFFFF
|
||||||
|
beq check2
|
||||||
|
bcs done
|
||||||
|
check2 cpy #256
|
||||||
|
bcc getchar
|
||||||
|
|
||||||
|
_flush sty errindex
|
||||||
|
phx
|
||||||
|
long a
|
||||||
|
Write errWriteParm
|
||||||
|
short a
|
||||||
|
plx
|
||||||
|
ldy #0
|
||||||
|
bra next
|
||||||
|
|
||||||
|
done sty errindex
|
||||||
|
long a
|
||||||
|
unlock errmutex
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* errflush - flush stderr
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
errflush START
|
||||||
|
|
||||||
|
using stderr
|
||||||
|
|
||||||
|
lock errmutex
|
||||||
|
Write errWriteParm
|
||||||
|
stz errindex
|
||||||
|
unlock errmutex
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* data for standard error
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
stderr PRIVDATA
|
||||||
|
|
||||||
|
errmutex key
|
||||||
|
|
||||||
|
errWriteParm dc i2'4'
|
||||||
|
dc i2'3' ;3 is standard err
|
||||||
|
dc i4'errstream'
|
||||||
|
errindex dc i4'0'
|
||||||
|
dc i4'0'
|
||||||
|
|
||||||
|
errstream ds 256+1 ;not as large as stdout
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* getchar - read a single character from standard input
|
||||||
|
* on exit: a = character, -1 if EOF
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
getchar START
|
||||||
|
|
||||||
|
using stdin
|
||||||
|
|
||||||
|
lock inmutex
|
||||||
|
|
||||||
|
lda insize ;any characters in stream?
|
||||||
|
bne grabchar ;yup
|
||||||
|
|
||||||
|
readloop Read inReadParm
|
||||||
|
bcc okread
|
||||||
|
ldy #-1 ;return EOF on ALL errors
|
||||||
|
jmp done2
|
||||||
|
|
||||||
|
okread stz inindex
|
||||||
|
lda insize
|
||||||
|
bne grabchar
|
||||||
|
|
||||||
|
cop $7F ;no characters ready, so wait
|
||||||
|
bra readloop
|
||||||
|
|
||||||
|
grabchar ldx inindex
|
||||||
|
lda instream,x
|
||||||
|
and #$7F
|
||||||
|
inc inindex
|
||||||
|
dec insize
|
||||||
|
|
||||||
|
tay
|
||||||
|
|
||||||
|
done2 unlock inmutex
|
||||||
|
tya
|
||||||
|
rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* data for standard input
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
stdin PRIVDATA
|
||||||
|
|
||||||
|
inmutex key
|
||||||
|
|
||||||
|
inReadParm dc i2'4'
|
||||||
|
dc i2'1' ;1 is standard input
|
||||||
|
dc i4'instream'
|
||||||
|
inrequest dc i4'128'
|
||||||
|
insize dc i4'0'
|
||||||
|
|
||||||
|
inindex dc i2'0'
|
||||||
|
|
||||||
|
instream ds 128+1
|
||||||
|
|
||||||
|
END
|
535
bin/gsh/sv.asm
Normal file
535
bin/gsh/sv.asm
Normal file
|
@ -0,0 +1,535 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* SV.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* String Vector routines.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/sv
|
||||||
|
mcopy m/sv.mac
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Allocate a string vector array
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
sv_alloc START
|
||||||
|
|
||||||
|
ptr equ 0
|
||||||
|
space equ ptr+4
|
||||||
|
|
||||||
|
subroutine (2:size),space
|
||||||
|
|
||||||
|
lda size
|
||||||
|
inc a ;for size and count
|
||||||
|
inc a ;at least one null entry
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta ptr
|
||||||
|
stx ptr+2
|
||||||
|
|
||||||
|
ldy #2
|
||||||
|
lda size
|
||||||
|
sta [ptr],y
|
||||||
|
lda #0
|
||||||
|
sta [ptr]
|
||||||
|
ldy #4
|
||||||
|
|
||||||
|
ldx size
|
||||||
|
|
||||||
|
init sta [ptr],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
sta [ptr],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
dex
|
||||||
|
bpl init ;not bne so that extra null at end
|
||||||
|
|
||||||
|
add4 ptr,#4,ptr
|
||||||
|
|
||||||
|
return 4:ptr
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Add a string to the string vector
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
sv_add START
|
||||||
|
|
||||||
|
p equ 0
|
||||||
|
base equ p+4
|
||||||
|
space equ base+4
|
||||||
|
|
||||||
|
subroutine (4:vect,4:string,2:allocflag),space
|
||||||
|
|
||||||
|
sub4 vect,#4,base
|
||||||
|
|
||||||
|
ldy #2
|
||||||
|
lda [base],y
|
||||||
|
cmp [base]
|
||||||
|
beq exit ;ack, the vector is full!
|
||||||
|
;
|
||||||
|
; 1 = allocate memory, 0 = use string as is...
|
||||||
|
;
|
||||||
|
lda allocflag
|
||||||
|
beq asis
|
||||||
|
|
||||||
|
pei (string+2)
|
||||||
|
pei (string)
|
||||||
|
jsr cstrlen
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
jsl ~NEW
|
||||||
|
sta p
|
||||||
|
stx p+2
|
||||||
|
|
||||||
|
pei (string+2)
|
||||||
|
pei (string)
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
jsr copycstr
|
||||||
|
bra doit
|
||||||
|
|
||||||
|
asis mv4 string,p
|
||||||
|
|
||||||
|
doit lda [base]
|
||||||
|
tax
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda p
|
||||||
|
sta [vect],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda p+2
|
||||||
|
sta [vect],y
|
||||||
|
|
||||||
|
txa
|
||||||
|
inc a
|
||||||
|
sta [base]
|
||||||
|
|
||||||
|
exit return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Dispose a string vector
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
sv_dispose START
|
||||||
|
|
||||||
|
p equ 0
|
||||||
|
space equ p+4
|
||||||
|
|
||||||
|
subroutine (4:vect),space
|
||||||
|
|
||||||
|
sub4 vect,#4,p
|
||||||
|
|
||||||
|
loop lda [p]
|
||||||
|
beq done
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [vect],y
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [vect],y
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
jsl nullfree
|
||||||
|
lda [p]
|
||||||
|
dec a
|
||||||
|
sta [p]
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done pei (p+2)
|
||||||
|
pei (p)
|
||||||
|
jsl nullfree
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Column print a string vector
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
sv_colprint START
|
||||||
|
|
||||||
|
numrow equ 0
|
||||||
|
numcol equ numrow+2
|
||||||
|
base equ numcol+2
|
||||||
|
maxlen equ base+4
|
||||||
|
space equ maxlen+2
|
||||||
|
|
||||||
|
subroutine (4:sv),space
|
||||||
|
|
||||||
|
sub4 sv,#4,base
|
||||||
|
;
|
||||||
|
; Find the maximum string length
|
||||||
|
;
|
||||||
|
lda #1
|
||||||
|
sta maxlen
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
lda #0
|
||||||
|
lenloop pha
|
||||||
|
lda [sv],y
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
phy
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
jsr cstrlen
|
||||||
|
cmp maxlen
|
||||||
|
bcc nextlen
|
||||||
|
sta maxlen
|
||||||
|
nextlen ply
|
||||||
|
pla
|
||||||
|
inc a
|
||||||
|
cmp [base]
|
||||||
|
bcc lenloop
|
||||||
|
;
|
||||||
|
; add one for a space
|
||||||
|
;
|
||||||
|
inc maxlen
|
||||||
|
;
|
||||||
|
; calculate the number of columns....this is probably simpler than doing
|
||||||
|
; a divide..
|
||||||
|
;
|
||||||
|
ldx #0
|
||||||
|
txa
|
||||||
|
dex
|
||||||
|
clc
|
||||||
|
colloop inx
|
||||||
|
adc maxlen
|
||||||
|
cmp #80
|
||||||
|
bcc colloop
|
||||||
|
cpx #6+1
|
||||||
|
bcc okcol
|
||||||
|
ldx #6 ;limit of 6 columns
|
||||||
|
okcol stx numcol
|
||||||
|
;
|
||||||
|
; recalculate the width
|
||||||
|
;
|
||||||
|
UDivide (#80,@x),(maxlen,@a)
|
||||||
|
;
|
||||||
|
; calculate the height
|
||||||
|
;
|
||||||
|
lda [base]
|
||||||
|
UDivide (@a,numcol),(numrow,@x)
|
||||||
|
cpx #0
|
||||||
|
beq foocol
|
||||||
|
inc numrow
|
||||||
|
foocol anop
|
||||||
|
;
|
||||||
|
; find the index for each column...
|
||||||
|
;
|
||||||
|
lda #0
|
||||||
|
tax
|
||||||
|
clc
|
||||||
|
mkidxloop sta offtbl,x
|
||||||
|
inx
|
||||||
|
adc numrow
|
||||||
|
cmp [base]
|
||||||
|
bcc mkidxloop
|
||||||
|
;
|
||||||
|
; well....I think we can print now (yay!)
|
||||||
|
;
|
||||||
|
ldx #0
|
||||||
|
printloop lda offtbl,x
|
||||||
|
and #$FF
|
||||||
|
cmp [base]
|
||||||
|
bcs nextprint0
|
||||||
|
inc a
|
||||||
|
short a
|
||||||
|
sta offtbl,x
|
||||||
|
long a
|
||||||
|
phx
|
||||||
|
dec a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
tax
|
||||||
|
lda 1,s
|
||||||
|
jsr puts
|
||||||
|
jsr cstrlen
|
||||||
|
tabit cmp maxlen
|
||||||
|
bcs nextprint
|
||||||
|
pha
|
||||||
|
lda #' '
|
||||||
|
jsr putchar
|
||||||
|
pla
|
||||||
|
inc a
|
||||||
|
bra tabit
|
||||||
|
nextprint plx
|
||||||
|
inx
|
||||||
|
cpx numcol
|
||||||
|
bcc printloop
|
||||||
|
nextprint0 jsr newline
|
||||||
|
ldx #0
|
||||||
|
dec numrow
|
||||||
|
bne printloop
|
||||||
|
|
||||||
|
doneprint return
|
||||||
|
|
||||||
|
offtbl ds 7
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Sort a string vector
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
sv_sort START
|
||||||
|
|
||||||
|
space equ 0
|
||||||
|
|
||||||
|
subroutine (4:sv),space
|
||||||
|
|
||||||
|
pei (sv+2)
|
||||||
|
pei (sv)
|
||||||
|
sub4 sv,#4,sv
|
||||||
|
pea 0
|
||||||
|
lda [sv]
|
||||||
|
dec a
|
||||||
|
pha
|
||||||
|
jsl _qsort
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
_qsort PRIVATE
|
||||||
|
|
||||||
|
vleft equ 0
|
||||||
|
i equ vleft+4
|
||||||
|
last equ i+2
|
||||||
|
ptr2 equ last+2
|
||||||
|
ptr1 equ ptr2+4
|
||||||
|
idx1 equ ptr1+4
|
||||||
|
space equ idx1+2
|
||||||
|
|
||||||
|
subroutine (4:sv,2:left,2:right),space
|
||||||
|
;
|
||||||
|
; if (left >= right)
|
||||||
|
; return;
|
||||||
|
;
|
||||||
|
lda right ;if one or two elements do nothing
|
||||||
|
jmi exit
|
||||||
|
cmp left
|
||||||
|
jcc exit
|
||||||
|
;
|
||||||
|
; swap(v, left, (left + right)/2);
|
||||||
|
;
|
||||||
|
lda left
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta idx1
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr1
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr1+2
|
||||||
|
add2 left,right,@a
|
||||||
|
lsr a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr2
|
||||||
|
lda ptr1
|
||||||
|
sta [sv],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr2+2
|
||||||
|
lda ptr1+2
|
||||||
|
sta [sv],y
|
||||||
|
ldy idx1
|
||||||
|
lda ptr2
|
||||||
|
sta [sv],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda ptr2+2
|
||||||
|
sta [sv],y
|
||||||
|
;
|
||||||
|
; last = left;
|
||||||
|
;
|
||||||
|
lda left
|
||||||
|
sta last
|
||||||
|
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
sta vleft
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
sta vleft+2
|
||||||
|
;
|
||||||
|
; for (i=left+1; i <=right; i++)
|
||||||
|
;
|
||||||
|
lda left
|
||||||
|
inc a
|
||||||
|
sta i
|
||||||
|
forloop lda i
|
||||||
|
cmp right
|
||||||
|
beq okloop
|
||||||
|
bcs endloop
|
||||||
|
okloop anop
|
||||||
|
;
|
||||||
|
; if (strcmp(v[i],v[left]) < 0)
|
||||||
|
;
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
pha
|
||||||
|
phx
|
||||||
|
pei (vleft+2)
|
||||||
|
pei (vleft)
|
||||||
|
jsr cmpcstr
|
||||||
|
bpl nextloop
|
||||||
|
;
|
||||||
|
; swap (v, ++last, i)
|
||||||
|
;
|
||||||
|
inc last
|
||||||
|
lda last
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta idx1
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr1
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr1+2
|
||||||
|
lda i
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr2
|
||||||
|
lda ptr1
|
||||||
|
sta [sv],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr2+2
|
||||||
|
lda ptr1+2
|
||||||
|
sta [sv],y
|
||||||
|
ldy idx1
|
||||||
|
lda ptr2
|
||||||
|
sta [sv],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda ptr2+2
|
||||||
|
sta [sv],y
|
||||||
|
|
||||||
|
nextloop inc i
|
||||||
|
jmp forloop
|
||||||
|
;
|
||||||
|
; swap(v, left, last)
|
||||||
|
;
|
||||||
|
endloop lda left
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta idx1
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr1
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr1+2
|
||||||
|
lda last
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
tay
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr2
|
||||||
|
lda ptr1
|
||||||
|
sta [sv],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda [sv],y
|
||||||
|
sta ptr2+2
|
||||||
|
lda ptr1+2
|
||||||
|
sta [sv],y
|
||||||
|
ldy idx1
|
||||||
|
lda ptr2
|
||||||
|
sta [sv],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda ptr2+2
|
||||||
|
sta [sv],y
|
||||||
|
;
|
||||||
|
; qsort(v, left, last-1)
|
||||||
|
;
|
||||||
|
pei (sv+2)
|
||||||
|
pei (sv)
|
||||||
|
pei (left)
|
||||||
|
lda last
|
||||||
|
dec a
|
||||||
|
pha
|
||||||
|
jsl _qsort
|
||||||
|
;
|
||||||
|
; qsort(v, last+1, right)
|
||||||
|
;
|
||||||
|
pei (sv+2)
|
||||||
|
pei (sv)
|
||||||
|
lda last
|
||||||
|
inc a
|
||||||
|
pha
|
||||||
|
pei (right)
|
||||||
|
jsl _qsort
|
||||||
|
|
||||||
|
exit return
|
||||||
|
|
||||||
|
END
|
485
bin/gsh/term.asm
Normal file
485
bin/gsh/term.asm
Normal file
|
@ -0,0 +1,485 @@
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* The GNO Shell Project
|
||||||
|
*
|
||||||
|
* Developed by:
|
||||||
|
* Jawaid Bazyar
|
||||||
|
* Tim Meekins
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* TERM.ASM
|
||||||
|
* By Tim Meekins
|
||||||
|
*
|
||||||
|
* Routines for dealing with Termcap under gsh.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
keep o/term
|
||||||
|
mcopy m/term.mac
|
||||||
|
|
||||||
|
TIOCGETP gequ $40067408
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Initialize the system for termcap - checks to see if $TERM exists
|
||||||
|
* and is set, if not, sets to GNOCON
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
InitTerm START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
Set_Variable setparm
|
||||||
|
Export expparm
|
||||||
|
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'
|
||||||
|
|
||||||
|
expparm dc i4'termname'
|
||||||
|
dc i2'1'
|
||||||
|
|
||||||
|
termname str 'term'
|
||||||
|
termval str 'gnocon'
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* read new temcap information
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
readterm START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
backward_char equ 3
|
||||||
|
forward_char equ 4
|
||||||
|
up_history equ 5
|
||||||
|
down_history equ 6
|
||||||
|
|
||||||
|
lda #1
|
||||||
|
sta didReadTerm
|
||||||
|
|
||||||
|
ph4 #termname
|
||||||
|
jsl getenv
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
tgetent (bp,@xa) ;xa is pushed first
|
||||||
|
beq noentry
|
||||||
|
dec a
|
||||||
|
beq ok
|
||||||
|
|
||||||
|
jsl nullfree
|
||||||
|
stz termok
|
||||||
|
ldx #^error1
|
||||||
|
lda #error1
|
||||||
|
jmp errputs
|
||||||
|
|
||||||
|
noentry jsl nullfree
|
||||||
|
stz termok
|
||||||
|
ldx #^error2
|
||||||
|
lda #error2
|
||||||
|
jsr errputs
|
||||||
|
ph4 #termname
|
||||||
|
jsl getenv
|
||||||
|
jsr errputs
|
||||||
|
lda #13
|
||||||
|
jmp errputchar
|
||||||
|
|
||||||
|
ok jsl nullfree
|
||||||
|
lda #1
|
||||||
|
sta termok
|
||||||
|
mv4 areabuf,area
|
||||||
|
|
||||||
|
tgetstr (#isid,#area)
|
||||||
|
jsr puts
|
||||||
|
tgetstr (#leid,#area)
|
||||||
|
sta lecap
|
||||||
|
stx lecap+2
|
||||||
|
tgetstr (#ndid,#area)
|
||||||
|
sta ndcap
|
||||||
|
stx ndcap+2
|
||||||
|
tgetstr (#veid,#area)
|
||||||
|
sta vecap
|
||||||
|
stx vecap+2
|
||||||
|
tgetstr (#viid,#area)
|
||||||
|
sta vicap
|
||||||
|
stx vicap+2
|
||||||
|
tgetstr (#vsid,#area)
|
||||||
|
sta vscap
|
||||||
|
stx vscap+2
|
||||||
|
tgetstr (#blid,#area)
|
||||||
|
sta blcap
|
||||||
|
stx blcap+2
|
||||||
|
tgetstr (#clid,#area)
|
||||||
|
sta clcap
|
||||||
|
stx clcap+2
|
||||||
|
tgetstr (#soid,#area)
|
||||||
|
sta socap
|
||||||
|
stx socap+2
|
||||||
|
tgetstr (#seid,#area)
|
||||||
|
sta secap
|
||||||
|
stx secap+2
|
||||||
|
tgetstr (#cdid,#area)
|
||||||
|
sta cdcap
|
||||||
|
stx cdcap+2
|
||||||
|
tgetstr (#ueid,#area)
|
||||||
|
sta uecap
|
||||||
|
stx uecap+2
|
||||||
|
tgetstr (#usid,#area)
|
||||||
|
sta uscap
|
||||||
|
stx uscap+2
|
||||||
|
|
||||||
|
tgetstr (#klid,#area)
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
ph2 #backward_char
|
||||||
|
jsl bindkeyfunc
|
||||||
|
tgetstr (#krid,#area)
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
ph2 #forward_char
|
||||||
|
jsl bindkeyfunc
|
||||||
|
tgetstr (#kuid,#area)
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
ph2 #up_history
|
||||||
|
jsl bindkeyfunc
|
||||||
|
tgetstr (#kdid,#area)
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
ph2 #down_history
|
||||||
|
jsl bindkeyfunc
|
||||||
|
|
||||||
|
; the following is VERY important. It doesn't seem so, but I actually tested
|
||||||
|
; a terminal that dropped characters w/o it.
|
||||||
|
|
||||||
|
ioctl (#1,#TIOCGETP,#sgtty)
|
||||||
|
lda sg_ospeed ;let termcap know our speed
|
||||||
|
case on
|
||||||
|
sta >ospeed
|
||||||
|
case off
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
termname dc c'term',h'00'
|
||||||
|
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'
|
||||||
|
leid dc c'le',h'00'
|
||||||
|
ndid dc c'nd',h'00'
|
||||||
|
veid dc c've',h'00'
|
||||||
|
viid dc c'vi',h'00'
|
||||||
|
vsid dc c'vs',h'00'
|
||||||
|
blid dc c'bl',h'00'
|
||||||
|
clid dc c'cl',h'00'
|
||||||
|
soid dc c'so',h'00'
|
||||||
|
seid dc c'se',h'00'
|
||||||
|
klid dc c'kl',h'00'
|
||||||
|
krid dc c'kr',h'00'
|
||||||
|
kuid dc c'ku',h'00'
|
||||||
|
kdid dc c'kd',h'00'
|
||||||
|
cdid dc c'cd',h'00'
|
||||||
|
ueid dc c'ue',h'00'
|
||||||
|
usid dc c'us',h'00'
|
||||||
|
|
||||||
|
sgtty anop
|
||||||
|
dc i1'0'
|
||||||
|
sg_ospeed dc i1'0'
|
||||||
|
dc i1'0'
|
||||||
|
dc i1'0'
|
||||||
|
sg_flags dc i2'0'
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* outc for outputting characters by termcap
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
outc START
|
||||||
|
|
||||||
|
space equ 0
|
||||||
|
|
||||||
|
subroutine (2:char),space
|
||||||
|
|
||||||
|
lda char
|
||||||
|
jsr putchar
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* move left x characters
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
moveleft START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
|
||||||
|
loop dex
|
||||||
|
bmi done
|
||||||
|
phx
|
||||||
|
tputs (lecap,#0,#outc)
|
||||||
|
plx
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* move right x characters
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
moveright START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
|
||||||
|
loop dex
|
||||||
|
bmi done
|
||||||
|
phx
|
||||||
|
tputs (ndcap,#0,#outc)
|
||||||
|
plx
|
||||||
|
bra loop
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* cursor off
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
cursoroff START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
lda vicap
|
||||||
|
ldx vicap+2
|
||||||
|
jmp puts
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* cursor on
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
cursoron START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
lda insertflag
|
||||||
|
beq dovs
|
||||||
|
|
||||||
|
lda vecap
|
||||||
|
ldx vecap+2
|
||||||
|
jmp puts
|
||||||
|
|
||||||
|
dovs lda vscap
|
||||||
|
ldx vscap+2
|
||||||
|
jmp puts
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* Beep the bell if it's ok.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
beep START
|
||||||
|
|
||||||
|
using vardata
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda varnobeep
|
||||||
|
bne beepdone
|
||||||
|
lda termok
|
||||||
|
beq beepdone
|
||||||
|
tputs (blcap,#0,#outc)
|
||||||
|
beepdone rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* clear the screen
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
clearscrn START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
tputs (clcap,#0,#outc)
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* begin standout mode
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
standout START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
|
||||||
|
tputs (socap,#0,#outc)
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* end standout mode
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
standend START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
|
||||||
|
tputs (secap,#0,#outc)
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* begin underline mode
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
underline START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
|
||||||
|
tputs (uscap,#0,#outc)
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* end underline mode
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
underend START
|
||||||
|
|
||||||
|
using termdata
|
||||||
|
|
||||||
|
lda termok
|
||||||
|
beq done
|
||||||
|
|
||||||
|
tputs (uecap,#0,#outc)
|
||||||
|
|
||||||
|
done rts
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* TSET: builtin command
|
||||||
|
* syntax: tset
|
||||||
|
*
|
||||||
|
* reset the termcap for gsh
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
tset START
|
||||||
|
|
||||||
|
using global
|
||||||
|
|
||||||
|
space equ 0
|
||||||
|
|
||||||
|
subroutine (4:argv,2:argc),space
|
||||||
|
|
||||||
|
jsr readterm
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* termcap data
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
|
||||||
|
termdata DATA
|
||||||
|
|
||||||
|
didReadTerm dc i2'0'
|
||||||
|
|
||||||
|
termok dc i2'0'
|
||||||
|
insertflag dc i2'1'
|
||||||
|
|
||||||
|
bp ds 4
|
||||||
|
areabuf ds 4
|
||||||
|
area ds 4
|
||||||
|
|
||||||
|
blcap ds 4
|
||||||
|
cdcap ds 4
|
||||||
|
clcap ds 4
|
||||||
|
lecap ds 4
|
||||||
|
ndcap ds 4
|
||||||
|
secap ds 4
|
||||||
|
socap ds 4
|
||||||
|
uecap ds 4
|
||||||
|
uscap ds 4
|
||||||
|
vecap ds 4
|
||||||
|
vicap ds 4
|
||||||
|
vscap ds 4
|
||||||
|
|
||||||
|
END
|
||||||
|
|
4
bin/gsh/tests/history
Normal file
4
bin/gsh/tests/history
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
set term=gno
|
||||||
|
ls
|
||||||
|
ls -l >.null &
|
||||||
|
ls
|
1
bin/gsh/tests/test
Normal file
1
bin/gsh/tests/test
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/bin/ls
|
2
bin/gsh/tests/testscr
Normal file
2
bin/gsh/tests/testscr
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
echo "hi there!"
|
||||||
|
ls g*
|
Loading…
Reference in New Issue
Block a user