A2osX/BIN/KILL.S.txt

118 lines
2.3 KiB
Plaintext
Raw Normal View History

2018-12-04 13:20:35 +00:00
NEW
PREFIX
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
2020-08-19 19:39:43 +00:00
.TF bin/kill
2018-12-04 13:20:35 +00:00
*--------------------------------------
2020-08-19 19:39:43 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
2018-12-04 13:20:35 +00:00
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPTmpPtr .BS 2
2020-08-19 19:39:43 +00:00
ZS.END .ED
2018-12-04 13:20:35 +00:00
*--------------------------------------
* 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
2022-11-02 06:54:30 +00:00
.DA CS.DOEVENT
2018-12-04 13:20:35 +00:00
.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
2022-11-02 06:54:30 +00:00
ldy #1
2018-12-04 13:20:35 +00:00
lda (ZPTmpPtr),y
beq .9
cmp #'0'
bcc .9
cmp #'9'+1
bcs .9
and #$0F
>STA.G Signal
bra .1
2022-11-02 06:54:30 +00:00
.9 >LDYA L.MSG.USAGE
>SYSCALL PutS
2018-12-04 13:20:35 +00:00
lda #E.SYN
2019-10-03 06:25:27 +00:00
sec
rts
2020-02-14 16:32:52 +00:00
.2 >PUSHW ZPTmpPtr
2018-12-04 13:20:35 +00:00
>PUSHW L.SSCANF.PID
2020-02-14 16:32:52 +00:00
>PUSHEA.G PID
>PUSHBI 2 1 Ptr
2020-08-19 19:39:43 +00:00
>SYSCALL SScanF
2018-12-04 13:20:35 +00:00
bcs .9
2021-04-10 17:17:40 +00:00
>PUSHB.G PID
2018-12-04 13:20:35 +00:00
>PUSHB.G Signal
2020-08-19 19:39:43 +00:00
>SYSCALL Kill
2018-12-04 13:20:35 +00:00
bcs .99
lda #0
sec
.99 rts
*--------------------------------------
CS.DOEVENT sec do not discard TIMER event
rts
*--------------------------------------
CS.QUIT clc
rts
*--------------------------------------
CS.END
2022-11-02 06:54:30 +00:00
MSG.USAGE .CS "Usage : KILL <signal> PID\r\n"
.CS " -0 : No Signal\r\n"
.CS " -1 : SIGQUIT\r\n"
.CZ " -2 : SIGKILL\r\n"
SSCANF.PID .CZ "%d"
2018-12-04 13:20:35 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgIndex .BS 1
Signal .BS 1
PID .BS 1
DS.END
.ED
*--------------------------------------
MAN
2020-08-19 19:39:43 +00:00
SAVE usr/src/bin/kill.s
2018-12-04 13:20:35 +00:00
ASM