A2osX/BIN/LSOF.S.txt
2023-10-18 07:41:12 +02:00

142 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/lsof
*--------------------------------------
.INB inc/macros.i
.INB inc/mli.i
.INB inc/a2osx.i
.INB inc/kernel.i
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPFDPtr .BS 2
ZPFNPtr .BS 2
FILE.ID .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
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #16 SS
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
L.MSG.HEADER .DA MSG.HEADER
L.MSG.BODY .DA MSG.BODY
L.FD.T .DA FD.T.REG
.DA FD.T.DIR
.DA FD.T.CDEV
.DA FD.T.BDEV
.DA FD.T.LNK
.DA FD.T.DSOCK
.DA FD.T.SSOCK
.DA FD.T.PIPE
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
CS.RUN >LDYA L.MSG.HEADER
>SYSCALL PutS
ldx #1
.1 stx FILE.ID
ldy FILEs.hFD-1,x
beq .7
lda FDs.pLO-1,y
sta ZPFDPtr
lda FDs.pHI-1,y
sta ZPFDPtr+1
>PUSHW L.MSG.BODY
txa
>PUSHA
lda (ZPFDPtr)
tay
>PUSHW L.FD.T,y
lda FILEs.hFD-1,x
>PUSHA
>PUSHW ZPFDPtr
lda FILEs.oCnt-1,x
>PUSHA
lda FILEs.hName-1,x
beq .2
>SYSCALL GetMemPtr
bra .6
.2 lda ZPFDPtr
clc
adc #S.FD.DEV
tay
lda ZPFDPtr+1
adc /S.FD.DEV
.6 >PUSHYA
>PUSHBI 9
>SYSCALL PrintF
* bcs .9
.7 ldx FILE.ID
inx
cpx #K.FILE.MAX+1
bcc .1
lda #0
* sec
.9 rts
*--------------------------------------
CS.EVENT sec
rts
*--------------------------------------
CS.QUIT clc
rts
*--------------------------------------
CS.END
MSG.HEADER .CZ "hFILE Type hFD pFD Cnt Filepath"
MSG.BODY .CZ " %3d %4s %3d %H %3d %s\r\n"
FD.T.REG .CZ "REG"
FD.T.DIR .CZ "DIR"
FD.T.CDEV .CZ "CDEV"
FD.T.BDEV .CZ "BDEV"
FD.T.LNK .CZ "LNK"
FD.T.DSOCK .CZ "DSCK"
FD.T.SSOCK .CZ "SSCK"
FD.T.PIPE .CZ "PIPE"
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/lsof.s
ASM