mirror of https://github.com/A2osX/A2osX.git
TERMIBAL, PRINTF, SH, Piping....
This commit is contained in:
parent
0ea8d62a96
commit
87b9078877
|
@ -1195,16 +1195,6 @@ Specifiers :
|
||||||
+ %L : pull 4 bytes signed DEC -2147483648..2147483647
|
+ %L : pull 4 bytes signed DEC -2147483648..2147483647
|
||||||
+ %s : pull 2 bytes ptr to C-Style String
|
+ %s : pull 2 bytes ptr to C-Style String
|
||||||
+ %S : pull 2 bytes ptr to P-Style String
|
+ %S : pull 2 bytes ptr to P-Style String
|
||||||
+ \b : Print 'BS' (08)
|
|
||||||
+ \e : Print 'ESC' ($1B,27)
|
|
||||||
+ \f : Print 'FF' ($0C,12)
|
|
||||||
+ \n : Print 'LF' ($0A,10)
|
|
||||||
+ \r : Print 'CR' ($0D,13)
|
|
||||||
+ \t : Print 'TAB' ($09,09)
|
|
||||||
+ \v : Print 'VT' ($0B,11)
|
|
||||||
+ \xHH : Print byte with hexadecimal value HH (1 to 2 digits)
|
|
||||||
+ \\\\ : Print \
|
|
||||||
+ \\% : Print %
|
|
||||||
|
|
||||||
Modifiers for len and padding :
|
Modifiers for len and padding :
|
||||||
+ %d : '9' '12'
|
+ %d : '9' '12'
|
||||||
|
|
|
@ -182,7 +182,7 @@ CS: A = EC
|
||||||
CC: Y,A = bytes written
|
CC: Y,A = bytes written
|
||||||
CS: A = EC
|
CS: A = EC
|
||||||
|
|
||||||
# RecvFrom (RAW,DGRAM,SEQPKT)
|
# RecvFrom (RAW,DGRAM)
|
||||||
|
|
||||||
## C
|
## C
|
||||||
`hMem recvfrom(hFD fd, struct sockaddr *addr);`
|
`hMem recvfrom(hFD fd, struct sockaddr *addr);`
|
||||||
|
|
|
@ -301,13 +301,15 @@ The **default** commands is used to select the block of commands to execute for
|
||||||
|
|
||||||
### ECHO
|
### ECHO
|
||||||
|
|
||||||
echo [-n] <value>...
|
echo [-e] [-n] <value>...
|
||||||
|
|
||||||
|
The **echo** command optional switch **-e** causes **echo** to process escape **\\** caracters.
|
||||||
The **echo** command is used to print <values> to an output device, by default the screen. The **echo** command optional switch **-n** causes **echo** to suppress output of the carriage return that normally occurs. Technically the format of the **echo** command is **echo [-n] [\<value\> ...]**. This means that the **echo** command can be followed by the optional switch **-n** and one or more optional \<values\>. In the case of **echo**, it is these \<values\> that are output by the command. Here, values are separated by spaces, so you can do ECHO $A HELLO $B and echo will output the value stored in the variable A and then the world HELLO and then the value stored in B. Please see \<values> for more information on how values are processed, especially in the handling of variables ($VAR) contained in a \<value>.
|
The **echo** command is used to print <values> to an output device, by default the screen. The **echo** command optional switch **-n** causes **echo** to suppress output of the carriage return that normally occurs. Technically the format of the **echo** command is **echo [-n] [\<value\> ...]**. This means that the **echo** command can be followed by the optional switch **-n** and one or more optional \<values\>. In the case of **echo**, it is these \<values\> that are output by the command. Here, values are separated by spaces, so you can do ECHO $A HELLO $B and echo will output the value stored in the variable A and then the world HELLO and then the value stored in B. Please see \<values> for more information on how values are processed, especially in the handling of variables ($VAR) contained in a \<value>.
|
||||||
|
|
||||||
A word about values, command lines and spaces: **echo Hello World** is not the same as **echo "Hello World"**. In the first case **echo** treats Hello and World as separate values and in the second, "Hello World" as one value. Since **echo** takes multiple values, you might not notice the difference, but in the case of **if [ $A = "Hello World" ]** if you omitted the quotes you would get a syntax error because the = operator only accepts one value on each side. In addition, when not enclosed in quotes, extra spaces are removed so **echo Hello World** would be output as **Hello World** as **echo** would treat Hello and World as values and output value space value.
|
A word about values, command lines and spaces: **echo Hello World** is not the same as **echo "Hello World"**. In the first case **echo** treats Hello and World as separate values and in the second, "Hello World" as one value. Since **echo** takes multiple values, you might not notice the difference, but in the case of **if [ $A = "Hello World" ]** if you omitted the quotes you would get a syntax error because the = operator only accepts one value on each side. In addition, when not enclosed in quotes, extra spaces are removed so **echo Hello World** would be output as **Hello World** as **echo** would treat Hello and World as values and output value space value.
|
||||||
|
|
||||||
In addition to the usual variable substitution that occurs with \<values> (see \<value> above), the **echo** command performs some special character substitutions while sending output to the screen or terminal. If placed inside a value like a string, **echo** will automatically substitute a backspace for the sequence **\b**, substitute an escape for **\e**, clear the screen for **\f**, send a newline for **\n**, send a \ for **\\\\** and send a % for **\\%**. The **\e** (escape) code is useful for sending VT100 escape sequences to the screen/terminal (see the VT100 example script). The **\\\\** and **\\%** are necessary to send those chars to the screen since normally those characters are interpreted as special command line arguments. There is also a special **\xHH** option, that will send explicitly the char represented by the HEX value HH to the output device (screen or file).
|
supported escaped chars : **\\a**,**\\b**,**\\e**,**\\f**,**\\n**,**\\r**,**\\t**,**\\v**,**\\\\**,**\\'**,**\\"**,**\\?**
|
||||||
|
|
||||||
|
In addition to the usual variable substitution that occurs with \<values> (see \<value> above), the **echo** command performs some special character substitutions while sending output to the screen or terminal. If placed inside a value like a string, **echo** will automatically substitute a backspace for the sequence **\b**, substitute an escape for **\e**, clear the screen for **\f**, send a newline for **\n**, send a \ for **\\\\** and send a % for **\\%**. The **\e** (escape) code is useful for sending VT100 escape sequences to the screen/terminal (see the VT100 example script). The **\\\\** and **\\%** are necessary to send those chars to the screen since normally those characters are interpreted as special command line arguments. There is also special **\xHH** and **\OOO** options, that will send explicitly the char represented by the HEX value HH or OCT value OOO to the output device (screen or file).
|
||||||
|
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# A2osX Terminal Codes Guide
|
# A2osX Terminal Codes Guide
|
||||||
|
|
||||||
### Updated Apr. 15, 2023
|
### Updated May. 14, 2023
|
||||||
|
|
||||||
A2osX terminal capabilities are based off of the standard VT-100 Terminal. This applies to users connected via Super Serial Cards, Telnet (via TelnetD server daemon) and the Apple console (physical keyboard/screen). All programs can use this facility to create rich interactive text mode applications. This includes both programs written in Assembly or Scripts written for the Shell (SH). The table below lists the codes you can use in your applications and their function. Consult the A2osX Shell Developers Guide for information on using these codes in scripts. Note, the Apple Console implementation only supports a subset of the VT-100 codes, these are noted in the last column as OK.
|
A2osX terminal capabilities are based off of the standard VT-100 Terminal. This applies to users connected via Super Serial Cards, Telnet (via TelnetD server daemon) and the Apple console (physical keyboard/screen). All programs can use this facility to create rich interactive text mode applications. This includes both programs written in Assembly or Scripts written for the Shell (SH). The table below lists the codes you can use in your applications and their function. Consult the A2osX Shell Developers Guide for information on using these codes in scripts. Note, the Apple Console implementation only supports a subset of the VT-100 codes, these are noted in the last column as OK.
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ A2osX terminal capabilities are based off of the standard VT-100 Terminal. This
|
||||||
|Esc[?7h |Set auto-wrap mode|DECAWM|OK| |
|
|Esc[?7h |Set auto-wrap mode|DECAWM|OK| |
|
||||||
|Esc[?8h |Set auto-repeat mode|DECARM|| |
|
|Esc[?8h |Set auto-repeat mode|DECARM|| |
|
||||||
|Esc[?9h |Set interlacing mode|DECINLM|| |
|
|Esc[?9h |Set interlacing mode|DECINLM|| |
|
||||||
|
|Esc[?25h |Show cursor| DECTCEM |OK||
|
||||||
|Esc[20l |Reset line feed mode|LMN|OK| |
|
|Esc[20l |Reset line feed mode|LMN|OK| |
|
||||||
|Esc[?1l |Reset cursor key to cursor|DECCKM|| |
|
|Esc[?1l |Reset cursor key to cursor|DECCKM|| |
|
||||||
|Esc[?2l |Reset VT52 (versus ANSI) |DECANM|| |
|
|Esc[?2l |Reset VT52 (versus ANSI) |DECANM|| |
|
||||||
|
@ -25,6 +26,7 @@ A2osX terminal capabilities are based off of the standard VT-100 Terminal. This
|
||||||
|Esc[?7l |Reset auto-wrap mode| DECAWM |OK||
|
|Esc[?7l |Reset auto-wrap mode| DECAWM |OK||
|
||||||
|Esc[?8l |Reset auto-repeat mode| DECARM || |
|
|Esc[?8l |Reset auto-repeat mode| DECARM || |
|
||||||
|Esc[?9l |Reset interlacing mode| DECINLM |||
|
|Esc[?9l |Reset interlacing mode| DECINLM |||
|
||||||
|
|Esc[?25l |Hide cursor| DECTCEM |OK||
|
||||||
|Esc= |Set alternate keypad mode| DECKPAM |||
|
|Esc= |Set alternate keypad mode| DECKPAM |||
|
||||||
|Esc> |Set numeric keypad mode| DECKPNM |||
|
|Esc> |Set numeric keypad mode| DECKPNM |||
|
||||||
|Esc(A |Set United Kingdom G0 character set| setukg0 |OK||
|
|Esc(A |Set United Kingdom G0 character set| setukg0 |OK||
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -117,17 +117,23 @@ BSX.MoveHead sta BSX.TargetQTrack
|
||||||
cmp BSX.TargetQTrack
|
cmp BSX.TargetQTrack
|
||||||
bne .3
|
bne .3
|
||||||
|
|
||||||
lsr CS if X,Y on
|
* lsr CS if X,Y on
|
||||||
|
|
||||||
jsr BSX.Wait25600usec
|
jsr BSX.Wait25600usec
|
||||||
|
|
||||||
|
ldy BSX.Slotn0
|
||||||
|
lda IO.D2.Ph0Off+2,y
|
||||||
|
lda IO.D2.Ph0Off+6,y
|
||||||
lda IO.D2.Ph0Off,y
|
lda IO.D2.Ph0Off,y
|
||||||
|
lda IO.D2.Ph0Off+4,y
|
||||||
|
|
||||||
bcc .10
|
* lda IO.D2.Ph0Off,y
|
||||||
|
|
||||||
|
* bcc .10
|
||||||
|
|
||||||
clc
|
* lda IO.D2.Ph0Off,x
|
||||||
|
* clc
|
||||||
lda IO.D2.Ph0Off,x
|
* lda IO.D2.Ph0Off,y
|
||||||
|
|
||||||
.10 rts
|
.10 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
|
|
@ -364,25 +364,17 @@ SCRN.UpdateLineAtBufPtr
|
||||||
jsr SCRN.ToggleSel
|
jsr SCRN.ToggleSel
|
||||||
|
|
||||||
.5 lda (BufPtr)
|
.5 lda (BufPtr)
|
||||||
cmp #'\'
|
|
||||||
beq .50
|
|
||||||
|
|
||||||
cmp #'%'
|
|
||||||
bne .51
|
|
||||||
|
|
||||||
.50 pha
|
|
||||||
lda #'\'
|
|
||||||
jsr SCRN.ToLineBuf
|
jsr SCRN.ToLineBuf
|
||||||
pla
|
|
||||||
|
|
||||||
.51 jsr SCRN.ToLineBuf
|
|
||||||
inc BufPtr
|
inc BufPtr
|
||||||
bne .6
|
bne .6
|
||||||
|
|
||||||
inc BufPtr+1
|
inc BufPtr+1
|
||||||
|
|
||||||
.6 inc BUF.COffset
|
.6 inc BUF.COffset
|
||||||
bne .7
|
bne .7
|
||||||
|
|
||||||
inc BUF.COffset+1
|
inc BUF.COffset+1
|
||||||
|
|
||||||
.7 dex
|
.7 dex
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ DumpFD.PIPE >PUSHW L.MSG.PIPE
|
||||||
|
|
||||||
jsr DumpFD.Name
|
jsr DumpFD.Name
|
||||||
|
|
||||||
>PUSHBI 5
|
>PUSHBI 6
|
||||||
>SYSCALL PrintF
|
>SYSCALL PrintF
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
@ -263,7 +263,7 @@ MSG.DEV.ERR .CZ "[%h] Device Error.\r\n"
|
||||||
MSG.DEV.DIB .CZ "%s %h.%h %16S %3d.%3d "
|
MSG.DEV.DIB .CZ "%s %h.%h %16S %3d.%3d "
|
||||||
MSG.DEV.B .CZ "%10u\r\n"
|
MSG.DEV.B .CZ "%10u\r\n"
|
||||||
MSG.DEV.C .CZ "n/a\r\n"
|
MSG.DEV.C .CZ "n/a\r\n"
|
||||||
MSG.PIPE .CZ "%3d %5s %s\r\n"
|
MSG.PIPE .CZ "%3d %h %4s %s\r\n"
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
MSG.SFLAGS .AS "bwrlneio"
|
MSG.SFLAGS .AS "bwrlneio"
|
||||||
NO.PATH .AZ "(no path)"
|
NO.PATH .AZ "(no path)"
|
||||||
|
|
|
@ -36,9 +36,9 @@ CS.START cld
|
||||||
.DA CS.RUN
|
.DA CS.RUN
|
||||||
.DA CS.EVENT
|
.DA CS.EVENT
|
||||||
.DA CS.QUIT
|
.DA CS.QUIT
|
||||||
L.MSG0 .DA MSG0
|
L.MSG.HEADER .DA MSG.HEADER
|
||||||
L.MSG1 .DA MSG1
|
L.MSG.BODY .DA MSG.REGDIR
|
||||||
L.MSG.NA .DA MSG.NA
|
.DA MSG.SPECIAL
|
||||||
L.FD.T .DA FD.T.REG
|
L.FD.T .DA FD.T.REG
|
||||||
.DA FD.T.DIR
|
.DA FD.T.DIR
|
||||||
.DA FD.T.CDEV
|
.DA FD.T.CDEV
|
||||||
|
@ -52,7 +52,7 @@ L.FD.T .DA FD.T.REG
|
||||||
CS.INIT clc
|
CS.INIT clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN >LDYA L.MSG0
|
CS.RUN >LDYA L.MSG.HEADER
|
||||||
>SYSCALL PutS
|
>SYSCALL PutS
|
||||||
|
|
||||||
ldx #1
|
ldx #1
|
||||||
|
@ -62,7 +62,23 @@ CS.RUN >LDYA L.MSG0
|
||||||
lda hFDs-1,x
|
lda hFDs-1,x
|
||||||
beq .7
|
beq .7
|
||||||
|
|
||||||
>PUSHW L.MSG1
|
>SYSCALL GetMemPtr
|
||||||
|
>STYA ZPFDPtr
|
||||||
|
|
||||||
|
ldx FILE.ID
|
||||||
|
|
||||||
|
lda hFDs.oCnt-1,x
|
||||||
|
beq .7
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
lda (ZPFDPtr)
|
||||||
|
cmp #S.FD.T.DIR+1
|
||||||
|
bcc .2
|
||||||
|
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
|
||||||
|
.2 >PUSHW L.MSG.BODY,y
|
||||||
|
|
||||||
txa
|
txa
|
||||||
>PUSHA
|
>PUSHA
|
||||||
|
@ -70,27 +86,16 @@ CS.RUN >LDYA L.MSG0
|
||||||
lda hFDs-1,x
|
lda hFDs-1,x
|
||||||
>PUSHA
|
>PUSHA
|
||||||
|
|
||||||
>SYSCALL GetMemPtr
|
|
||||||
>STYA ZPFDPtr
|
|
||||||
|
|
||||||
ldx FILE.ID
|
|
||||||
lda hFDs.oCnt-1,x
|
lda hFDs.oCnt-1,x
|
||||||
>PUSHA
|
>PUSHA
|
||||||
|
|
||||||
lda (ZPFDPtr)
|
lda (ZPFDPtr)
|
||||||
tax
|
tay
|
||||||
>PUSHW L.FD.T,x
|
>PUSHW L.FD.T,y
|
||||||
|
|
||||||
|
jsr CS.RUN.GetName
|
||||||
|
|
||||||
ldx FILE.ID
|
>PUSHYA
|
||||||
lda hFDs.hName-1,x
|
|
||||||
bne .5
|
|
||||||
|
|
||||||
>LDYA L.MSG.NA
|
|
||||||
bra .6
|
|
||||||
|
|
||||||
.5 >SYSCALL GetMemPtr
|
|
||||||
|
|
||||||
.6 >PUSHYA
|
|
||||||
|
|
||||||
>PUSHBI 7
|
>PUSHBI 7
|
||||||
|
|
||||||
|
@ -105,6 +110,22 @@ CS.RUN >LDYA L.MSG0
|
||||||
sec
|
sec
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
CS.RUN.GetName lda hFDs.hName-1,x
|
||||||
|
bne .1
|
||||||
|
|
||||||
|
lda ZPFDPtr
|
||||||
|
clc
|
||||||
|
adc #S.FD.DEV
|
||||||
|
tay
|
||||||
|
lda ZPFDPtr+1
|
||||||
|
adc /S.FD.DEV
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
.1 >SYSCALL GetMemPtr
|
||||||
|
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
CS.EVENT sec
|
CS.EVENT sec
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
@ -112,9 +133,9 @@ CS.QUIT clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.END
|
CS.END
|
||||||
MSG0 .CZ "hFILE hFD Cnt Type Filepath"
|
MSG.HEADER .CZ "hFILE hFD Cnt Type Filepath"
|
||||||
MSG1 .CZ "%3d %3d %3d %4s %s\r\n"
|
MSG.REGDIR .CZ "%3d %3d %3d %4s %s\r\n"
|
||||||
MSG.NA .CZ "n/a"
|
MSG.SPECIAL .CZ "%3d %3d %3d %4s /dev/%s\r\n"
|
||||||
FD.T.REG .CZ "REG"
|
FD.T.REG .CZ "REG"
|
||||||
FD.T.DIR .CZ "DIR"
|
FD.T.DIR .CZ "DIR"
|
||||||
FD.T.CDEV .CZ "CDEV"
|
FD.T.CDEV .CZ "CDEV"
|
||||||
|
|
|
@ -128,15 +128,22 @@ CS.RUN inc ArgCount
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
ldy #S.PS.hStdIn
|
||||||
lda (pPS),y
|
lda (pPS),y
|
||||||
|
|
||||||
|
pha
|
||||||
|
|
||||||
tax
|
tax
|
||||||
|
|
||||||
lda hFDs-1,x
|
lda hFDs-1,x
|
||||||
>SYSCALL GetMemPtr
|
>SYSCALL GetMemPtr
|
||||||
>STYA ZPPtr1
|
>STYA ZPPtr1
|
||||||
|
|
||||||
|
plx
|
||||||
|
|
||||||
lda (ZPPtr1)
|
lda (ZPPtr1)
|
||||||
cmp #S.FD.T.PIPE
|
cmp #S.FD.T.PIPE
|
||||||
bne .71
|
bne .71
|
||||||
|
|
||||||
|
stx hFile
|
||||||
|
|
||||||
.80 >LDYAI 256
|
.80 >LDYAI 256
|
||||||
>SYSCALL GetMem
|
>SYSCALL GetMem
|
||||||
|
@ -203,7 +210,9 @@ CS.RUN.PAUSE ldy #S.PS.hStdErr
|
||||||
>PUSHW L.MSG.Pause
|
>PUSHW L.MSG.Pause
|
||||||
>SYSCALL FPutS
|
>SYSCALL FPutS
|
||||||
|
|
||||||
.10 jsr CS.RUN.GETC
|
.10 ldy #S.PS.hStdErr
|
||||||
|
lda (pPS),y
|
||||||
|
>SYSCALL GetC
|
||||||
bcs .99
|
bcs .99
|
||||||
|
|
||||||
cmp #'Q'
|
cmp #'Q'
|
||||||
|
@ -251,24 +260,7 @@ CS.RUN.ERASE ldy #S.PS.hStdErr
|
||||||
>SYSCALL FPutS
|
>SYSCALL FPutS
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.GETC lda hFile
|
CS.RUN.GETLINE >PUSHB hFile
|
||||||
bne .1
|
|
||||||
|
|
||||||
ldy #S.PS.hStdErr
|
|
||||||
lda (pPS),y
|
|
||||||
>SYSCALL GetC
|
|
||||||
rts
|
|
||||||
|
|
||||||
.1 >SYSCALL GetChar
|
|
||||||
rts
|
|
||||||
*--------------------------------------
|
|
||||||
CS.RUN.GETLINE lda hFile
|
|
||||||
bne .1
|
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
|
||||||
lda (pPS),y
|
|
||||||
|
|
||||||
.1 >PUSHA
|
|
||||||
|
|
||||||
>PUSHW ZPBufPtr
|
>PUSHW ZPBufPtr
|
||||||
>PUSHWI 256
|
>PUSHWI 256
|
||||||
|
|
435
BIN/OD.S.txt
435
BIN/OD.S.txt
|
@ -1,235 +1,236 @@
|
||||||
NEW
|
NEW
|
||||||
AUTO 3,1
|
AUTO 3,1
|
||||||
.LIST OFF
|
.LIST OFF
|
||||||
.OP 65C02
|
.OP 65C02
|
||||||
.OR $2000
|
.OR $2000
|
||||||
.TF bin/od
|
.TF bin/od
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.INB inc/macros.i
|
.INB inc/macros.i
|
||||||
.INB inc/a2osx.i
|
.INB inc/a2osx.i
|
||||||
.INB inc/kernel.i
|
.INB inc/kernel.i
|
||||||
.INB inc/mli.i
|
.INB inc/mli.i
|
||||||
.INB inc/mli.e.i
|
.INB inc/mli.e.i
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.DUMMY
|
.DUMMY
|
||||||
.OR ZPBIN
|
.OR ZPBIN
|
||||||
ZS.START
|
ZS.START
|
||||||
ArgIndex .BS 1
|
ArgIndex .BS 1
|
||||||
ArgPattern .BS 1
|
ArgPattern .BS 1
|
||||||
ZPPtr1 .BS 2
|
ZPPtr1 .BS 2
|
||||||
ZPBufPtr .BS 2
|
ZPBufPtr .BS 2
|
||||||
hFile .BS 1
|
hFile .BS 1
|
||||||
hBuf .BS 1
|
hBuf .BS 1
|
||||||
char .BS 1
|
char .BS 1
|
||||||
ByteCount .BS 3
|
ByteCount .BS 3
|
||||||
bPause .BS 1
|
bPause .BS 1
|
||||||
bPipe .BS 1
|
bPipe .BS 1
|
||||||
bIsTTY .BS 1
|
bIsTTY .BS 1
|
||||||
bTemp .BS 1
|
bTemp .BS 1
|
||||||
bDummy .BS 1
|
bDummy .BS 1
|
||||||
|
|
||||||
ZS.END .ED
|
ZS.END .ED
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* File Header (16 Bytes)
|
* File Header (16 Bytes)
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.START cld
|
CS.START cld
|
||||||
jmp (.1,x)
|
jmp (.1,x)
|
||||||
.DA #$61 6502,Level 1 (65c02)
|
.DA #$61 6502,Level 1 (65c02)
|
||||||
.DA #1 BIN Layout Version 1
|
.DA #1 BIN Layout Version 1
|
||||||
.DA #0 S.PS.F.EVENT
|
.DA #0 S.PS.F.EVENT
|
||||||
.DA #0
|
.DA #0
|
||||||
.DA CS.END-CS.START Code Size (without Constants)
|
.DA CS.END-CS.START Code Size (without Constants)
|
||||||
.DA DS.END-DS.START Data Segment Size
|
.DA DS.END-DS.START Data Segment Size
|
||||||
.DA #16 Stack Size
|
.DA #16 Stack Size
|
||||||
.DA #ZS.END-ZS.START Zero Page Size
|
.DA #ZS.END-ZS.START Zero Page Size
|
||||||
.DA 0
|
.DA 0
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* Relocation Table
|
* Relocation Table
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.1 .DA CS.INIT
|
.1 .DA CS.INIT
|
||||||
.DA CS.RUN
|
.DA CS.RUN
|
||||||
.DA CS.DOEVENT
|
.DA CS.DOEVENT
|
||||||
.DA CS.QUIT
|
.DA CS.QUIT
|
||||||
L.MSG.USAGE .DA MSG.USAGE
|
L.MSG.USAGE .DA MSG.USAGE
|
||||||
L.MSG.CRLF .DA MSG.CRLF
|
L.MSG.CRLF .DA MSG.CRLF
|
||||||
L.MSG.OFFSET .DA MSG.OFFSET
|
L.MSG.OFFSET .DA MSG.OFFSET
|
||||||
L.MSG.HEXBYTE .DA MSG.HEXBYTE
|
L.MSG.HEXBYTE .DA MSG.HEXBYTE
|
||||||
.DA 0
|
.DA 0
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.INIT clc
|
CS.INIT clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN stz bPipe
|
CS.RUN stz bPipe
|
||||||
stz bIsTTY
|
stz bIsTTY
|
||||||
jsr CS.RUN.ISATTY
|
jsr CS.RUN.ISATTY
|
||||||
jsr CS.RUN.CheckArgs
|
jsr CS.RUN.CheckArgs
|
||||||
bcs CS.RUN.LOOP.RTS
|
bcs CS.RUN.LOOP.RTS
|
||||||
|
|
||||||
stz ByteCount
|
stz ByteCount
|
||||||
stz ByteCount+1
|
stz ByteCount+1
|
||||||
stz ByteCount+2
|
stz ByteCount+2
|
||||||
|
|
||||||
CS.RUN.LOOP lda bPipe If reading from pipe
|
CS.RUN.LOOP lda bPipe If reading from pipe
|
||||||
bne .2 No ^C/^S handling
|
bne .2 No ^C/^S handling
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
ldy #S.PS.hStdIn
|
||||||
lda (pPS),y
|
lda (pPS),y
|
||||||
>SYSCALL FEOF
|
>SYSCALL FEOF
|
||||||
bcs .9 I/O Error
|
bcs .9 I/O Error
|
||||||
|
|
||||||
tay
|
tay
|
||||||
bne .1 No char
|
bne .1 No char
|
||||||
|
|
||||||
>SYSCALL GetChar
|
>SYSCALL GetChar
|
||||||
bcs .9 I/O error
|
bcs .9 I/O error
|
||||||
cmp #$03 Ctrl-C
|
cmp #$03 Ctrl-C
|
||||||
beq .9
|
beq .9
|
||||||
cmp #$13 Ctrl-S
|
cmp #$13 Ctrl-S
|
||||||
bne .1
|
bne .1
|
||||||
|
|
||||||
|
lda bPause
|
||||||
|
eor #$ff
|
||||||
|
sta bPause
|
||||||
|
bne CS.RUN.LOOP
|
||||||
|
|
||||||
|
.1 lda bPause
|
||||||
|
bne CS.RUN.LOOP
|
||||||
|
|
||||||
|
.2 >SLEEP
|
||||||
|
|
||||||
|
lda hFile
|
||||||
|
>SYSCALL GetC
|
||||||
|
bcs .7
|
||||||
|
|
||||||
|
jsr CS.RUN.PRINTBYTE
|
||||||
|
bra CS.RUN.LOOP
|
||||||
|
|
||||||
|
.7 cmp #MLI.E.EOF
|
||||||
|
bne .9
|
||||||
|
|
||||||
|
jsr CS.RUN.FINISHUP
|
||||||
|
|
||||||
|
.8 lda #0 Exit with no Error
|
||||||
|
|
||||||
|
.9 sec
|
||||||
|
CS.RUN.LOOP.RTS rts
|
||||||
|
*--------------------------------------
|
||||||
|
CS.RUN.CheckArgs
|
||||||
|
jsr CS.RUN.NextArg
|
||||||
|
bcs .4
|
||||||
|
|
||||||
|
lda (ZPPtr1)
|
||||||
|
cmp #'-'
|
||||||
|
beq .1
|
||||||
|
|
||||||
|
.11 lda hFile
|
||||||
|
bne .97
|
||||||
|
|
||||||
|
>LDYA ZPPtr1
|
||||||
|
jsr CS.RUN.OPEN
|
||||||
|
bcs .9
|
||||||
|
|
||||||
|
sta hFile
|
||||||
|
bra CS.RUN.CheckArgs
|
||||||
|
|
||||||
|
.1 ldy #1
|
||||||
|
lda (ZPPtr1),y
|
||||||
|
|
||||||
|
ldx #OptionList.Cnt-1
|
||||||
|
|
||||||
|
.2 cmp OptionList,x
|
||||||
|
beq .3
|
||||||
|
|
||||||
|
dex
|
||||||
|
bpl .2
|
||||||
|
|
||||||
|
bra .97
|
||||||
|
|
||||||
|
.3 txa
|
||||||
|
lsr
|
||||||
|
beq .98
|
||||||
|
|
||||||
|
tax
|
||||||
|
lda #$80
|
||||||
|
sta bDummy-1,x
|
||||||
|
bra CS.RUN.CheckArgs
|
||||||
|
|
||||||
lda bPause
|
.4 lda hFile
|
||||||
eor #$ff
|
bne .80
|
||||||
sta bPause
|
|
||||||
bne CS.RUN.LOOP
|
ldy #S.PS.hStdIn
|
||||||
|
lda (pPS),y
|
||||||
.1 lda bPause
|
tax
|
||||||
bne CS.RUN.LOOP
|
|
||||||
|
lda hFDs-1,x
|
||||||
.2 >SLEEP
|
>SYSCALL GetMemPtr
|
||||||
|
>STYA ZPPtr1
|
||||||
lda hFile
|
lda (ZPPtr1)
|
||||||
>SYSCALL GetC
|
cmp #S.FD.T.PIPE
|
||||||
bcs .7
|
bne .97
|
||||||
|
|
||||||
jsr CS.RUN.PRINTBYTE
|
ldy #S.PS.hStdIn
|
||||||
bra CS.RUN.LOOP
|
lda (pPS),y
|
||||||
|
sta hFile
|
||||||
.7 cmp #MLI.E.EOF
|
inc bPipe
|
||||||
bne .9
|
|
||||||
|
.80 >LDYAI 256
|
||||||
jsr CS.RUN.FINISHUP
|
>SYSCALL GetMem
|
||||||
|
bcs .9
|
||||||
.8 lda #0 Exit with no Error
|
|
||||||
|
>STYA ZPBufPtr
|
||||||
.9 sec
|
stx hBuf
|
||||||
CS.RUN.LOOP.RTS rts
|
|
||||||
|
* clc
|
||||||
|
|
||||||
|
.9 rts
|
||||||
|
|
||||||
|
.97 lda #E.SYN
|
||||||
|
|
||||||
|
.98 pha
|
||||||
|
>PUSHW L.MSG.USAGE
|
||||||
|
>PUSHBI 0
|
||||||
|
>SYSCALL PrintF
|
||||||
|
pla
|
||||||
|
sec
|
||||||
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.CheckArgs jsr CS.RUN.NextArg
|
CS.RUN.NextArg inc ArgIndex
|
||||||
bcs .4
|
lda ArgIndex
|
||||||
|
>SYSCALL ArgV
|
||||||
|
bcs .9
|
||||||
|
|
||||||
lda (ZPPtr1)
|
>STYA ZPPtr1
|
||||||
cmp #'-'
|
|
||||||
beq .1
|
|
||||||
|
|
||||||
.11 lda hFile
|
.9 rts
|
||||||
bne .97
|
|
||||||
|
|
||||||
>LDYA ZPPtr1
|
|
||||||
jsr CS.RUN.OPEN
|
|
||||||
bcs .9
|
|
||||||
|
|
||||||
sta hFile
|
|
||||||
bra CS.RUN.CheckArgs
|
|
||||||
|
|
||||||
.1 ldy #1
|
|
||||||
lda (ZPPtr1),y
|
|
||||||
|
|
||||||
ldx #OptionList.Cnt-1
|
|
||||||
|
|
||||||
.2 cmp OptionList,x
|
|
||||||
beq .3
|
|
||||||
|
|
||||||
dex
|
|
||||||
bpl .2
|
|
||||||
|
|
||||||
bra .97
|
|
||||||
|
|
||||||
.3 txa
|
|
||||||
lsr
|
|
||||||
beq .98
|
|
||||||
|
|
||||||
tax
|
|
||||||
lda #$80
|
|
||||||
sta bDummy-1,x
|
|
||||||
bra CS.RUN.CheckArgs
|
|
||||||
|
|
||||||
.4 lda hFile
|
|
||||||
bne .80
|
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
|
||||||
lda (pPS),y
|
|
||||||
tax
|
|
||||||
|
|
||||||
lda hFDs-1,x
|
|
||||||
>SYSCALL GetMemPtr
|
|
||||||
>STYA ZPPtr1
|
|
||||||
lda (ZPPtr1)
|
|
||||||
cmp #S.FD.T.PIPE
|
|
||||||
bne .97
|
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
|
||||||
lda (pPS),y
|
|
||||||
sta hFile
|
|
||||||
inc bPipe
|
|
||||||
|
|
||||||
.80 >LDYAI 256
|
|
||||||
>SYSCALL GetMem
|
|
||||||
bcs .9
|
|
||||||
|
|
||||||
>STYA ZPBufPtr
|
|
||||||
stx hBuf
|
|
||||||
|
|
||||||
* clc
|
|
||||||
|
|
||||||
.9 rts
|
|
||||||
|
|
||||||
.97 lda #E.SYN
|
|
||||||
|
|
||||||
.98 pha
|
|
||||||
>PUSHW L.MSG.USAGE
|
|
||||||
>PUSHBI 0
|
|
||||||
>SYSCALL PrintF
|
|
||||||
pla
|
|
||||||
sec
|
|
||||||
rts
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.NextArg inc ArgIndex
|
CS.RUN.OPEN >PUSHYA
|
||||||
lda ArgIndex
|
>PUSHBI O.RDONLY+O.TEXT
|
||||||
>SYSCALL ArgV
|
>PUSHBI S.FI.T.TXT
|
||||||
bcs .9
|
>PUSHWZ Aux type
|
||||||
|
>SYSCALL FOpen
|
||||||
>STYA ZPPtr1
|
bcs .9
|
||||||
|
sta hFile
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.OPEN >PUSHYA
|
CS.RUN.ISATTY ldy #S.PS.hStdOut
|
||||||
>PUSHBI O.RDONLY+O.TEXT
|
lda (pPS),y
|
||||||
>PUSHBI S.FI.T.TXT
|
tax
|
||||||
>PUSHWZ Aux type
|
lda hFDs-1,x
|
||||||
>SYSCALL FOpen
|
>SYSCALL GetMemPtr
|
||||||
bcs .9
|
>STYA ZPPtr1
|
||||||
sta hFile
|
lda (ZPPtr1)
|
||||||
.9 rts
|
beq .9
|
||||||
|
inc bIsTTY
|
||||||
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.ISATTY ldy #S.PS.hStdOut
|
CS.QUIT lda hFile
|
||||||
lda (pPS),y
|
beq .1
|
||||||
tax
|
>SYSCALL FClose
|
||||||
lda hFDs-1,x
|
.1 lda hBuf
|
||||||
>SYSCALL GetMemPtr
|
beq .8
|
||||||
>STYA ZPPtr1
|
>SYSCALL FreeMem
|
||||||
lda (ZPPtr1)
|
.8 clc
|
||||||
beq .9
|
rts
|
||||||
inc bIsTTY
|
|
||||||
.9 rts
|
|
||||||
*--------------------------------------
|
|
||||||
CS.QUIT lda hFile
|
|
||||||
beq .1
|
|
||||||
>SYSCALL FClose
|
|
||||||
.1 lda hBuf
|
|
||||||
beq .8
|
|
||||||
>SYSCALL FreeMem
|
|
||||||
.8 clc
|
|
||||||
rts
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.PRINTBYTE
|
CS.RUN.PRINTBYTE
|
||||||
pha Char is in A
|
pha Char is in A
|
||||||
|
@ -330,18 +331,18 @@ CS.DOEVENT sec
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.END
|
CS.END
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
OptionList .AS "x"
|
OptionList .AS "x"
|
||||||
OptionList.Cnt .EQ *-OptionList
|
OptionList.Cnt .EQ *-OptionList
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
MSG.USAGE .AS "Usage : OD <File> or CMD|OD"
|
MSG.USAGE .CS "Usage : OD <File> or CMD|OD"
|
||||||
MSG.CRLF .AZ "\r\n"
|
MSG.CRLF .CZ "\r\n"
|
||||||
MSG.OFFSET .AZ "%h%h%h "
|
MSG.OFFSET .CZ "%h%h%h "
|
||||||
MSG.HEXBYTE .AZ "%h "
|
MSG.HEXBYTE .CZ "%h "
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.DUMMY
|
.DUMMY
|
||||||
.OR 0
|
.OR 0
|
||||||
DS.START
|
DS.START
|
||||||
DS.END .ED
|
DS.END .ED
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
MAN
|
MAN
|
||||||
SAVE usr/src/bin/od.s
|
SAVE usr/src/bin/od.s
|
||||||
|
|
556
BIN/SED.S.txt
556
BIN/SED.S.txt
|
@ -1,383 +1,383 @@
|
||||||
NEW
|
NEW
|
||||||
AUTO 3,1
|
AUTO 3,1
|
||||||
.LIST OFF
|
.LIST OFF
|
||||||
.OP 65C02
|
.OP 65C02
|
||||||
.OR $2000
|
.OR $2000
|
||||||
.TF bin/sed
|
.TF bin/sed
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.INB inc/macros.i
|
.INB inc/macros.i
|
||||||
.INB inc/a2osx.i
|
.INB inc/a2osx.i
|
||||||
.INB inc/kernel.i
|
.INB inc/kernel.i
|
||||||
.INB inc/mli.i
|
.INB inc/mli.i
|
||||||
.INB inc/mli.e.i
|
.INB inc/mli.e.i
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.DUMMY
|
.DUMMY
|
||||||
.OR ZPBIN
|
.OR ZPBIN
|
||||||
ZS.START
|
ZS.START
|
||||||
ArgIndex .BS 1
|
ArgIndex .BS 1
|
||||||
ArgPattern .BS 1
|
ArgPattern .BS 1
|
||||||
ZPPtr1 .BS 2
|
ZPPtr1 .BS 2
|
||||||
ZPPatternPtr .BS 2
|
ZPPatternPtr .BS 2
|
||||||
ZPBufPtr .BS 2
|
ZPBufPtr .BS 2
|
||||||
hFile .BS 1
|
hFile .BS 1
|
||||||
hBuf .BS 1
|
hBuf .BS 1
|
||||||
LineNum .BS 2
|
LineNum .BS 2
|
||||||
char .BS 1
|
char .BS 1
|
||||||
delimiter .BS 1
|
delimiter .BS 1
|
||||||
replaceidx .BS 1
|
replaceidx .BS 1
|
||||||
|
|
||||||
bIgnoreCase .BS 1
|
bIgnoreCase .BS 1
|
||||||
|
|
||||||
ZS.END .ED
|
ZS.END .ED
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* File Header (16 Bytes)
|
* File Header (16 Bytes)
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.START cld
|
CS.START cld
|
||||||
jmp (.1,x)
|
jmp (.1,x)
|
||||||
.DA #$61 6502,Level 1 (65c02)
|
.DA #$61 6502,Level 1 (65c02)
|
||||||
.DA #1 BIN Layout Version 1
|
.DA #1 BIN Layout Version 1
|
||||||
.DA #0 S.PS.F.EVENT
|
.DA #0 S.PS.F.EVENT
|
||||||
.DA #0
|
.DA #0
|
||||||
.DA CS.END-CS.START Code Size (without Constants)
|
.DA CS.END-CS.START Code Size (without Constants)
|
||||||
.DA DS.END-DS.START Data Segment Size
|
.DA DS.END-DS.START Data Segment Size
|
||||||
.DA #16 Stack Size
|
.DA #16 Stack Size
|
||||||
.DA #ZS.END-ZS.START Zero Page Size
|
.DA #ZS.END-ZS.START Zero Page Size
|
||||||
.DA 0
|
.DA 0
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* Relocation Table
|
* Relocation Table
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.1 .DA CS.INIT
|
.1 .DA CS.INIT
|
||||||
.DA CS.RUN
|
.DA CS.RUN
|
||||||
.DA CS.DOEVENT
|
.DA CS.DOEVENT
|
||||||
.DA CS.QUIT
|
.DA CS.QUIT
|
||||||
L.MSG.USAGE .DA MSG.USAGE
|
L.MSG.USAGE .DA MSG.USAGE
|
||||||
L.MSG.CRLF .DA MSG.CRLF
|
L.MSG.CRLF .DA MSG.CRLF
|
||||||
.DA 0
|
.DA 0
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.INIT clc
|
CS.INIT clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN jsr CS.RUN.CheckArgs
|
CS.RUN jsr CS.RUN.CheckArgs
|
||||||
bcs CS.RUN.LOOP.RTS
|
bcs CS.RUN.LOOP.RTS
|
||||||
|
|
||||||
stz LineNum
|
stz LineNum
|
||||||
stz LineNum+1
|
stz LineNum+1
|
||||||
|
|
||||||
CS.RUN.LOOP >SLEEP
|
CS.RUN.LOOP >SLEEP
|
||||||
|
|
||||||
>PUSHB hFile
|
>PUSHB hFile
|
||||||
>PUSHW ZPBufPtr
|
>PUSHW ZPBufPtr
|
||||||
>PUSHWI 256
|
>PUSHWI 256
|
||||||
>SYSCALL FGetS
|
>SYSCALL FGetS
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
inc LineNum
|
inc LineNum
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
inc LineNum+1
|
inc LineNum+1
|
||||||
|
|
||||||
.2 jsr CS.RUN.PRINT
|
.2 jsr CS.RUN.PRINT
|
||||||
|
|
||||||
bcc CS.RUN.LOOP
|
bcc CS.RUN.LOOP
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.9 cmp #MLI.E.EOF
|
.9 cmp #MLI.E.EOF
|
||||||
bne .99
|
bne .99
|
||||||
|
|
||||||
lda #0 Exit with no Error
|
lda #0 Exit with no Error
|
||||||
|
|
||||||
.99 sec
|
.99 sec
|
||||||
CS.RUN.LOOP.RTS rts
|
CS.RUN.LOOP.RTS rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.CheckArgs
|
CS.RUN.CheckArgs
|
||||||
jsr CS.RUN.NextArg
|
jsr CS.RUN.NextArg
|
||||||
bcs .4
|
bcs .4
|
||||||
|
|
||||||
lda (ZPPtr1)
|
lda (ZPPtr1)
|
||||||
cmp #'-'
|
cmp #'-'
|
||||||
beq .1
|
beq .1
|
||||||
|
|
||||||
lda ArgPattern
|
lda ArgPattern
|
||||||
bne .11
|
bne .11
|
||||||
|
|
||||||
lda ArgIndex
|
lda ArgIndex
|
||||||
sta ArgPattern
|
sta ArgPattern
|
||||||
>LDYA ZPPtr1
|
>LDYA ZPPtr1
|
||||||
>STYA ZPPatternPtr
|
>STYA ZPPatternPtr
|
||||||
jsr CS.RUN.SEDParser
|
jsr CS.RUN.SEDParser
|
||||||
bcs .97
|
bcs .97
|
||||||
bra CS.RUN.CheckArgs
|
bra CS.RUN.CheckArgs
|
||||||
|
|
||||||
.11 lda hFile
|
.11 lda hFile
|
||||||
bne .97
|
bne .97
|
||||||
|
|
||||||
>LDYA ZPPtr1
|
>LDYA ZPPtr1
|
||||||
jsr CS.RUN.OPEN
|
jsr CS.RUN.OPEN
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
sta hFile
|
sta hFile
|
||||||
bra CS.RUN.CheckArgs
|
bra CS.RUN.CheckArgs
|
||||||
|
|
||||||
.1 ldy #1
|
.1 ldy #1
|
||||||
lda (ZPPtr1),y
|
lda (ZPPtr1),y
|
||||||
|
|
||||||
ldx #OptionList.Cnt-1
|
ldx #OptionList.Cnt-1
|
||||||
|
|
||||||
.2 cmp OptionList,x
|
.2 cmp OptionList,x
|
||||||
beq .3
|
beq .3
|
||||||
|
|
||||||
dex
|
dex
|
||||||
bpl .2
|
bpl .2
|
||||||
|
|
||||||
bra .97
|
bra .97
|
||||||
|
|
||||||
.3 txa
|
.3 txa
|
||||||
lsr
|
lsr
|
||||||
beq .98
|
beq .98
|
||||||
|
|
||||||
tax
|
tax
|
||||||
lda #$80
|
lda #$80
|
||||||
sta bIgnoreCase-1,x
|
sta bIgnoreCase-1,x
|
||||||
bra CS.RUN.CheckArgs
|
bra CS.RUN.CheckArgs
|
||||||
|
|
||||||
.4 lda hFile
|
.4 lda hFile
|
||||||
bne .80
|
bne .80
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
ldy #S.PS.hStdIn
|
||||||
lda (pPS),y
|
lda (pPS),y
|
||||||
tax
|
tax
|
||||||
|
|
||||||
lda hFDs-1,x
|
lda hFDs-1,x
|
||||||
>SYSCALL GetMemPtr
|
>SYSCALL GetMemPtr
|
||||||
>STYA ZPPtr1
|
>STYA ZPPtr1
|
||||||
lda (ZPPtr1)
|
lda (ZPPtr1)
|
||||||
cmp #S.FD.T.PIPE
|
cmp #S.FD.T.PIPE
|
||||||
bne .97
|
bne .97
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
ldy #S.PS.hStdIn
|
||||||
lda (pPS),y
|
lda (pPS),y
|
||||||
sta hFile
|
sta hFile
|
||||||
|
|
||||||
.80 >LDYAI 256
|
.80 >LDYAI 256
|
||||||
>SYSCALL GetMem
|
>SYSCALL GetMem
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
>STYA ZPBufPtr
|
>STYA ZPBufPtr
|
||||||
stx hBuf
|
stx hBuf
|
||||||
|
|
||||||
* clc
|
* clc
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
|
|
||||||
.97 lda #E.SYN
|
.97 lda #E.SYN
|
||||||
|
|
||||||
.98 pha
|
.98 pha
|
||||||
>PUSHW L.MSG.USAGE
|
>PUSHW L.MSG.USAGE
|
||||||
>PUSHBI 0
|
>PUSHBI 0
|
||||||
>SYSCALL PrintF
|
>SYSCALL PrintF
|
||||||
pla
|
pla
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.NextArg inc ArgIndex
|
CS.RUN.NextArg inc ArgIndex
|
||||||
lda ArgIndex
|
lda ArgIndex
|
||||||
>SYSCALL ArgV
|
>SYSCALL ArgV
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
>STYA ZPPtr1
|
>STYA ZPPtr1
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.SEDParser
|
|
||||||
* On entry, the expression is in ZPPatternPtr
|
* On entry, the expression is in ZPPatternPtr
|
||||||
* We are looking for "s/search string/replace string/"
|
* We are looking for "s/search string/replace string/"
|
||||||
* The '/' delimiter can be any char
|
* The '/' delimiter can be any char
|
||||||
* On exit. ZPPatternPtr points to delimiter-terminated search string,
|
* On exit. ZPPatternPtr points to delimiter-terminated search string,
|
||||||
* replaceidx contains the offset to the start of replacement str
|
* replace idx contains the offset to the start of replacement str
|
||||||
|
|
||||||
stz LineNum Reusing this as cntr
|
CS.RUN.SEDParser
|
||||||
|
stz LineNum Reusing this as cntr
|
||||||
|
|
||||||
lda (ZPPatternPtr)
|
lda (ZPPatternPtr)
|
||||||
cmp #'s' Substitute cmd
|
cmp #'s' Substitute cmd
|
||||||
bne .8 If not, error
|
bne .8 If not, error
|
||||||
|
|
||||||
ldy #$01 Delimiter char
|
ldy #$01 Delimiter char
|
||||||
lda (ZPPatternPtr),y
|
lda (ZPPatternPtr),y
|
||||||
sta delimiter Stash for later
|
sta delimiter Stash for later
|
||||||
|
|
||||||
.2 iny
|
.2 iny
|
||||||
lda (ZPPatternPtr),y
|
lda (ZPPatternPtr),y
|
||||||
beq .4 End of string
|
beq .4 End of string
|
||||||
cmp delimiter Is it delimiter?
|
cmp delimiter Is it delimiter?
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
inc LineNum Keep count
|
inc LineNum Keep count
|
||||||
lda LineNum
|
lda LineNum
|
||||||
cmp #$01 Second delim
|
cmp #$01 Second delim
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
sty replaceidx
|
sty replaceidx
|
||||||
bra .2
|
bra .2
|
||||||
|
|
||||||
.4 lda LineNum Check # of delims
|
.4 lda LineNum Check # of delims
|
||||||
cmp #$02
|
cmp #$02
|
||||||
bne .8
|
bne .8
|
||||||
|
|
||||||
inc ZPPatternPtr Eat 's/'
|
inc ZPPatternPtr Eat 's/'
|
||||||
bne .5
|
bne .5
|
||||||
inc ZPPatternPtr+1
|
inc ZPPatternPtr+1
|
||||||
.5 inc ZPPatternPtr
|
.5 inc ZPPatternPtr
|
||||||
bne .7
|
bne .7
|
||||||
inc ZPPatternPtr+1
|
inc ZPPatternPtr+1
|
||||||
|
|
||||||
.7 clc
|
.7 clc
|
||||||
rts No error return
|
rts No error return
|
||||||
|
|
||||||
.8 sec
|
.8 sec
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.OPEN >PUSHYA
|
CS.RUN.OPEN >PUSHYA
|
||||||
>PUSHBI O.RDONLY+O.TEXT
|
>PUSHBI O.RDONLY+O.TEXT
|
||||||
>PUSHBI S.FI.T.TXT
|
>PUSHBI S.FI.T.TXT
|
||||||
>PUSHWZ Aux type
|
>PUSHWZ Aux type
|
||||||
>SYSCALL FOpen
|
>SYSCALL FOpen
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
sta hFile
|
sta hFile
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.PRINT >LDYA ZPBufPtr
|
CS.RUN.PRINT >LDYA ZPBufPtr
|
||||||
>STYA ZPPtr1
|
>STYA ZPPtr1
|
||||||
|
|
||||||
lda (ZPPtr1) If null first time
|
lda (ZPPtr1) If null first time
|
||||||
beq .8
|
beq .8
|
||||||
|
|
||||||
.1 lda (ZPPtr1)
|
.1 lda (ZPPtr1)
|
||||||
beq .7 EOL. No match.
|
beq .7 EOL. No match.
|
||||||
|
|
||||||
ldy #$ff
|
ldy #$ff
|
||||||
|
|
||||||
.2 iny
|
.2 iny
|
||||||
lda (ZPPtr1),y
|
lda (ZPPtr1),y
|
||||||
bne .3
|
bne .3
|
||||||
|
|
||||||
lda (ZPPatternPtr),y EOL
|
lda (ZPPatternPtr),y EOL
|
||||||
cmp delimiter
|
cmp delimiter
|
||||||
bne .7 Not end of pattern
|
bne .7 Not end of pattern
|
||||||
* No match.
|
* No match.
|
||||||
|
|
||||||
.3 lda (ZPPatternPtr),y
|
.3 lda (ZPPatternPtr),y
|
||||||
cmp delimiter
|
cmp delimiter
|
||||||
beq .5 Match
|
beq .5 Match
|
||||||
|
|
||||||
jsr CS.RUN.toUpper
|
jsr CS.RUN.toUpper
|
||||||
sta char
|
sta char
|
||||||
lda (ZPPtr1),y
|
lda (ZPPtr1),y
|
||||||
jsr CS.RUN.toUpper
|
jsr CS.RUN.toUpper
|
||||||
cmp char
|
cmp char
|
||||||
beq .2
|
beq .2
|
||||||
|
|
||||||
bra .6 No match
|
bra .6 No match
|
||||||
|
|
||||||
* Found a match
|
* Found a match
|
||||||
.5 jsr CS.RUN.GotMatch
|
.5 jsr CS.RUN.GotMatch
|
||||||
bra .1
|
bra .1
|
||||||
|
|
||||||
* Mismatch with pattern, keep going
|
* Mismatch with pattern, keep going
|
||||||
.6 jsr CS.RUN.NoMatch
|
.6 jsr CS.RUN.NoMatch
|
||||||
bra .1
|
bra .1
|
||||||
|
|
||||||
* Hit EOL but not end of pattern, return
|
* Hit EOL but not end of pattern, return
|
||||||
.7 jsr CS.RUN.NoMatch
|
.7 jsr CS.RUN.NoMatch
|
||||||
.8 lda #C.CR
|
.8 lda #C.CR
|
||||||
>SYSCALL PutChar
|
>SYSCALL PutChar
|
||||||
lda #C.LF
|
lda #C.LF
|
||||||
>SYSCALL PutChar
|
>SYSCALL PutChar
|
||||||
|
|
||||||
.9 clc
|
.9 clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.GotMatch phy
|
CS.RUN.GotMatch phy
|
||||||
ldy replaceidx
|
ldy replaceidx
|
||||||
dey
|
dey
|
||||||
.1 lda (ZPPatternPtr),y
|
.1 lda (ZPPatternPtr),y
|
||||||
cmp delimiter
|
cmp delimiter
|
||||||
beq .5
|
beq .5
|
||||||
phy
|
phy
|
||||||
>SYSCALL PutChar
|
>SYSCALL PutChar
|
||||||
ply
|
ply
|
||||||
iny
|
iny
|
||||||
bra .1
|
bra .1
|
||||||
|
|
||||||
.5 ply
|
.5 ply
|
||||||
tya Advance ZPPtr1 by Y
|
tya Advance ZPPtr1 by Y
|
||||||
clc
|
clc
|
||||||
adc ZPPtr1
|
adc ZPPtr1
|
||||||
sta ZPPtr1
|
sta ZPPtr1
|
||||||
lda #$00
|
lda #$00
|
||||||
adc ZPPtr1+1
|
adc ZPPtr1+1
|
||||||
sta ZPPtr1+1
|
sta ZPPtr1+1
|
||||||
ldy #$00
|
ldy #$00
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.NoMatch lda (ZPPtr1) Print ZPPtr1->ZPPtr1+Y
|
CS.RUN.NoMatch lda (ZPPtr1) Print ZPPtr1->ZPPtr1+Y
|
||||||
phy
|
phy
|
||||||
>SYSCALL PutChar
|
>SYSCALL PutChar
|
||||||
ply
|
ply
|
||||||
inc ZPPtr1
|
inc ZPPtr1
|
||||||
bne .2
|
bne .2
|
||||||
inc ZPPtr1+1
|
inc ZPPtr1+1
|
||||||
.2 dey
|
.2 dey
|
||||||
cpy #$ff
|
cpy #$ff
|
||||||
bne CS.RUN.NoMatch
|
bne CS.RUN.NoMatch
|
||||||
ldy #$00
|
ldy #$00
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.toUpper bit bIgnoreCase
|
CS.RUN.toUpper bit bIgnoreCase
|
||||||
bpl .9
|
bpl .9
|
||||||
|
|
||||||
cmp #'a'
|
cmp #'a'
|
||||||
bcc .9
|
bcc .9
|
||||||
|
|
||||||
cmp #'z'+1
|
cmp #'z'+1
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
eor #$20
|
eor #$20
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.QUIT lda hFile
|
CS.QUIT lda hFile
|
||||||
beq .1
|
beq .1
|
||||||
|
|
||||||
>SYSCALL FClose
|
>SYSCALL FClose
|
||||||
|
|
||||||
.1 lda hBuf
|
.1 lda hBuf
|
||||||
beq .8
|
beq .8
|
||||||
|
|
||||||
>SYSCALL FreeMem
|
>SYSCALL FreeMem
|
||||||
|
|
||||||
.8 clc
|
.8 clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.DOEVENT sec
|
CS.DOEVENT sec
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.END
|
CS.END
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
OptionList .AS "HhIi"
|
OptionList .AS "HhIi"
|
||||||
OptionList.Cnt .EQ *-OptionList
|
OptionList.Cnt .EQ *-OptionList
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
MSG.USAGE .AS "Usage : SED [-I] s/pattern/replacement/ <File>\r\n"
|
MSG.USAGE .CS "Usage : SED [-I] s/pattern/replacement/ <File>\r\n"
|
||||||
.AS " or : CMD|SED [-I] s/pattern/replacement/\r\n"
|
.CS " or : CMD|SED [-I] s/pattern/replacement/\r\n"
|
||||||
.AS " -I : Ignore Case"
|
.CS " -I : Ignore Case"
|
||||||
MSG.CRLF .AZ "\r\n"
|
MSG.CRLF .CZ "\r\n"
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.DUMMY
|
.DUMMY
|
||||||
.OR 0
|
.OR 0
|
||||||
DS.START
|
DS.START
|
||||||
DS.END .ED
|
DS.END .ED
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
MAN
|
MAN
|
||||||
SAVE usr/src/bin/od.s
|
SAVE usr/src/bin/sed.s
|
||||||
ASM
|
ASM
|
||||||
|
|
|
@ -12,19 +12,18 @@ CL.Init >LDYAI 256
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CL.PrintPrompt >PUSHW L.PS1
|
CL.PrintPrompt >PUSHW L.PS1
|
||||||
>PUSHWZ
|
>PUSHW ZPCLBuf
|
||||||
>SYSCALL Expand
|
>SYSCALL Expand
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
phx
|
>LDYA ZPCLBuf
|
||||||
|
jsr IO.EscOutYA
|
||||||
jsr PrintYANoCR
|
|
||||||
|
lda #0
|
||||||
pla
|
sta (ZPCLBuf)
|
||||||
>SYSCALL FreeMem
|
|
||||||
|
|
||||||
.1 >LDYA L.MSG.PROMPT
|
.1 >LDYA L.MSG.PROMPT
|
||||||
jsr PrintYANoCR
|
jsr IO.OutYA
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CL.READN0A tax
|
CL.READN0A tax
|
||||||
|
@ -281,7 +280,7 @@ CL.FS >LDA.G CL.Ptr
|
||||||
bmi CL.BS.8
|
bmi CL.BS.8
|
||||||
|
|
||||||
CL.FS.OUT >LDYA L.MSG.FS
|
CL.FS.OUT >LDYA L.MSG.FS
|
||||||
jmp PrintYANoCR
|
jmp IO.OutYA
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CL.CLR >STZ.G HIS.Ptr
|
CL.CLR >STZ.G HIS.Ptr
|
||||||
|
|
||||||
|
@ -311,7 +310,7 @@ CL.CLR.1 lda (ZPCLBuf)
|
||||||
bne .3
|
bne .3
|
||||||
|
|
||||||
>LDYA ZPCLBuf
|
>LDYA ZPCLBuf
|
||||||
jsr PrintYANoCR
|
jsr IO.OutYA
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CL.Reset lda #0
|
CL.Reset lda #0
|
||||||
sta (ZPCLBuf)
|
sta (ZPCLBuf)
|
||||||
|
@ -336,6 +335,7 @@ CL.ReadReset lda #$ff
|
||||||
|
|
||||||
iny CL.bSilent
|
iny CL.bSilent
|
||||||
sta (pData),y
|
sta (pData),y
|
||||||
|
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
MAN
|
MAN
|
||||||
|
|
|
@ -331,7 +331,7 @@ CMD.SET.GET >PUSHW ZPVarNamePtr
|
||||||
CMD.SET.RTS rts
|
CMD.SET.RTS rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CMD.SET.EXEC jsr CORE.ArgV.NextChar skip "`"
|
CMD.SET.EXEC jsr CORE.ArgV.NextChar skip "`"
|
||||||
|
|
||||||
jsr IO.Pipe.Out
|
jsr IO.Pipe.Out
|
||||||
bcs CMD.SET.RTS
|
bcs CMD.SET.RTS
|
||||||
|
|
||||||
|
@ -368,45 +368,75 @@ CMD.DATE.PRINT >LDYA ZPCLBuf
|
||||||
>SYSCALL PutS
|
>SYSCALL PutS
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CMD.ECHO stz ZPPtr1 echo -N
|
CMD.ECHO stz ZPPtr1 echo -E
|
||||||
stz ZPPtr1+1 Token Cnt
|
stz ZPPtr1+1 echo -N
|
||||||
|
|
||||||
|
stz ZPPtr2 index in buffer
|
||||||
|
|
||||||
lda (ZPArgVBufPtr)
|
lda (ZPArgVBufPtr)
|
||||||
beq .7
|
beq .7
|
||||||
|
|
||||||
.1 jsr CMD.IsSwitch
|
.1 jsr CMD.IsSwitch
|
||||||
bcs .2
|
bcs .3
|
||||||
|
|
||||||
|
ldx #0
|
||||||
|
cmp #'E'
|
||||||
|
beq .2
|
||||||
|
|
||||||
|
inx
|
||||||
|
|
||||||
cmp #'N'
|
cmp #'N'
|
||||||
bne CMD.ECHO.CSYN
|
bne CMD.ECHO.CSYN
|
||||||
|
|
||||||
lda #$ff
|
.2 ror ZPPtr1,x
|
||||||
eor ZPPtr1
|
bra .6
|
||||||
sta ZPPtr1
|
|
||||||
bra .4
|
|
||||||
|
|
||||||
.2 lda ZPPtr1+1
|
.3 ldy ZPPtr2
|
||||||
beq .3
|
beq .4
|
||||||
|
|
||||||
lda #C.SPACE
|
lda #C.SPACE
|
||||||
>SYSCALL PutChar
|
sta (ZPCLBuf),y
|
||||||
|
inc ZPPtr2
|
||||||
|
|
||||||
.3 >LDYA ZPArgVBufPtr
|
.4 ldy #$ff
|
||||||
jsr PrintYANoCR
|
|
||||||
bcs .9
|
|
||||||
|
|
||||||
inc ZPPtr1+1
|
.5 iny
|
||||||
|
lda (ZPArgVBufPtr),y
|
||||||
|
beq .6
|
||||||
|
|
||||||
.4 jsr CORE.ArgV.Next
|
phy
|
||||||
|
ldy ZPPtr2
|
||||||
|
sta (ZPCLBuf),y
|
||||||
|
inc ZPPtr2
|
||||||
|
ply
|
||||||
|
bra .5
|
||||||
|
|
||||||
|
.6 jsr CORE.ArgV.Next
|
||||||
bne .1
|
bne .1
|
||||||
|
|
||||||
.7 bit ZPPtr1
|
.7 ldy ZPPtr2
|
||||||
|
|
||||||
|
bit ZPPtr1+1 -N
|
||||||
bmi .8
|
bmi .8
|
||||||
|
|
||||||
>LDYA L.MSG.ECHOCRLF
|
lda #C.CR
|
||||||
jmp PrintYANoCR
|
sta (ZPCLBuf),y
|
||||||
|
iny
|
||||||
|
lda #C.LF
|
||||||
|
sta (ZPCLBuf),y
|
||||||
|
iny
|
||||||
|
|
||||||
|
.8 lda #0
|
||||||
|
sta (ZPCLBuf),y
|
||||||
|
|
||||||
|
>LDYA ZPCLBuf
|
||||||
|
bit ZPPtr1
|
||||||
|
bmi .80
|
||||||
|
|
||||||
|
jmp IO.OutYA
|
||||||
|
|
||||||
|
.80 jmp IO.EscOutYA
|
||||||
|
|
||||||
.8 clc
|
|
||||||
.9 rts
|
.9 rts
|
||||||
|
|
||||||
CMD.ECHO.CSYN lda #E.CSYN
|
CMD.ECHO.CSYN lda #E.CSYN
|
||||||
|
@ -438,7 +468,7 @@ CMD.READ lda (ZPArgVBufPtr)
|
||||||
beq CMD.ECHO.CSYN
|
beq CMD.ECHO.CSYN
|
||||||
|
|
||||||
>LDYA ZPArgVBufPtr
|
>LDYA ZPArgVBufPtr
|
||||||
jsr PrintYANoCR
|
jsr IO.OutYA
|
||||||
bcs CMD.ECHO.RTS
|
bcs CMD.ECHO.RTS
|
||||||
bra .5
|
bra .5
|
||||||
|
|
||||||
|
@ -573,6 +603,7 @@ CMD.REN lda (ZPArgVBufPtr)
|
||||||
.4 iny
|
.4 iny
|
||||||
lda (ZPPtr1),y
|
lda (ZPPtr1),y
|
||||||
beq .5
|
beq .5
|
||||||
|
|
||||||
sta (ZPPtr2),y
|
sta (ZPPtr2),y
|
||||||
cmp #'/'
|
cmp #'/'
|
||||||
bne .4
|
bne .4
|
||||||
|
@ -800,7 +831,7 @@ CMD.BREAK jsr STK.GetCtx Get context in CORE.TestResult
|
||||||
|
|
||||||
cmp #C.CASE
|
cmp #C.CASE
|
||||||
bne .1
|
bne .1
|
||||||
|
|
||||||
txa
|
txa
|
||||||
bpl .8 already FALSE
|
bpl .8 already FALSE
|
||||||
|
|
||||||
|
@ -812,10 +843,10 @@ CMD.BREAK jsr STK.GetCtx Get context in CORE.TestResult
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
sta (pData),y IF=false to skip until FI
|
sta (pData),y IF=false to skip until FI
|
||||||
|
|
||||||
dey get parent context
|
dey get parent context
|
||||||
beq .9
|
beq .9
|
||||||
|
|
||||||
lda (pData),y
|
lda (pData),y
|
||||||
and #$3F
|
and #$3F
|
||||||
|
|
||||||
|
@ -824,7 +855,7 @@ CMD.BREAK jsr STK.GetCtx Get context in CORE.TestResult
|
||||||
|
|
||||||
.3 cmp #C.FOR
|
.3 cmp #C.FOR
|
||||||
bne .9
|
bne .9
|
||||||
|
|
||||||
.6 lda (pData),y
|
.6 lda (pData),y
|
||||||
|
|
||||||
.7 and #%01111111
|
.7 and #%01111111
|
||||||
|
|
|
@ -130,9 +130,9 @@ CORE.Run jsr IO.Reset
|
||||||
txa
|
txa
|
||||||
>STA.G CORE.hArgVBuf
|
>STA.G CORE.hArgVBuf
|
||||||
|
|
||||||
lda #bState.PipeIn
|
lda #bState.PipeIn+bState.PipeOut
|
||||||
trb bState
|
trb bState
|
||||||
|
*--------------------------------------
|
||||||
CORE.Run.1 >LDYA ZPInputBufPtr Save Actual ptr for looping
|
CORE.Run.1 >LDYA ZPInputBufPtr Save Actual ptr for looping
|
||||||
>STYA ZPInputCmdPtr
|
>STYA ZPInputCmdPtr
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ CORE.Run.4 >LDYA L.CMD internal command ?
|
||||||
jmp CORE.Run.Exit
|
jmp CORE.Run.Exit
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CORE.Run.5 jsr CORE.GetCharNB
|
CORE.Run.5 jsr CORE.GetCharNB
|
||||||
bcs .8 Nothing to skip
|
bcs CORE.Run.6 Nothing to skip
|
||||||
|
|
||||||
jsr CORE.IsEndCmd
|
jsr CORE.IsEndCmd
|
||||||
bcc .3
|
bcc .3
|
||||||
|
@ -254,7 +254,7 @@ CORE.Run.5 jsr CORE.GetCharNB
|
||||||
.9 lda #E.SYN
|
.9 lda #E.SYN
|
||||||
sec
|
sec
|
||||||
jmp CORE.Run.Exit
|
jmp CORE.Run.Exit
|
||||||
|
*--------------------------------------
|
||||||
.3 cmp #C.CR
|
.3 cmp #C.CR
|
||||||
beq .7
|
beq .7
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ CORE.Run.5 jsr CORE.GetCharNB
|
||||||
|
|
||||||
.50 lda #S.PS.F.HOLD Run in the background...
|
.50 lda #S.PS.F.HOLD Run in the background...
|
||||||
trb CORE.PSFlags
|
trb CORE.PSFlags
|
||||||
bra .8
|
bra CORE.Run.6
|
||||||
|
|
||||||
.6 jsr CORE.GetNextChar Skip '&&'
|
.6 jsr CORE.GetNextChar Skip '&&'
|
||||||
|
|
||||||
|
@ -296,58 +296,57 @@ CORE.Run.5 jsr CORE.GetCharNB
|
||||||
.60 jmp CORE.Run.1
|
.60 jmp CORE.Run.1
|
||||||
|
|
||||||
.7 jsr CORE.GetNextCharNB Skip EoL char
|
.7 jsr CORE.GetNextCharNB Skip EoL char
|
||||||
|
|
||||||
.8 lda #bState.PipeOut
|
|
||||||
trb bState
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CORE.Run.6 lda bState
|
CORE.Run.6 lda bState
|
||||||
bit #bState.PipeIn
|
bit #bState.PipeOut
|
||||||
beq .1
|
beq .3
|
||||||
|
|
||||||
jsr IO.Pipe.In
|
|
||||||
bcs CORE.Run.Exit
|
|
||||||
|
|
||||||
lda bState
|
|
||||||
|
|
||||||
.1 bit #bState.PipeOut
|
|
||||||
beq .7
|
|
||||||
|
|
||||||
jsr IO.Pipe.Out
|
jsr IO.Pipe.Out
|
||||||
bcs CORE.Run.Exit
|
bcs CORE.Run.Exit
|
||||||
|
|
||||||
lda #S.PS.F.HOLD Run in the background...
|
lda #S.PS.F.HOLD Run in the background...
|
||||||
trb CORE.PSFlags
|
trb CORE.PSFlags
|
||||||
|
|
||||||
lda #S.PS.F.CLOSEONX ...and close PIPE OUT on exit
|
lda #S.PS.F.CLOSEONX ...and child PS must close StdOut on exit
|
||||||
tsb CORE.PSFlags
|
tsb CORE.PSFlags
|
||||||
|
|
||||||
jsr CORE.ExecCmd
|
.3 jsr CORE.ExecCmd
|
||||||
|
|
||||||
php
|
bcs CORE.Run.Exit
|
||||||
pha
|
|
||||||
|
|
||||||
lda CORE.IntCmd $ff if external
|
|
||||||
eor #$80
|
|
||||||
asl if cc Was external...
|
|
||||||
|
|
||||||
jsr IO.Reset.OutC restore Output, NO close if EXTERNAL
|
|
||||||
|
|
||||||
lda bState
|
lda bState
|
||||||
and #bState.PipeIn
|
|
||||||
|
.5 bit #bState.PipeIn
|
||||||
beq .6
|
beq .6
|
||||||
|
|
||||||
jsr IO.Pop.In restore Input
|
jsr IO.Pop.In restore Input piping app must close it
|
||||||
|
|
||||||
|
lda #bState.PipeIn
|
||||||
|
trb bState
|
||||||
|
|
||||||
.6 pla
|
lda bState
|
||||||
plp
|
|
||||||
|
.6 bit #bState.PipeOut
|
||||||
|
beq .7
|
||||||
|
|
||||||
|
jsr IO.Pipe.In Set previous Pipe Out to StdIn for next CMD
|
||||||
bcs CORE.Run.Exit
|
bcs CORE.Run.Exit
|
||||||
|
|
||||||
lda #bState.PipeIn
|
lda #bState.PipeIn
|
||||||
tsb bState
|
tsb bState
|
||||||
|
|
||||||
jmp CORE.Run.1 Loop with Pipe IN
|
bit CORE.IntCmd
|
||||||
|
bmi .60
|
||||||
|
|
||||||
|
jsr IO.Reset.Out Internal : CLOSE output
|
||||||
|
bra .61
|
||||||
|
|
||||||
|
.60 jsr IO.Pop.Out External : DONT Close Output, child process will close it
|
||||||
|
|
||||||
.7 jsr CORE.ExecCmd
|
.61 lda #bState.PipeOut
|
||||||
|
trb bState
|
||||||
|
|
||||||
|
.7 jmp CORE.Run.1 Loop with Pipe IN
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CORE.Run.Exit php
|
CORE.Run.Exit php
|
||||||
pha
|
pha
|
||||||
|
@ -403,6 +402,7 @@ CORE.ExecExtCmd >PUSHW ZPArgVBuf
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.4 >SLEEP Suspend this PID
|
.4 >SLEEP Suspend this PID
|
||||||
|
|
||||||
sec
|
sec
|
||||||
ldy #S.PS.RC CPID will update S.PS.RC
|
ldy #S.PS.RC CPID will update S.PS.RC
|
||||||
lda (pPS),y
|
lda (pPS),y
|
||||||
|
@ -584,6 +584,7 @@ CORE.ArgV.Next lda (ZPArgVBufPtr)
|
||||||
CORE.ArgV.NextChar
|
CORE.ArgV.NextChar
|
||||||
inc ZPArgVBufPtr
|
inc ZPArgVBufPtr
|
||||||
bne .8
|
bne .8
|
||||||
|
|
||||||
inc ZPArgVBufPtr+1
|
inc ZPArgVBufPtr+1
|
||||||
.8 rts
|
.8 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
|
|
@ -74,7 +74,7 @@ HIS.Select >LDA.G HIS.Count
|
||||||
bne .1
|
bne .1
|
||||||
|
|
||||||
>LDYA L.MSG.HISPROMPT
|
>LDYA L.MSG.HISPROMPT
|
||||||
jsr PrintYANoCR
|
jsr IO.OutYA
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
|
@ -97,7 +97,7 @@ HIS.Select >LDA.G HIS.Count
|
||||||
>STA.G HIS.Ptr
|
>STA.G HIS.Ptr
|
||||||
|
|
||||||
.7 >LDYA L.MSG.HISROMPTCLR
|
.7 >LDYA L.MSG.HISROMPTCLR
|
||||||
jsr PrintYANoCR
|
jsr IO.OutYA
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
jsr CL.PrintPrompt
|
jsr CL.PrintPrompt
|
||||||
|
@ -154,7 +154,7 @@ HIS.GetToCL1 >LDA.G HIS.Ptr
|
||||||
>STA.G CL.Len
|
>STA.G CL.Len
|
||||||
|
|
||||||
>LDYA ZPCLBuf
|
>LDYA ZPCLBuf
|
||||||
jmp PrintYANoCR
|
jmp IO.OutYA
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
|
187
BIN/SH.S.IO.txt
187
BIN/SH.S.IO.txt
|
@ -38,6 +38,7 @@ IO.Pop.In clc
|
||||||
IO.Reset.In sec
|
IO.Reset.In sec
|
||||||
>LDA.G IO.hIn
|
>LDA.G IO.hIn
|
||||||
beq .8
|
beq .8
|
||||||
|
|
||||||
bcc .1
|
bcc .1
|
||||||
|
|
||||||
ldy #S.PS.hStdIn
|
ldy #S.PS.hStdIn
|
||||||
|
@ -83,7 +84,7 @@ IO.Pop.Out clc
|
||||||
.HS B0 BCS
|
.HS B0 BCS
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
IO.Reset.Out sec
|
IO.Reset.Out sec
|
||||||
IO.Reset.OutC >LDA.G IO.hOut
|
>LDA.G IO.hOut
|
||||||
beq .8
|
beq .8
|
||||||
|
|
||||||
bcc .1
|
bcc .1
|
||||||
|
@ -124,11 +125,11 @@ IO.Close.Y pha
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
IO.Pipe.OpenR ldx #O.RDONLY+O.TEXT
|
IO.Pipe.OpenR ldx #O.RDONLY+O.TEXT
|
||||||
.HS 2C BIT ABS
|
bra IO.Pipe.Open
|
||||||
|
|
||||||
IO.Pipe.OpenW ldx #O.WRONLY+O.TEXT
|
IO.Pipe.OpenW ldx #O.WRONLY+O.TEXT
|
||||||
|
|
||||||
>LEA.G IO.DEVFIFO
|
IO.Pipe.Open >LEA.G IO.DEVFIFO
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
IO.FOpenYAX >PUSHYA
|
IO.FOpenYAX >PUSHYA
|
||||||
txa
|
txa
|
||||||
|
@ -151,50 +152,10 @@ IO.StatYA >PUSHYA
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* set A = `sh -C ls|grep test`
|
|
||||||
IO.Exec >PUSHW ZPArgVBufPtr
|
IO.Exec >PUSHW ZPArgVBufPtr
|
||||||
>PUSHBI S.PS.F.CLOSEONX
|
>PUSHBI S.PS.F.CLOSEONX
|
||||||
>SYSCALL ExecL
|
>SYSCALL ExecL
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
* >LDYAI 256
|
|
||||||
* >SYSCALL GetMem
|
|
||||||
* bcs .99
|
|
||||||
|
|
||||||
* >STYA ZPPtr1
|
|
||||||
* phx
|
|
||||||
* >PUSHYA
|
|
||||||
* >PUSHW L.EXECC
|
|
||||||
* >PUSHW.G SH
|
|
||||||
* >PUSHW ZPArgVBufPtr
|
|
||||||
* >PUSHBI 4
|
|
||||||
* >SYSCALL sprintf
|
|
||||||
* bcs .98
|
|
||||||
|
|
||||||
* ldy #S.PS.hStdErr
|
|
||||||
* lda (pPS),y
|
|
||||||
* >PUSHA
|
|
||||||
* >PUSHW ZPPtr1
|
|
||||||
* >SYSCALL fputs
|
|
||||||
* >DEBUG
|
|
||||||
|
|
||||||
* >PUSHW ZPPtr1
|
|
||||||
* >PUSHBI S.PS.F.CLOSEONX
|
|
||||||
* >SYSCALL ExecL
|
|
||||||
|
|
||||||
*.98 plx
|
|
||||||
|
|
||||||
* php
|
|
||||||
* pha
|
|
||||||
|
|
||||||
* txa
|
|
||||||
* >SYSCALL freemem
|
|
||||||
|
|
||||||
* pla
|
|
||||||
* plp
|
|
||||||
|
|
||||||
*.99 rts
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
IO.PrintBatchErrMsg
|
IO.PrintBatchErrMsg
|
||||||
>LDYA ZPInputBuf
|
>LDYA ZPInputBuf
|
||||||
|
@ -319,6 +280,144 @@ IO.PrintErrMsg ldy #S.PS.RC
|
||||||
|
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
IO.EscOutYA >STYA ZPPtr1 In
|
||||||
|
>STYA ZPPtr2 Out
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
.1 jsr GetPtr1NextChar
|
||||||
|
beq .8
|
||||||
|
|
||||||
|
cmp #'\'
|
||||||
|
bne .6
|
||||||
|
|
||||||
|
lda (ZPPtr1)
|
||||||
|
beq .7
|
||||||
|
|
||||||
|
ldx #OUT.EscCharsCnt-1
|
||||||
|
|
||||||
|
.2 cmp OUT.EscChars,x
|
||||||
|
beq .5
|
||||||
|
|
||||||
|
dex
|
||||||
|
bpl .2
|
||||||
|
|
||||||
|
stz ZPTmpW
|
||||||
|
|
||||||
|
jsr ToUpperCase
|
||||||
|
cmp #'X'
|
||||||
|
bne .3
|
||||||
|
|
||||||
|
.20 jsr IncPtr1
|
||||||
|
|
||||||
|
lda (ZPPtr1)
|
||||||
|
beq .40
|
||||||
|
|
||||||
|
jsr IO.IsHexDigit
|
||||||
|
bcs .40
|
||||||
|
|
||||||
|
asl ZPTmpW
|
||||||
|
asl ZPTmpW
|
||||||
|
asl ZPTmpW
|
||||||
|
asl ZPTmpW
|
||||||
|
ora ZPTmpW
|
||||||
|
sta ZPTmpW
|
||||||
|
bra .20
|
||||||
|
|
||||||
|
.3 jsr IO.IsOctDigit
|
||||||
|
bcs .40
|
||||||
|
|
||||||
|
jsr IncPtr1
|
||||||
|
|
||||||
|
asl ZPTmpW
|
||||||
|
asl ZPTmpW
|
||||||
|
asl ZPTmpW
|
||||||
|
ora ZPTmpW
|
||||||
|
sta ZPTmpW
|
||||||
|
lda (ZPPtr1)
|
||||||
|
bne .3
|
||||||
|
|
||||||
|
.40 lda ZPTmpW
|
||||||
|
bra .6
|
||||||
|
|
||||||
|
.4 tax
|
||||||
|
|
||||||
|
lda #'\'
|
||||||
|
sta (ZPPtr2),y
|
||||||
|
iny
|
||||||
|
|
||||||
|
txa
|
||||||
|
bra .6
|
||||||
|
|
||||||
|
.5 lda OUT.EscCodes,x
|
||||||
|
jsr IncPtr1
|
||||||
|
|
||||||
|
.6 sta (ZPPtr2),y
|
||||||
|
iny
|
||||||
|
bra .1
|
||||||
|
|
||||||
|
.7 lda #'\'
|
||||||
|
sta (ZPPtr2),y
|
||||||
|
iny
|
||||||
|
lda #0
|
||||||
|
|
||||||
|
.8 sta (ZPPtr2),y
|
||||||
|
|
||||||
|
>LDYA ZPPtr2
|
||||||
|
*--------------------------------------
|
||||||
|
IO.OutYA >PUSHYA
|
||||||
|
>PUSHBI 0
|
||||||
|
>SYSCALL PrintF
|
||||||
|
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
IO.IsOctDigit cmp #'0'
|
||||||
|
bcc .9
|
||||||
|
|
||||||
|
cmp #'7'+1
|
||||||
|
bcs .9
|
||||||
|
|
||||||
|
and #%00000111
|
||||||
|
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
|
||||||
|
.9 sec
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
IO.IsHexDigit cmp #'0'
|
||||||
|
bcc .9
|
||||||
|
|
||||||
|
cmp #'9'+1
|
||||||
|
bcc .8
|
||||||
|
|
||||||
|
cmp #'A'
|
||||||
|
bcc .9
|
||||||
|
|
||||||
|
cmp #'Z'+1
|
||||||
|
bcc .7
|
||||||
|
|
||||||
|
cmp #'a'
|
||||||
|
bcc .9
|
||||||
|
|
||||||
|
cmp #'z'+1
|
||||||
|
bcc .9
|
||||||
|
|
||||||
|
* sec
|
||||||
|
|
||||||
|
sbc #$20
|
||||||
|
|
||||||
|
.7 sec
|
||||||
|
sbc #'A'-10
|
||||||
|
|
||||||
|
.8 and #$0F
|
||||||
|
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
|
||||||
|
.9 sec
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
MAN
|
MAN
|
||||||
SAVE usr/src/bin/sh.s.io
|
SAVE usr/src/bin/sh.s.io
|
||||||
LOAD usr/src/bin/sh.s
|
LOAD usr/src/bin/sh.s
|
||||||
|
|
30
BIN/SH.S.txt
30
BIN/SH.S.txt
|
@ -89,7 +89,7 @@ bState.ExitOnEOF .EQ %10000000
|
||||||
bState.Pause .EQ %01000000
|
bState.Pause .EQ %01000000
|
||||||
bState.PipeIn .EQ %00100000
|
bState.PipeIn .EQ %00100000
|
||||||
bState.PipeOut .EQ %00010000
|
bState.PipeOut .EQ %00010000
|
||||||
|
bState.PipeOutInt .EQ %00001000
|
||||||
bState.SET.C .EQ %00000100
|
bState.SET.C .EQ %00000100
|
||||||
bState.SET.E .EQ %00000010
|
bState.SET.E .EQ %00000010
|
||||||
bState.SET.X .EQ %00000001
|
bState.SET.X .EQ %00000001
|
||||||
|
@ -244,7 +244,7 @@ CS.RUN jsr CL.Init
|
||||||
|
|
||||||
jsr GetArgV
|
jsr GetArgV
|
||||||
jmp CS.RUN.CMDLINE
|
jmp CS.RUN.CMDLINE
|
||||||
|
|
||||||
.19 lda #E.CSYN
|
.19 lda #E.CSYN
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
@ -357,11 +357,10 @@ CS.RUN.LOOP >SLEEP
|
||||||
CS.RUN.INTERACTIVE
|
CS.RUN.INTERACTIVE
|
||||||
jsr IO.Reset
|
jsr IO.Reset
|
||||||
jsr CL.Reset
|
jsr CL.Reset
|
||||||
|
jsr CL.ReadResetV
|
||||||
|
|
||||||
>STZ.G HIS.Ptr
|
>STZ.G HIS.Ptr
|
||||||
|
|
||||||
jsr CL.ReadResetV
|
|
||||||
|
|
||||||
jsr CL.PrintPrompt
|
jsr CL.PrintPrompt
|
||||||
bcs CS.RUN.CMDLINE.9
|
bcs CS.RUN.CMDLINE.9
|
||||||
|
|
||||||
|
@ -377,7 +376,7 @@ CS.RUN.INTERACTIVE
|
||||||
bpl .1
|
bpl .1
|
||||||
|
|
||||||
>LDYA L.MSG.PROMPTCRLF
|
>LDYA L.MSG.PROMPTCRLF
|
||||||
jsr PrintYANoCR
|
jsr IO.OutYA
|
||||||
bcs CS.RUN.CMDLINE.9
|
bcs CS.RUN.CMDLINE.9
|
||||||
|
|
||||||
lda (ZPCLBuf)
|
lda (ZPCLBuf)
|
||||||
|
@ -539,6 +538,7 @@ CheckLFAfterCR ldy #S.PS.hStdIn Check for any extra LF
|
||||||
|
|
||||||
tay
|
tay
|
||||||
bne .9
|
bne .9
|
||||||
|
|
||||||
>SYSCALL GetChar
|
>SYSCALL GetChar
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
|
@ -558,13 +558,17 @@ GetPtr1NextChar lda (ZPPtr1)
|
||||||
|
|
||||||
IncPtr1 inc ZPPtr1
|
IncPtr1 inc ZPPtr1
|
||||||
bne IncPtr1.8
|
bne IncPtr1.8
|
||||||
|
|
||||||
inc ZPPtr1+1
|
inc ZPPtr1+1
|
||||||
|
|
||||||
IncPtr1.8 rts
|
IncPtr1.8 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
GetPtr1LenY ldy #$ff
|
GetPtr1LenY ldy #$ff
|
||||||
|
|
||||||
.1 iny
|
.1 iny
|
||||||
lda (ZPPtr1),y
|
lda (ZPPtr1),y
|
||||||
bne .1
|
bne .1
|
||||||
|
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
GetPtr1NextString
|
GetPtr1NextString
|
||||||
|
@ -576,6 +580,7 @@ AddAp1Ptr1 sec
|
||||||
adc ZPPtr1
|
adc ZPPtr1
|
||||||
sta ZPPtr1
|
sta ZPPtr1
|
||||||
bcc .8
|
bcc .8
|
||||||
|
|
||||||
inc ZPPtr1+1
|
inc ZPPtr1+1
|
||||||
.8 rts
|
.8 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
@ -595,11 +600,6 @@ IncPStack3 inc pStack
|
||||||
inc pStack
|
inc pStack
|
||||||
inc pStack
|
inc pStack
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
|
||||||
PrintYANoCR >PUSHYA
|
|
||||||
>PUSHBI 0
|
|
||||||
>SYSCALL PrintF
|
|
||||||
rts
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.INB usr/src/bin/sh.s.cl
|
.INB usr/src/bin/sh.s.cl
|
||||||
.INB usr/src/bin/sh.s.cmd
|
.INB usr/src/bin/sh.s.cmd
|
||||||
|
@ -637,15 +637,15 @@ HOME .AZ "${HOME}"
|
||||||
EXECC .AZ "%s -C %s"
|
EXECC .AZ "%s -C %s"
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
IN.EscChars .AS "DABC"
|
IN.EscChars .AS "DABC"
|
||||||
IN.EscCharsCnt .EQ *-EscChars
|
IN.EscCharsCnt .EQ *-IN.EscChars
|
||||||
IN.EscCodes .DA #C.BS,#C.VT,#C.LF,#21
|
IN.EscCodes .DA #C.BS,#C.VT,#C.LF,#21
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* \e[1~ - Home
|
* \e[1~ - Home
|
||||||
* \e[2~ - Insert
|
* \e[2~ - Insert
|
||||||
* \e[3~ - Delete
|
* \e[3~ - Delete
|
||||||
* \e[4~ - End
|
* \e[4~ - End
|
||||||
* \e[5~ - PgUp
|
* \e[5~ - PgUp
|
||||||
* \e[6~ - PgDn
|
* \e[6~ - PgDn
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
OUT.EscChars .AS "abefnrtv"
|
OUT.EscChars .AS "abefnrtv"
|
||||||
.HS 5C27223F \'"?
|
.HS 5C27223F \'"?
|
||||||
|
|
|
@ -162,19 +162,25 @@ D2.MoveHead >PULLB D2.TargetQTrack
|
||||||
cmp D2.TargetQTrack
|
cmp D2.TargetQTrack
|
||||||
bne .3
|
bne .3
|
||||||
|
|
||||||
lsr CS if X,Y on
|
* lsr CS if X,Y on
|
||||||
|
|
||||||
jsr D2.Wait25600usec
|
jsr D2.Wait25600usec
|
||||||
|
|
||||||
|
ldy D2.Slotn0
|
||||||
|
lda IO.D2.Ph0Off+2,y
|
||||||
|
lda IO.D2.Ph0Off+6,y
|
||||||
lda IO.D2.Ph0Off,y
|
lda IO.D2.Ph0Off,y
|
||||||
|
lda IO.D2.Ph0Off+4,y
|
||||||
bcc .10
|
|
||||||
|
|
||||||
clc
|
|
||||||
|
|
||||||
lda IO.D2.Ph0Off,x
|
* lda IO.D2.Ph0Off,y
|
||||||
|
|
||||||
.10 jsr D2.Wait25600usec
|
* bcc .10
|
||||||
|
|
||||||
|
* lda IO.D2.Ph0Off,x
|
||||||
|
* clc
|
||||||
|
* lda IO.D2.Ph0Off,y
|
||||||
|
|
||||||
|
*.10 jsr D2.Wait25600usec
|
||||||
|
|
||||||
plp
|
plp
|
||||||
clc
|
clc
|
||||||
|
|
|
@ -716,13 +716,19 @@ XRW.TrackSelect lda #2
|
||||||
ora A2L
|
ora A2L
|
||||||
tay y = n0/n2
|
tay y = n0/n2
|
||||||
|
|
||||||
lda IO.D2.Ph0On,y
|
iny
|
||||||
lda IO.D2.Ph0On+4,y
|
jsr XRW.Ph04Off
|
||||||
|
|
||||||
|
* lda IO.D2.Ph0On,y
|
||||||
|
* lda IO.D2.Ph0On+4,y
|
||||||
|
|
||||||
jsr XRW.Wait100usec
|
jsr XRW.Wait100usec
|
||||||
|
|
||||||
lda IO.D2.Ph0Off,y
|
dey
|
||||||
lda IO.D2.Ph0Off+4,y
|
jsr XRW.Ph04Off
|
||||||
|
*
|
||||||
|
* lda IO.D2.Ph0Off,y
|
||||||
|
* lda IO.D2.Ph0Off+4,y
|
||||||
|
|
||||||
lda XRW.AddrField.T
|
lda XRW.AddrField.T
|
||||||
sta XRW.D2Trk-1,x
|
sta XRW.D2Trk-1,x
|
||||||
|
@ -834,17 +840,24 @@ XRW.SeekYA sta XRW.D2Trk-1,x will be current track at the end
|
||||||
cmp XRW.TargetQTrack
|
cmp XRW.TargetQTrack
|
||||||
bne .3
|
bne .3
|
||||||
|
|
||||||
lsr CS if X,Y on
|
* lsr CS if X,Y on
|
||||||
|
|
||||||
jsr XRW.Wait25600usec
|
jsr XRW.Wait25600usec
|
||||||
|
|
||||||
lda IO.D2.Ph0Off,y
|
ldy A2L
|
||||||
|
lda IO.D2.Ph0Off+2,y
|
||||||
|
lda IO.D2.Ph0Off+6,y
|
||||||
|
XRW.Ph04Off lda IO.D2.Ph0Off,y
|
||||||
|
lda IO.D2.Ph0Off+4,y
|
||||||
|
|
||||||
bcc .10
|
|
||||||
|
|
||||||
|
* lda IO.D2.Ph0Off,y
|
||||||
|
|
||||||
|
* bcc .10
|
||||||
|
|
||||||
|
* lda IO.D2.Ph0Off,x
|
||||||
clc Exit wit CC (recalibrate)
|
clc Exit wit CC (recalibrate)
|
||||||
|
* lda IO.D2.Ph0Off,y
|
||||||
lda IO.D2.Ph0Off,x
|
|
||||||
|
|
||||||
.10 rts
|
.10 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
|
|
@ -319,20 +319,26 @@ BB.FX2.SeekReadD2
|
||||||
cmp BB.TargetQTrack
|
cmp BB.TargetQTrack
|
||||||
bne .3
|
bne .3
|
||||||
|
|
||||||
lsr CS if X,Y on
|
* lsr CS if X,Y on
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
jsr BB.Wait100usecA
|
jsr BB.Wait100usecA
|
||||||
|
|
||||||
|
ldy ROM.D2.Slotn0
|
||||||
|
lda IO.D2.Ph0Off+2,y
|
||||||
|
lda IO.D2.Ph0Off+6,y
|
||||||
lda IO.D2.Ph0Off,y
|
lda IO.D2.Ph0Off,y
|
||||||
|
lda IO.D2.Ph0Off+4,y
|
||||||
|
|
||||||
bcc .10
|
* lda IO.D2.Ph0Off,y
|
||||||
|
|
||||||
clc
|
* bcc .10
|
||||||
|
|
||||||
lda IO.D2.Ph0Off,x
|
* clc
|
||||||
|
|
||||||
.10
|
* lda IO.D2.Ph0Off,x
|
||||||
|
|
||||||
|
*.10
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
BB.FX2.ReadSectD2
|
BB.FX2.ReadSectD2
|
||||||
ldx ROM.D2.Slotn0
|
ldx ROM.D2.Slotn0
|
||||||
|
|
|
@ -763,16 +763,6 @@ K.Rename jsr PFT.CheckPath2
|
||||||
* + %L : pull 4 bytes signed DEC -2147483648..2147483647
|
* + %L : pull 4 bytes signed DEC -2147483648..2147483647
|
||||||
* + %s : pull 2 bytes ptr to C-Style String
|
* + %s : pull 2 bytes ptr to C-Style String
|
||||||
* + %S : pull 2 bytes ptr to P-Style String
|
* + %S : pull 2 bytes ptr to P-Style String
|
||||||
* + \b : Print 'BS' (08)
|
|
||||||
* + \e : Print 'ESC' ($1B,27)
|
|
||||||
* + \f : Print 'FF' ($0C,12)
|
|
||||||
* + \n : Print 'LF' ($0A,10)
|
|
||||||
* + \r : Print 'CR' ($0D,13)
|
|
||||||
* + \t : Print 'TAB' ($09,09)
|
|
||||||
* + \v : Print 'VT' ($0B,11)
|
|
||||||
* + \xHH : Print byte with hexadecimal value HH (1 to 2 digits)
|
|
||||||
* + \\\\ : Print \
|
|
||||||
* + \\% : Print %
|
|
||||||
* Modifiers for len and padding :
|
* Modifiers for len and padding :
|
||||||
* + %d : '9' '12'
|
* + %d : '9' '12'
|
||||||
* + %2d : ' 9' '12'
|
* + %2d : ' 9' '12'
|
||||||
|
@ -818,7 +808,8 @@ K.PrintF.1 sec format string->ptr2
|
||||||
jmp .8 end of format..
|
jmp .8 end of format..
|
||||||
|
|
||||||
.22 cmp #'%'
|
.22 cmp #'%'
|
||||||
bne .10
|
bne .20
|
||||||
|
|
||||||
stz K.PrintF.PadL
|
stz K.PrintF.PadL
|
||||||
stz K.PrintF.PadC
|
stz K.PrintF.PadC
|
||||||
lda (ZPPtr2)
|
lda (ZPPtr2)
|
||||||
|
@ -851,10 +842,13 @@ K.PrintF.1 sec format string->ptr2
|
||||||
beq .7
|
beq .7
|
||||||
|
|
||||||
.6 ldx #PrintFTBL1.Cnt-1 do we have a %x command?
|
.6 ldx #PrintFTBL1.Cnt-1 do we have a %x command?
|
||||||
|
|
||||||
.61 cmp PrintFTBL1,x
|
.61 cmp PrintFTBL1,x
|
||||||
beq .62
|
beq .62
|
||||||
|
|
||||||
dex
|
dex
|
||||||
bpl .61
|
bpl .61
|
||||||
|
|
||||||
bra .20 unknown ...
|
bra .20 unknown ...
|
||||||
|
|
||||||
.62 jsr SHARED.NextCP2
|
.62 jsr SHARED.NextCP2
|
||||||
|
@ -862,35 +856,16 @@ K.PrintF.1 sec format string->ptr2
|
||||||
asl
|
asl
|
||||||
tax
|
tax
|
||||||
jsr PrintF.ESC
|
jsr PrintF.ESC
|
||||||
.11 bcc .1
|
bcc .1
|
||||||
|
|
||||||
bra .99
|
bra .99
|
||||||
|
|
||||||
.7 lda #'%'
|
.7 lda #'%'
|
||||||
bra .20
|
|
||||||
*--------------------------------------
|
|
||||||
.10 cmp #'\'
|
|
||||||
bne .20
|
|
||||||
|
|
||||||
jsr SHARED.GetCP2
|
|
||||||
beq .99
|
|
||||||
ldx #PrintFTBL2.Cnt-1
|
|
||||||
.12 cmp PrintFTBL2,x
|
|
||||||
beq .19
|
|
||||||
dex
|
|
||||||
bpl .12
|
|
||||||
|
|
||||||
cmp #'x' \xHH
|
|
||||||
bne .1
|
|
||||||
|
|
||||||
jsr MATH.Hex2ACC32
|
|
||||||
bcs .99
|
|
||||||
|
|
||||||
jsr SHARED.AddY2P2
|
|
||||||
.14 lda ACC32
|
|
||||||
bra .20
|
|
||||||
.19 lda PrintFTBL2.OUT,x
|
|
||||||
|
|
||||||
.20 jsr PrintF.PutC
|
.20 jsr PrintF.PutC
|
||||||
bcc .11
|
bcc .1
|
||||||
|
|
||||||
|
jmp STDIO.Exit
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.99 lda #E.BADARG
|
.99 lda #E.BADARG
|
||||||
sec
|
sec
|
||||||
|
@ -921,11 +896,6 @@ K.PrintF.1 sec format string->ptr2
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
PrintFTBL1 .AS "bdDuefhHiILsS"
|
PrintFTBL1 .AS "bdDuefhHiILsS"
|
||||||
PrintFTBL1.Cnt .EQ *-PrintFTBL1
|
PrintFTBL1.Cnt .EQ *-PrintFTBL1
|
||||||
PrintFTBL2 .AS "abefnrtv\%"
|
|
||||||
PrintFTBL2.Cnt .EQ *-PrintFTBL2
|
|
||||||
PrintFTBL2.OUT .HS 07.08.1B.0C.0A.0D.09.0B \a\b\e\f\n\r\t\v
|
|
||||||
.DA #'\' \\
|
|
||||||
.DA #'%' \%
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
PrintF.ESC jmp (.1,x)
|
PrintF.ESC jmp (.1,x)
|
||||||
.1 .DA PrintF.B
|
.1 .DA PrintF.B
|
||||||
|
|
|
@ -575,27 +575,27 @@ TERMX.RM clc
|
||||||
|
|
||||||
ldy #S.DCB.TTY.bDECAWM
|
ldy #S.DCB.TTY.bDECAWM
|
||||||
bra .8
|
bra .8
|
||||||
|
*--------------------------------------
|
||||||
.2 cmp #25
|
.2 eor #25
|
||||||
bne .98
|
bne .98
|
||||||
|
|
||||||
ldy #S.DCB.TTY.bCURON
|
ldy #S.DCB.TTY.bCURON
|
||||||
plp
|
plp
|
||||||
|
|
||||||
ror
|
ror A = 0
|
||||||
sta (ZPDCBPtr),y
|
sta (ZPDCBPtr),y
|
||||||
bmi .80
|
bmi .3 let it starts blinking..
|
||||||
|
|
||||||
jsr TERMX.CUROFF
|
jsr TERMX.CUROFF
|
||||||
|
|
||||||
clc
|
.3 clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.8 plp
|
.8 plp
|
||||||
ror
|
ror
|
||||||
sta (ZPDCBPtr),y
|
sta (ZPDCBPtr),y
|
||||||
|
|
||||||
.80 clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.98 plp
|
.98 plp
|
||||||
|
@ -989,6 +989,8 @@ TERMX.CUU clc no scroll
|
||||||
TERMX.CBLNK jsr TERMX.CCheck
|
TERMX.CBLNK jsr TERMX.CCheck
|
||||||
bcs TERMX.RTS
|
bcs TERMX.RTS
|
||||||
|
|
||||||
|
* ldy #S.DCB.TTY.bCURON
|
||||||
|
|
||||||
lda DevMgr.Timer
|
lda DevMgr.Timer
|
||||||
and #CURBLNK.SPEED
|
and #CURBLNK.SPEED
|
||||||
eor (ZPDCBPtr),y
|
eor (ZPDCBPtr),y
|
||||||
|
@ -1001,7 +1003,7 @@ TERMX.CBLNK jsr TERMX.CCheck
|
||||||
asl
|
asl
|
||||||
beq TERMX.CUROFF.1
|
beq TERMX.CUROFF.1
|
||||||
|
|
||||||
jsr GetCharAtCurPos
|
TERMX.CURON jsr GetCharAtCurPos
|
||||||
bcs TERMX.RTS Out of screen
|
bcs TERMX.RTS Out of screen
|
||||||
|
|
||||||
and #$80
|
and #$80
|
||||||
|
@ -1011,9 +1013,6 @@ TERMX.CBLNK jsr TERMX.CCheck
|
||||||
TERMX.CUROFF jsr TERMX.CCheck
|
TERMX.CUROFF jsr TERMX.CCheck
|
||||||
bcs TERMX.RTS
|
bcs TERMX.RTS
|
||||||
|
|
||||||
asl
|
|
||||||
beq TERMX.RTS already off
|
|
||||||
|
|
||||||
TERMX.CUROFF.1 jsr GetCharAtCurPos
|
TERMX.CUROFF.1 jsr GetCharAtCurPos
|
||||||
bcs TERMX.RTS Out of screen
|
bcs TERMX.RTS Out of screen
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue