TERMIBAL, PRINTF, SH, Piping....

This commit is contained in:
burniouf 2023-05-16 18:53:52 +02:00
parent 0ea8d62a96
commit 87b9078877
25 changed files with 907 additions and 776 deletions

View File

@ -1195,16 +1195,6 @@ Specifiers :
+ %L : pull 4 bytes signed DEC -2147483648..2147483647
+ %s : pull 2 bytes ptr to C-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 :
+ %d : '9' '12'

View File

@ -182,7 +182,7 @@ CS: A = EC
CC: Y,A = bytes written
CS: A = EC
# RecvFrom (RAW,DGRAM,SEQPKT)
# RecvFrom (RAW,DGRAM)
## C
`hMem recvfrom(hFD fd, struct sockaddr *addr);`

View File

@ -301,13 +301,15 @@ The **default** commands is used to select the block of commands to execute for
### 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>.
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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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
#

View File

@ -1,6 +1,6 @@
# 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.
@ -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[?8h |Set auto-repeat mode|DECARM|| |
|Esc[?9h |Set interlacing mode|DECINLM|| |
|Esc[?25h |Show cursor| DECTCEM |OK||
|Esc[20l |Reset line feed mode|LMN|OK| |
|Esc[?1l |Reset cursor key to cursor|DECCKM|| |
|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[?8l |Reset auto-repeat mode| DECARM || |
|Esc[?9l |Reset interlacing mode| DECINLM |||
|Esc[?25l |Hide cursor| DECTCEM |OK||
|Esc= |Set alternate keypad mode| DECKPAM |||
|Esc> |Set numeric keypad mode| DECKPNM |||
|Esc(A |Set United Kingdom G0 character set| setukg0 |OK||

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -117,17 +117,23 @@ BSX.MoveHead sta BSX.TargetQTrack
cmp BSX.TargetQTrack
bne .3
lsr CS if X,Y on
* lsr CS if X,Y on
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+4,y
bcc .10
* lda IO.D2.Ph0Off,y
* bcc .10
clc
lda IO.D2.Ph0Off,x
* lda IO.D2.Ph0Off,x
* clc
* lda IO.D2.Ph0Off,y
.10 rts
*--------------------------------------

View File

@ -364,25 +364,17 @@ SCRN.UpdateLineAtBufPtr
jsr SCRN.ToggleSel
.5 lda (BufPtr)
cmp #'\'
beq .50
cmp #'%'
bne .51
.50 pha
lda #'\'
jsr SCRN.ToLineBuf
pla
.51 jsr SCRN.ToLineBuf
inc BufPtr
bne .6
inc BufPtr+1
.6 inc BUF.COffset
bne .7
inc BUF.COffset+1
.7 dex
bne .2

View File

@ -215,7 +215,7 @@ DumpFD.PIPE >PUSHW L.MSG.PIPE
jsr DumpFD.Name
>PUSHBI 5
>PUSHBI 6
>SYSCALL PrintF
clc
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.B .CZ "%10u\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"
NO.PATH .AZ "(no path)"

View File

@ -36,9 +36,9 @@ CS.START cld
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG.NA .DA MSG.NA
L.MSG.HEADER .DA MSG.HEADER
L.MSG.BODY .DA MSG.REGDIR
.DA MSG.SPECIAL
L.FD.T .DA FD.T.REG
.DA FD.T.DIR
.DA FD.T.CDEV
@ -52,7 +52,7 @@ L.FD.T .DA FD.T.REG
CS.INIT clc
rts
*--------------------------------------
CS.RUN >LDYA L.MSG0
CS.RUN >LDYA L.MSG.HEADER
>SYSCALL PutS
ldx #1
@ -62,7 +62,23 @@ CS.RUN >LDYA L.MSG0
lda hFDs-1,x
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
>PUSHA
@ -70,27 +86,16 @@ CS.RUN >LDYA L.MSG0
lda hFDs-1,x
>PUSHA
>SYSCALL GetMemPtr
>STYA ZPFDPtr
ldx FILE.ID
lda hFDs.oCnt-1,x
>PUSHA
lda (ZPFDPtr)
tax
>PUSHW L.FD.T,x
tay
>PUSHW L.FD.T,y
jsr CS.RUN.GetName
ldx FILE.ID
lda hFDs.hName-1,x
bne .5
>LDYA L.MSG.NA
bra .6
.5 >SYSCALL GetMemPtr
.6 >PUSHYA
>PUSHYA
>PUSHBI 7
@ -105,6 +110,22 @@ CS.RUN >LDYA L.MSG0
sec
.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
rts
*--------------------------------------
@ -112,9 +133,9 @@ CS.QUIT clc
rts
*--------------------------------------
CS.END
MSG0 .CZ "hFILE hFD Cnt Type Filepath"
MSG1 .CZ "%3d %3d %3d %4s %s\r\n"
MSG.NA .CZ "n/a"
MSG.HEADER .CZ "hFILE hFD Cnt Type Filepath"
MSG.REGDIR .CZ "%3d %3d %3d %4s %s\r\n"
MSG.SPECIAL .CZ "%3d %3d %3d %4s /dev/%s\r\n"
FD.T.REG .CZ "REG"
FD.T.DIR .CZ "DIR"
FD.T.CDEV .CZ "CDEV"

View File

@ -128,15 +128,22 @@ CS.RUN inc ArgCount
ldy #S.PS.hStdIn
lda (pPS),y
pha
tax
lda hFDs-1,x
>SYSCALL GetMemPtr
>STYA ZPPtr1
plx
lda (ZPPtr1)
cmp #S.FD.T.PIPE
bne .71
stx hFile
.80 >LDYAI 256
>SYSCALL GetMem
@ -203,7 +210,9 @@ CS.RUN.PAUSE ldy #S.PS.hStdErr
>PUSHW L.MSG.Pause
>SYSCALL FPutS
.10 jsr CS.RUN.GETC
.10 ldy #S.PS.hStdErr
lda (pPS),y
>SYSCALL GetC
bcs .99
cmp #'Q'
@ -251,24 +260,7 @@ CS.RUN.ERASE ldy #S.PS.hStdErr
>SYSCALL FPutS
rts
*--------------------------------------
CS.RUN.GETC lda 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
CS.RUN.GETLINE >PUSHB hFile
>PUSHW ZPBufPtr
>PUSHWI 256

View File

@ -1,235 +1,236 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/od
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/od
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/mli.i
.INB inc/mli.e.i
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/mli.i
.INB inc/mli.e.i
*--------------------------------------
.DUMMY
.OR ZPBIN
.DUMMY
.OR ZPBIN
ZS.START
ArgIndex .BS 1
ArgPattern .BS 1
ZPPtr1 .BS 2
ZPBufPtr .BS 2
hFile .BS 1
hBuf .BS 1
char .BS 1
ByteCount .BS 3
bPause .BS 1
bPipe .BS 1
bIsTTY .BS 1
bTemp .BS 1
bDummy .BS 1
ZS.END .ED
ArgIndex .BS 1
ArgPattern .BS 1
ZPPtr1 .BS 2
ZPBufPtr .BS 2
hFile .BS 1
hBuf .BS 1
char .BS 1
ByteCount .BS 3
bPause .BS 1
bPipe .BS 1
bIsTTY .BS 1
bTemp .BS 1
bDummy .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.CRLF .DA MSG.CRLF
L.MSG.OFFSET .DA MSG.OFFSET
L.MSG.HEXBYTE .DA MSG.HEXBYTE
.DA 0
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.CRLF .DA MSG.CRLF
L.MSG.OFFSET .DA MSG.OFFSET
L.MSG.HEXBYTE .DA MSG.HEXBYTE
.DA 0
*--------------------------------------
CS.INIT clc
rts
CS.INIT clc
rts
*--------------------------------------
CS.RUN stz bPipe
stz bIsTTY
jsr CS.RUN.ISATTY
jsr CS.RUN.CheckArgs
bcs CS.RUN.LOOP.RTS
CS.RUN stz bPipe
stz bIsTTY
jsr CS.RUN.ISATTY
jsr CS.RUN.CheckArgs
bcs CS.RUN.LOOP.RTS
stz ByteCount
stz ByteCount+1
stz ByteCount+2
stz ByteCount
stz ByteCount+1
stz ByteCount+2
CS.RUN.LOOP lda bPipe If reading from pipe
bne .2 No ^C/^S handling
CS.RUN.LOOP lda bPipe If reading from pipe
bne .2 No ^C/^S handling
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL FEOF
bcs .9 I/O Error
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL FEOF
bcs .9 I/O Error
tay
bne .1 No char
tay
bne .1 No char
>SYSCALL GetChar
bcs .9 I/O error
cmp #$03 Ctrl-C
beq .9
cmp #$13 Ctrl-S
bne .1
>SYSCALL GetChar
bcs .9 I/O error
cmp #$03 Ctrl-C
beq .9
cmp #$13 Ctrl-S
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
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
.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.CheckArgs jsr CS.RUN.NextArg
bcs .4
CS.RUN.NextArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .9
lda (ZPPtr1)
cmp #'-'
beq .1
>STYA ZPPtr1
.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
.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
.9 rts
*--------------------------------------
CS.RUN.NextArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .9
>STYA ZPPtr1
.9 rts
CS.RUN.OPEN >PUSHYA
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
sta hFile
.9 rts
*--------------------------------------
CS.RUN.OPEN >PUSHYA
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
sta hFile
.9 rts
CS.RUN.ISATTY ldy #S.PS.hStdOut
lda (pPS),y
tax
lda hFDs-1,x
>SYSCALL GetMemPtr
>STYA ZPPtr1
lda (ZPPtr1)
beq .9
inc bIsTTY
.9 rts
*--------------------------------------
CS.RUN.ISATTY ldy #S.PS.hStdOut
lda (pPS),y
tax
lda hFDs-1,x
>SYSCALL GetMemPtr
>STYA ZPPtr1
lda (ZPPtr1)
beq .9
inc bIsTTY
.9 rts
*--------------------------------------
CS.QUIT lda hFile
beq .1
>SYSCALL FClose
.1 lda hBuf
beq .8
>SYSCALL FreeMem
.8 clc
rts
CS.QUIT lda hFile
beq .1
>SYSCALL FClose
.1 lda hBuf
beq .8
>SYSCALL FreeMem
.8 clc
rts
*--------------------------------------
CS.RUN.PRINTBYTE
pha Char is in A
@ -330,18 +331,18 @@ CS.DOEVENT sec
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "x"
OptionList.Cnt .EQ *-OptionList
OptionList .AS "x"
OptionList.Cnt .EQ *-OptionList
*--------------------------------------
MSG.USAGE .AS "Usage : OD <File> or CMD|OD"
MSG.CRLF .AZ "\r\n"
MSG.OFFSET .AZ "%h%h%h "
MSG.HEXBYTE .AZ "%h "
MSG.USAGE .CS "Usage : OD <File> or CMD|OD"
MSG.CRLF .CZ "\r\n"
MSG.OFFSET .CZ "%h%h%h "
MSG.HEXBYTE .CZ "%h "
*--------------------------------------
.DUMMY
.OR 0
.DUMMY
.OR 0
DS.START
DS.END .ED
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/od.s

View File

@ -1,383 +1,383 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/sed
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/sed
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/mli.i
.INB inc/mli.e.i
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/mli.i
.INB inc/mli.e.i
*--------------------------------------
.DUMMY
.OR ZPBIN
.DUMMY
.OR ZPBIN
ZS.START
ArgIndex .BS 1
ArgPattern .BS 1
ZPPtr1 .BS 2
ZPPatternPtr .BS 2
ZPBufPtr .BS 2
hFile .BS 1
hBuf .BS 1
LineNum .BS 2
char .BS 1
delimiter .BS 1
replaceidx .BS 1
ArgIndex .BS 1
ArgPattern .BS 1
ZPPtr1 .BS 2
ZPPatternPtr .BS 2
ZPBufPtr .BS 2
hFile .BS 1
hBuf .BS 1
LineNum .BS 2
char .BS 1
delimiter .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
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.CRLF .DA MSG.CRLF
.DA 0
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.CRLF .DA MSG.CRLF
.DA 0
*--------------------------------------
CS.INIT clc
rts
CS.INIT clc
rts
*--------------------------------------
CS.RUN jsr CS.RUN.CheckArgs
bcs CS.RUN.LOOP.RTS
CS.RUN jsr CS.RUN.CheckArgs
bcs CS.RUN.LOOP.RTS
stz LineNum
stz LineNum+1
stz LineNum
stz LineNum+1
CS.RUN.LOOP >SLEEP
CS.RUN.LOOP >SLEEP
>PUSHB hFile
>PUSHW ZPBufPtr
>PUSHWI 256
>SYSCALL FGetS
bcs .9
>PUSHB hFile
>PUSHW ZPBufPtr
>PUSHWI 256
>SYSCALL FGetS
bcs .9
inc LineNum
bne .2
inc LineNum
bne .2
inc LineNum+1
inc LineNum+1
.2 jsr CS.RUN.PRINT
.2 jsr CS.RUN.PRINT
bcc CS.RUN.LOOP
rts
bcc CS.RUN.LOOP
rts
.9 cmp #MLI.E.EOF
bne .99
.9 cmp #MLI.E.EOF
bne .99
lda #0 Exit with no Error
lda #0 Exit with no Error
.99 sec
CS.RUN.LOOP.RTS rts
.99 sec
CS.RUN.LOOP.RTS rts
*--------------------------------------
CS.RUN.CheckArgs
jsr CS.RUN.NextArg
bcs .4
jsr CS.RUN.NextArg
bcs .4
lda (ZPPtr1)
cmp #'-'
beq .1
lda (ZPPtr1)
cmp #'-'
beq .1
lda ArgPattern
bne .11
lda ArgPattern
bne .11
lda ArgIndex
sta ArgPattern
>LDYA ZPPtr1
>STYA ZPPatternPtr
jsr CS.RUN.SEDParser
bcs .97
bra CS.RUN.CheckArgs
lda ArgIndex
sta ArgPattern
>LDYA ZPPtr1
>STYA ZPPatternPtr
jsr CS.RUN.SEDParser
bcs .97
bra CS.RUN.CheckArgs
.11 lda hFile
bne .97
.11 lda hFile
bne .97
>LDYA ZPPtr1
jsr CS.RUN.OPEN
bcs .9
>LDYA ZPPtr1
jsr CS.RUN.OPEN
bcs .9
sta hFile
bra CS.RUN.CheckArgs
sta hFile
bra CS.RUN.CheckArgs
.1 ldy #1
lda (ZPPtr1),y
.1 ldy #1
lda (ZPPtr1),y
ldx #OptionList.Cnt-1
ldx #OptionList.Cnt-1
.2 cmp OptionList,x
beq .3
.2 cmp OptionList,x
beq .3
dex
bpl .2
dex
bpl .2
bra .97
bra .97
.3 txa
lsr
beq .98
.3 txa
lsr
beq .98
tax
lda #$80
sta bIgnoreCase-1,x
bra CS.RUN.CheckArgs
.4 lda hFile
bne .80
tax
lda #$80
sta bIgnoreCase-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
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
.80 >LDYAI 256
>SYSCALL GetMem
bcs .9
.80 >LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPBufPtr
stx hBuf
>STYA ZPBufPtr
stx hBuf
* clc
* clc
.9 rts
.9 rts
.97 lda #E.SYN
.97 lda #E.SYN
.98 pha
>PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
pla
sec
rts
.98 pha
>PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
pla
sec
rts
*--------------------------------------
CS.RUN.NextArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .9
CS.RUN.NextArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .9
>STYA ZPPtr1
>STYA ZPPtr1
.9 rts
.9 rts
*--------------------------------------
CS.RUN.SEDParser
* On entry, the expression is in ZPPatternPtr
* We are looking for "s/search string/replace string/"
* The '/' delimiter can be any char
* 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)
cmp #'s' Substitute cmd
bne .8 If not, error
lda (ZPPatternPtr)
cmp #'s' Substitute cmd
bne .8 If not, error
ldy #$01 Delimiter char
lda (ZPPatternPtr),y
sta delimiter Stash for later
ldy #$01 Delimiter char
lda (ZPPatternPtr),y
sta delimiter Stash for later
.2 iny
lda (ZPPatternPtr),y
beq .4 End of string
cmp delimiter Is it delimiter?
bne .2
.2 iny
lda (ZPPatternPtr),y
beq .4 End of string
cmp delimiter Is it delimiter?
bne .2
inc LineNum Keep count
lda LineNum
cmp #$01 Second delim
bne .2
inc LineNum Keep count
lda LineNum
cmp #$01 Second delim
bne .2
sty replaceidx
bra .2
sty replaceidx
bra .2
.4 lda LineNum Check # of delims
cmp #$02
bne .8
.4 lda LineNum Check # of delims
cmp #$02
bne .8
inc ZPPatternPtr Eat 's/'
bne .5
inc ZPPatternPtr+1
.5 inc ZPPatternPtr
bne .7
inc ZPPatternPtr+1
inc ZPPatternPtr Eat 's/'
bne .5
inc ZPPatternPtr+1
.5 inc ZPPatternPtr
bne .7
inc ZPPatternPtr+1
.7 clc
rts No error return
.7 clc
rts No error return
.8 sec
rts
.8 sec
rts
*--------------------------------------
CS.RUN.OPEN >PUSHYA
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
CS.RUN.OPEN >PUSHYA
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
sta hFile
sta hFile
.9 rts
.9 rts
*--------------------------------------
CS.RUN.PRINT >LDYA ZPBufPtr
>STYA ZPPtr1
CS.RUN.PRINT >LDYA ZPBufPtr
>STYA ZPPtr1
lda (ZPPtr1) If null first time
beq .8
lda (ZPPtr1) If null first time
beq .8
.1 lda (ZPPtr1)
beq .7 EOL. No match.
.1 lda (ZPPtr1)
beq .7 EOL. No match.
ldy #$ff
ldy #$ff
.2 iny
lda (ZPPtr1),y
bne .3
.2 iny
lda (ZPPtr1),y
bne .3
lda (ZPPatternPtr),y EOL
cmp delimiter
bne .7 Not end of pattern
* No match.
lda (ZPPatternPtr),y EOL
cmp delimiter
bne .7 Not end of pattern
* No match.
.3 lda (ZPPatternPtr),y
cmp delimiter
beq .5 Match
.3 lda (ZPPatternPtr),y
cmp delimiter
beq .5 Match
jsr CS.RUN.toUpper
sta char
lda (ZPPtr1),y
jsr CS.RUN.toUpper
cmp char
beq .2
jsr CS.RUN.toUpper
sta char
lda (ZPPtr1),y
jsr CS.RUN.toUpper
cmp char
beq .2
bra .6 No match
bra .6 No match
* Found a match
.5 jsr CS.RUN.GotMatch
bra .1
* Found a match
.5 jsr CS.RUN.GotMatch
bra .1
* Mismatch with pattern, keep going
.6 jsr CS.RUN.NoMatch
bra .1
.6 jsr CS.RUN.NoMatch
bra .1
* Hit EOL but not end of pattern, return
.7 jsr CS.RUN.NoMatch
.8 lda #C.CR
>SYSCALL PutChar
lda #C.LF
>SYSCALL PutChar
.7 jsr CS.RUN.NoMatch
.8 lda #C.CR
>SYSCALL PutChar
lda #C.LF
>SYSCALL PutChar
.9 clc
rts
.9 clc
rts
*--------------------------------------
CS.RUN.GotMatch phy
ldy replaceidx
dey
.1 lda (ZPPatternPtr),y
cmp delimiter
beq .5
phy
>SYSCALL PutChar
ply
iny
bra .1
CS.RUN.GotMatch phy
ldy replaceidx
dey
.1 lda (ZPPatternPtr),y
cmp delimiter
beq .5
phy
>SYSCALL PutChar
ply
iny
bra .1
.5 ply
tya Advance ZPPtr1 by Y
clc
adc ZPPtr1
sta ZPPtr1
lda #$00
adc ZPPtr1+1
sta ZPPtr1+1
ldy #$00
rts
.5 ply
tya Advance ZPPtr1 by Y
clc
adc ZPPtr1
sta ZPPtr1
lda #$00
adc ZPPtr1+1
sta ZPPtr1+1
ldy #$00
rts
*--------------------------------------
CS.RUN.NoMatch lda (ZPPtr1) Print ZPPtr1->ZPPtr1+Y
phy
>SYSCALL PutChar
ply
inc ZPPtr1
bne .2
inc ZPPtr1+1
.2 dey
cpy #$ff
bne CS.RUN.NoMatch
ldy #$00
rts
CS.RUN.NoMatch lda (ZPPtr1) Print ZPPtr1->ZPPtr1+Y
phy
>SYSCALL PutChar
ply
inc ZPPtr1
bne .2
inc ZPPtr1+1
.2 dey
cpy #$ff
bne CS.RUN.NoMatch
ldy #$00
rts
*--------------------------------------
CS.RUN.toUpper bit bIgnoreCase
bpl .9
CS.RUN.toUpper bit bIgnoreCase
bpl .9
cmp #'a'
bcc .9
cmp #'a'
bcc .9
cmp #'z'+1
bcs .9
cmp #'z'+1
bcs .9
eor #$20
eor #$20
.9 rts
.9 rts
*--------------------------------------
CS.QUIT lda hFile
beq .1
CS.QUIT lda hFile
beq .1
>SYSCALL FClose
>SYSCALL FClose
.1 lda hBuf
beq .8
.1 lda hBuf
beq .8
>SYSCALL FreeMem
>SYSCALL FreeMem
.8 clc
rts
.8 clc
rts
*--------------------------------------
CS.DOEVENT sec
rts
CS.DOEVENT sec
rts
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "HhIi"
OptionList.Cnt .EQ *-OptionList
OptionList .AS "HhIi"
OptionList.Cnt .EQ *-OptionList
*--------------------------------------
MSG.USAGE .AS "Usage : SED [-I] s/pattern/replacement/ <File>\r\n"
.AS " or : CMD|SED [-I] s/pattern/replacement/\r\n"
.AS " -I : Ignore Case"
MSG.CRLF .AZ "\r\n"
MSG.USAGE .CS "Usage : SED [-I] s/pattern/replacement/ <File>\r\n"
.CS " or : CMD|SED [-I] s/pattern/replacement/\r\n"
.CS " -I : Ignore Case"
MSG.CRLF .CZ "\r\n"
*--------------------------------------
.DUMMY
.OR 0
.DUMMY
.OR 0
DS.START
DS.END .ED
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/od.s
SAVE usr/src/bin/sed.s
ASM

View File

@ -12,19 +12,18 @@ CL.Init >LDYAI 256
.9 rts
*--------------------------------------
CL.PrintPrompt >PUSHW L.PS1
>PUSHWZ
>PUSHW ZPCLBuf
>SYSCALL Expand
bcs .9
phx
jsr PrintYANoCR
pla
>SYSCALL FreeMem
>LDYA ZPCLBuf
jsr IO.EscOutYA
lda #0
sta (ZPCLBuf)
.1 >LDYA L.MSG.PROMPT
jsr PrintYANoCR
jsr IO.OutYA
.9 rts
*--------------------------------------
CL.READN0A tax
@ -281,7 +280,7 @@ CL.FS >LDA.G CL.Ptr
bmi CL.BS.8
CL.FS.OUT >LDYA L.MSG.FS
jmp PrintYANoCR
jmp IO.OutYA
*--------------------------------------
CL.CLR >STZ.G HIS.Ptr
@ -311,7 +310,7 @@ CL.CLR.1 lda (ZPCLBuf)
bne .3
>LDYA ZPCLBuf
jsr PrintYANoCR
jsr IO.OutYA
*--------------------------------------
CL.Reset lda #0
sta (ZPCLBuf)
@ -336,6 +335,7 @@ CL.ReadReset lda #$ff
iny CL.bSilent
sta (pData),y
rts
*--------------------------------------
MAN

View File

@ -331,7 +331,7 @@ CMD.SET.GET >PUSHW ZPVarNamePtr
CMD.SET.RTS rts
*--------------------------------------
CMD.SET.EXEC jsr CORE.ArgV.NextChar skip "`"
jsr IO.Pipe.Out
bcs CMD.SET.RTS
@ -368,45 +368,75 @@ CMD.DATE.PRINT >LDYA ZPCLBuf
>SYSCALL PutS
rts
*--------------------------------------
CMD.ECHO stz ZPPtr1 echo -N
stz ZPPtr1+1 Token Cnt
CMD.ECHO stz ZPPtr1 echo -E
stz ZPPtr1+1 echo -N
stz ZPPtr2 index in buffer
lda (ZPArgVBufPtr)
beq .7
.1 jsr CMD.IsSwitch
bcs .2
bcs .3
ldx #0
cmp #'E'
beq .2
inx
cmp #'N'
bne CMD.ECHO.CSYN
lda #$ff
eor ZPPtr1
sta ZPPtr1
bra .4
.2 ror ZPPtr1,x
bra .6
.2 lda ZPPtr1+1
beq .3
.3 ldy ZPPtr2
beq .4
lda #C.SPACE
>SYSCALL PutChar
sta (ZPCLBuf),y
inc ZPPtr2
.3 >LDYA ZPArgVBufPtr
jsr PrintYANoCR
bcs .9
.4 ldy #$ff
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
.7 bit ZPPtr1
.7 ldy ZPPtr2
bit ZPPtr1+1 -N
bmi .8
>LDYA L.MSG.ECHOCRLF
jmp PrintYANoCR
lda #C.CR
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
CMD.ECHO.CSYN lda #E.CSYN
@ -438,7 +468,7 @@ CMD.READ lda (ZPArgVBufPtr)
beq CMD.ECHO.CSYN
>LDYA ZPArgVBufPtr
jsr PrintYANoCR
jsr IO.OutYA
bcs CMD.ECHO.RTS
bra .5
@ -573,6 +603,7 @@ CMD.REN lda (ZPArgVBufPtr)
.4 iny
lda (ZPPtr1),y
beq .5
sta (ZPPtr2),y
cmp #'/'
bne .4
@ -800,7 +831,7 @@ CMD.BREAK jsr STK.GetCtx Get context in CORE.TestResult
cmp #C.CASE
bne .1
txa
bpl .8 already FALSE
@ -812,10 +843,10 @@ CMD.BREAK jsr STK.GetCtx Get context in CORE.TestResult
bne .2
sta (pData),y IF=false to skip until FI
dey get parent context
beq .9
lda (pData),y
and #$3F
@ -824,7 +855,7 @@ CMD.BREAK jsr STK.GetCtx Get context in CORE.TestResult
.3 cmp #C.FOR
bne .9
.6 lda (pData),y
.7 and #%01111111

View File

@ -130,9 +130,9 @@ CORE.Run jsr IO.Reset
txa
>STA.G CORE.hArgVBuf
lda #bState.PipeIn
lda #bState.PipeIn+bState.PipeOut
trb bState
*--------------------------------------
CORE.Run.1 >LDYA ZPInputBufPtr Save Actual ptr for looping
>STYA ZPInputCmdPtr
@ -232,7 +232,7 @@ CORE.Run.4 >LDYA L.CMD internal command ?
jmp CORE.Run.Exit
*--------------------------------------
CORE.Run.5 jsr CORE.GetCharNB
bcs .8 Nothing to skip
bcs CORE.Run.6 Nothing to skip
jsr CORE.IsEndCmd
bcc .3
@ -254,7 +254,7 @@ CORE.Run.5 jsr CORE.GetCharNB
.9 lda #E.SYN
sec
jmp CORE.Run.Exit
*--------------------------------------
.3 cmp #C.CR
beq .7
@ -281,7 +281,7 @@ CORE.Run.5 jsr CORE.GetCharNB
.50 lda #S.PS.F.HOLD Run in the background...
trb CORE.PSFlags
bra .8
bra CORE.Run.6
.6 jsr CORE.GetNextChar Skip '&&'
@ -296,58 +296,57 @@ CORE.Run.5 jsr CORE.GetCharNB
.60 jmp CORE.Run.1
.7 jsr CORE.GetNextCharNB Skip EoL char
.8 lda #bState.PipeOut
trb bState
*--------------------------------------
CORE.Run.6 lda bState
bit #bState.PipeIn
beq .1
jsr IO.Pipe.In
bcs CORE.Run.Exit
lda bState
.1 bit #bState.PipeOut
beq .7
bit #bState.PipeOut
beq .3
jsr IO.Pipe.Out
bcs CORE.Run.Exit
lda #S.PS.F.HOLD Run in the background...
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
jsr CORE.ExecCmd
.3 jsr CORE.ExecCmd
php
pha
lda CORE.IntCmd $ff if external
eor #$80
asl if cc Was external...
jsr IO.Reset.OutC restore Output, NO close if EXTERNAL
bcs CORE.Run.Exit
lda bState
and #bState.PipeIn
.5 bit #bState.PipeIn
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
plp
lda bState
.6 bit #bState.PipeOut
beq .7
jsr IO.Pipe.In Set previous Pipe Out to StdIn for next CMD
bcs CORE.Run.Exit
lda #bState.PipeIn
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
pha
@ -403,6 +402,7 @@ CORE.ExecExtCmd >PUSHW ZPArgVBuf
rts
.4 >SLEEP Suspend this PID
sec
ldy #S.PS.RC CPID will update S.PS.RC
lda (pPS),y
@ -584,6 +584,7 @@ CORE.ArgV.Next lda (ZPArgVBufPtr)
CORE.ArgV.NextChar
inc ZPArgVBufPtr
bne .8
inc ZPArgVBufPtr+1
.8 rts
*--------------------------------------

View File

@ -74,7 +74,7 @@ HIS.Select >LDA.G HIS.Count
bne .1
>LDYA L.MSG.HISPROMPT
jsr PrintYANoCR
jsr IO.OutYA
bcs .9
lda #0
@ -97,7 +97,7 @@ HIS.Select >LDA.G HIS.Count
>STA.G HIS.Ptr
.7 >LDYA L.MSG.HISROMPTCLR
jsr PrintYANoCR
jsr IO.OutYA
bcs .9
jsr CL.PrintPrompt
@ -154,7 +154,7 @@ HIS.GetToCL1 >LDA.G HIS.Ptr
>STA.G CL.Len
>LDYA ZPCLBuf
jmp PrintYANoCR
jmp IO.OutYA
.9 rts
*--------------------------------------

View File

@ -38,6 +38,7 @@ IO.Pop.In clc
IO.Reset.In sec
>LDA.G IO.hIn
beq .8
bcc .1
ldy #S.PS.hStdIn
@ -83,7 +84,7 @@ IO.Pop.Out clc
.HS B0 BCS
*--------------------------------------
IO.Reset.Out sec
IO.Reset.OutC >LDA.G IO.hOut
>LDA.G IO.hOut
beq .8
bcc .1
@ -124,11 +125,11 @@ IO.Close.Y pha
rts
*--------------------------------------
IO.Pipe.OpenR ldx #O.RDONLY+O.TEXT
.HS 2C BIT ABS
bra IO.Pipe.Open
IO.Pipe.OpenW ldx #O.WRONLY+O.TEXT
>LEA.G IO.DEVFIFO
IO.Pipe.Open >LEA.G IO.DEVFIFO
*--------------------------------------
IO.FOpenYAX >PUSHYA
txa
@ -151,50 +152,10 @@ IO.StatYA >PUSHYA
.9 rts
*--------------------------------------
* set A = `sh -C ls|grep test`
IO.Exec >PUSHW ZPArgVBufPtr
>PUSHBI S.PS.F.CLOSEONX
>SYSCALL ExecL
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
>LDYA ZPInputBuf
@ -319,6 +280,144 @@ IO.PrintErrMsg ldy #S.PS.RC
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
SAVE usr/src/bin/sh.s.io
LOAD usr/src/bin/sh.s

View File

@ -89,7 +89,7 @@ bState.ExitOnEOF .EQ %10000000
bState.Pause .EQ %01000000
bState.PipeIn .EQ %00100000
bState.PipeOut .EQ %00010000
bState.PipeOutInt .EQ %00001000
bState.SET.C .EQ %00000100
bState.SET.E .EQ %00000010
bState.SET.X .EQ %00000001
@ -244,7 +244,7 @@ CS.RUN jsr CL.Init
jsr GetArgV
jmp CS.RUN.CMDLINE
.19 lda #E.CSYN
sec
rts
@ -357,11 +357,10 @@ CS.RUN.LOOP >SLEEP
CS.RUN.INTERACTIVE
jsr IO.Reset
jsr CL.Reset
jsr CL.ReadResetV
>STZ.G HIS.Ptr
jsr CL.ReadResetV
jsr CL.PrintPrompt
bcs CS.RUN.CMDLINE.9
@ -377,7 +376,7 @@ CS.RUN.INTERACTIVE
bpl .1
>LDYA L.MSG.PROMPTCRLF
jsr PrintYANoCR
jsr IO.OutYA
bcs CS.RUN.CMDLINE.9
lda (ZPCLBuf)
@ -539,6 +538,7 @@ CheckLFAfterCR ldy #S.PS.hStdIn Check for any extra LF
tay
bne .9
>SYSCALL GetChar
.9 rts
@ -558,13 +558,17 @@ GetPtr1NextChar lda (ZPPtr1)
IncPtr1 inc ZPPtr1
bne IncPtr1.8
inc ZPPtr1+1
IncPtr1.8 rts
*--------------------------------------
GetPtr1LenY ldy #$ff
.1 iny
lda (ZPPtr1),y
bne .1
rts
*--------------------------------------
GetPtr1NextString
@ -576,6 +580,7 @@ AddAp1Ptr1 sec
adc ZPPtr1
sta ZPPtr1
bcc .8
inc ZPPtr1+1
.8 rts
*--------------------------------------
@ -595,11 +600,6 @@ IncPStack3 inc pStack
inc pStack
inc pStack
rts
*--------------------------------------
PrintYANoCR >PUSHYA
>PUSHBI 0
>SYSCALL PrintF
rts
*--------------------------------------
.INB usr/src/bin/sh.s.cl
.INB usr/src/bin/sh.s.cmd
@ -637,15 +637,15 @@ HOME .AZ "${HOME}"
EXECC .AZ "%s -C %s"
*--------------------------------------
IN.EscChars .AS "DABC"
IN.EscCharsCnt .EQ *-EscChars
IN.EscCharsCnt .EQ *-IN.EscChars
IN.EscCodes .DA #C.BS,#C.VT,#C.LF,#21
*--------------------------------------
* \e[1~ - Home
* \e[1~ - Home
* \e[2~ - Insert
* \e[3~ - Delete
* \e[4~ - End
* \e[5~ - PgUp
* \e[6~ - PgDn
* \e[4~ - End
* \e[5~ - PgUp
* \e[6~ - PgDn
*--------------------------------------
OUT.EscChars .AS "abefnrtv"
.HS 5C27223F \'"?

View File

@ -162,19 +162,25 @@ D2.MoveHead >PULLB D2.TargetQTrack
cmp D2.TargetQTrack
bne .3
lsr CS if X,Y on
* lsr CS if X,Y on
jsr D2.Wait25600usec
ldy D2.Slotn0
lda IO.D2.Ph0Off+2,y
lda IO.D2.Ph0Off+6,y
lda IO.D2.Ph0Off,y
bcc .10
clc
lda IO.D2.Ph0Off+4,y
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
clc

View File

@ -716,13 +716,19 @@ XRW.TrackSelect lda #2
ora A2L
tay y = n0/n2
lda IO.D2.Ph0On,y
lda IO.D2.Ph0On+4,y
iny
jsr XRW.Ph04Off
* lda IO.D2.Ph0On,y
* lda IO.D2.Ph0On+4,y
jsr XRW.Wait100usec
lda IO.D2.Ph0Off,y
lda IO.D2.Ph0Off+4,y
dey
jsr XRW.Ph04Off
*
* lda IO.D2.Ph0Off,y
* lda IO.D2.Ph0Off+4,y
lda XRW.AddrField.T
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
bne .3
lsr CS if X,Y on
* lsr CS if X,Y on
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)
lda IO.D2.Ph0Off,x
* lda IO.D2.Ph0Off,y
.10 rts
*--------------------------------------

View File

@ -319,20 +319,26 @@ BB.FX2.SeekReadD2
cmp BB.TargetQTrack
bne .3
lsr CS if X,Y on
* lsr CS if X,Y on
lda #0
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+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
ldx ROM.D2.Slotn0

View File

@ -763,16 +763,6 @@ K.Rename jsr PFT.CheckPath2
* + %L : pull 4 bytes signed DEC -2147483648..2147483647
* + %s : pull 2 bytes ptr to C-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 :
* + %d : '9' '12'
* + %2d : ' 9' '12'
@ -818,7 +808,8 @@ K.PrintF.1 sec format string->ptr2
jmp .8 end of format..
.22 cmp #'%'
bne .10
bne .20
stz K.PrintF.PadL
stz K.PrintF.PadC
lda (ZPPtr2)
@ -851,10 +842,13 @@ K.PrintF.1 sec format string->ptr2
beq .7
.6 ldx #PrintFTBL1.Cnt-1 do we have a %x command?
.61 cmp PrintFTBL1,x
beq .62
dex
bpl .61
bra .20 unknown ...
.62 jsr SHARED.NextCP2
@ -862,35 +856,16 @@ K.PrintF.1 sec format string->ptr2
asl
tax
jsr PrintF.ESC
.11 bcc .1
bcc .1
bra .99
.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
bcc .11
bcc .1
jmp STDIO.Exit
*--------------------------------------
.99 lda #E.BADARG
sec
@ -921,11 +896,6 @@ K.PrintF.1 sec format string->ptr2
*--------------------------------------
PrintFTBL1 .AS "bdDuefhHiILsS"
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)
.1 .DA PrintF.B

View File

@ -575,27 +575,27 @@ TERMX.RM clc
ldy #S.DCB.TTY.bDECAWM
bra .8
.2 cmp #25
*--------------------------------------
.2 eor #25
bne .98
ldy #S.DCB.TTY.bCURON
plp
ror
ror A = 0
sta (ZPDCBPtr),y
bmi .80
bmi .3 let it starts blinking..
jsr TERMX.CUROFF
clc
.3 clc
rts
.8 plp
ror
sta (ZPDCBPtr),y
.80 clc
clc
rts
.98 plp
@ -989,6 +989,8 @@ TERMX.CUU clc no scroll
TERMX.CBLNK jsr TERMX.CCheck
bcs TERMX.RTS
* ldy #S.DCB.TTY.bCURON
lda DevMgr.Timer
and #CURBLNK.SPEED
eor (ZPDCBPtr),y
@ -1001,7 +1003,7 @@ TERMX.CBLNK jsr TERMX.CCheck
asl
beq TERMX.CUROFF.1
jsr GetCharAtCurPos
TERMX.CURON jsr GetCharAtCurPos
bcs TERMX.RTS Out of screen
and #$80
@ -1011,9 +1013,6 @@ TERMX.CBLNK jsr TERMX.CCheck
TERMX.CUROFF jsr TERMX.CCheck
bcs TERMX.RTS
asl
beq TERMX.RTS already off
TERMX.CUROFF.1 jsr GetCharAtCurPos
bcs TERMX.RTS Out of screen