mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-27 04:49:20 +00:00
125 lines
2.3 KiB
Plaintext
125 lines
2.3 KiB
Plaintext
NEW
|
||
PREFIX
|
||
AUTO 4,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF BIN/KILL
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
*--------------------------------------
|
||
* Zero Page Segment, up to 32 bytes
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR ZPBIN
|
||
ZS.START
|
||
ZPTmpPtr .BS 2
|
||
ZS.END
|
||
.ED
|
||
*--------------------------------------
|
||
* 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
|
||
.DA #0
|
||
.DA CS.END-CS.START Code Length To Relocate
|
||
.DA DS.END-DS.START Data Segment to Allocate
|
||
.DA #16 Stack Size
|
||
.DA #ZS.END-ZS.START Zero Page Size
|
||
.DA 0
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.MSG.USAGE .DA MSG.USAGE
|
||
L.SSCANF.PID .DA SSCANF.PID
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN ldy #S.PS.ARGC
|
||
lda (pPS),y
|
||
beq .9
|
||
|
||
lda #1
|
||
>STA.G Signal
|
||
|
||
.1 >INC.G ArgIndex
|
||
>SYSCALL ArgV
|
||
bcs .9
|
||
>STYA ZPTmpPtr
|
||
|
||
lda (ZPTmpPtr)
|
||
cmp #'-'
|
||
bne .2
|
||
|
||
ldy #1
|
||
lda (ZPTmpPtr),y
|
||
beq .9
|
||
|
||
cmp #'0'
|
||
bcc .9
|
||
cmp #'9'+1
|
||
bcs .9
|
||
|
||
and #$0F
|
||
>STA.G Signal
|
||
bra .1
|
||
|
||
.9 >PUSHBI 0
|
||
>LDYA L.MSG.USAGE
|
||
|
||
>SYSCALL printf
|
||
|
||
lda #E.SYN
|
||
sec
|
||
rts
|
||
|
||
.2 >PUSHEA.G PID
|
||
|
||
>PUSHBI 2 1 Ptr
|
||
|
||
>PUSHW L.SSCANF.PID
|
||
>LDYA ZPTmpPtr
|
||
>SYSCALL sscanf
|
||
bcs .9
|
||
|
||
>PUSHB.G Signal
|
||
>LDA.G PID
|
||
>SYSCALL kill
|
||
bcs .99
|
||
lda #0
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec do not discard TIMER event
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG.USAGE .AS "Usage : KILL <signal> PID\r\n"
|
||
.AS " -0 : No Signal\r\n"
|
||
.AZ " -1 : SIGQUIT\r\n"
|
||
SSCANF.PID .AZ "%d"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
ArgIndex .BS 1
|
||
Signal .BS 1
|
||
PID .BS 1
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/KILL.S
|
||
ASM
|