A2osX/BIN/MEMDUMP.S.txt

314 lines
5.7 KiB
Plaintext
Raw Normal View History

2016-10-07 20:48:49 +00:00
NEW
2019-07-24 05:53:09 +00:00
AUTO 3,1
2016-10-07 20:48:49 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2019-03-25 07:04:40 +00:00
.TF BIN/MEMDUMP
2016-10-07 20:48:49 +00:00
*--------------------------------------
2018-07-23 15:28:42 +00:00
.INB INC/MACROS.I
.INB INC/A2OSX.I
2018-12-18 14:37:07 +00:00
.INB INC/KERNEL.I
2016-10-07 20:48:49 +00:00
*--------------------------------------
PAGELEN .EQ 22
*--------------------------------------
2018-12-18 14:37:07 +00:00
.DUMMY
.OR ZPBIN
ZS.START
ZPPTR1 .BS 2
ZPPTR2 .BS 2
ZPPSPtr .BS 2
ZS.END
.ED
2016-10-07 20:48:49 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2018-12-18 14:37:07 +00:00
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #32 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
2016-10-07 20:48:49 +00:00
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG0 .DA MSG0
L.MSG1.INV .DA MSG1.INV
2016-10-07 20:48:49 +00:00
L.MSG1 .DA MSG1
L.MSG1.BIN .DA MSG1.BIN
L.MSG1.STR .DA MSG1.STR
L.MSG1.HEX .DA MSG1.HEX
2016-10-07 20:48:49 +00:00
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
L.MSG4 .DA MSG4
L.MSG5 .DA MSG5
L.MSG.FREE .DA MSG.FREE
2016-10-07 20:48:49 +00:00
.DA 0
*--------------------------------------
2019-02-01 16:32:29 +00:00
CS.INIT clc
rts
2016-10-07 20:48:49 +00:00
*--------------------------------------
2019-02-01 16:32:29 +00:00
CS.RUN >LEA.G MemStat
>SYSCALL GetMemStat
>LDYAI Mem.Table+S.MEM
>STYA ZPPTR1
2019-02-20 16:07:43 +00:00
>LDYA L.MSG0
>SYSCALL puts
2019-02-28 16:45:33 +00:00
>INC.G MEM.COUNT skip slot 0
2019-02-20 16:07:43 +00:00
CS.RUN.LOOP >LDA.G bSTOP
beq .1
2019-02-01 16:32:29 +00:00
2019-02-25 07:39:19 +00:00
.10 >SYSCALL GetChar
cmp #3 Ctrl-C ?
2019-02-20 16:07:43 +00:00
beq CS.RUN.LOOP.RTS
2019-02-25 07:39:19 +00:00
cmp #C.SPACE
bne .10
2019-02-20 16:07:43 +00:00
>STZ.G bSTOP
2016-10-07 20:48:49 +00:00
2018-08-20 15:15:37 +00:00
.1 lda (ZPPTR1)
2016-10-07 20:48:49 +00:00
bpl .2
>INC.G USED.COUNT
2016-10-07 20:48:49 +00:00
.2 jsr CS.RUN.PRINTMEM
2019-02-01 16:32:29 +00:00
lda ZPPTR1
clc
adc #S.MEM
sta ZPPTR1
bcc .3
inc ZPPTR1+1
.3 >INC.G MEM.COUNT
2018-08-20 15:15:37 +00:00
>CMP.G MemStat+S.MSTAT.MLast
2019-01-21 06:52:04 +00:00
beq CS.RUN.FOOTER
2016-10-07 20:48:49 +00:00
2019-02-01 16:32:29 +00:00
bra CS.RUN.LOOP
2016-10-07 20:48:49 +00:00
2019-02-20 16:07:43 +00:00
sec
CS.RUN.LOOP.RTS rts
2016-10-07 20:48:49 +00:00
2019-01-21 06:52:04 +00:00
CS.RUN.FOOTER >SYSCALL GetChar
2019-02-20 16:07:43 +00:00
bcs CS.RUN.LOOP.RTS
2019-01-21 06:52:04 +00:00
>PUSHB.G MEM.COUNT
2018-07-24 06:24:23 +00:00
>PUSHB.G USED.COUNT
2018-08-22 15:23:27 +00:00
>PUSHBI 2
>LDYA L.MSG2
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2016-10-07 20:48:49 +00:00
2018-07-24 06:24:23 +00:00
>PUSHW.G MemStat+S.MSTAT.MH
2018-08-22 15:23:27 +00:00
>PUSHBI 2
>LDYA L.MSG3
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2016-10-07 20:48:49 +00:00
2018-07-24 06:24:23 +00:00
>PUSHW.G MemStat+S.MSTAT.MF
2018-08-22 15:23:27 +00:00
>PUSHBI 2
>LDYA L.MSG4
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2016-10-07 20:48:49 +00:00
2018-07-24 06:24:23 +00:00
>PUSHW.G MemStat+S.MSTAT.ML
2018-08-22 15:23:27 +00:00
>PUSHBI 2
>LDYA L.MSG5
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2016-10-07 20:48:49 +00:00
sec
>LDA.G MemStat+S.MSTAT.MF
>SBC.G MemStat+S.MSTAT.ML
pha
>LDA.G MemStat+S.MSTAT.MF+1
>SBC.G MemStat+S.MSTAT.ML+1
ply
2016-10-07 20:48:49 +00:00
>PUSHYA
2018-08-22 15:23:27 +00:00
>PUSHBI 2
>LDYA L.MSG.FREE
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-08-11 10:57:57 +00:00
lda #0
2016-10-07 20:48:49 +00:00
sec
rts
*--------------------------------------
CS.RUN.PRINTMEM ldy #S.MEM.LEN+1
2018-08-22 15:23:27 +00:00
ldx #4
2016-10-07 20:48:49 +00:00
2018-08-22 15:23:27 +00:00
.13 lda (ZPPTR1),y
>PUSHA
dey
2018-08-22 15:23:27 +00:00
dex
bne .13
2016-10-07 20:48:49 +00:00
ldy #S.MEM.REFCNT
lda (ZPPTR1),y
>PUSHA
ldy #S.MEM.OWNERPID
lda (ZPPTR1),y
>PUSHA
lda (ZPPTR1) Get flags
2016-10-07 20:48:49 +00:00
ldy #MEM.FLAGS+7
ldx #7
.20 lsr
pha
lda #'-'
bcc .30
lda MSG.FLAGS,x
.30 sta (pData),y
pla
dey
dex
bpl .20
>PUSHEA.G MEM.FLAGS
2018-08-22 15:23:27 +00:00
>PUSHB.G MEM.COUNT
2016-10-07 20:48:49 +00:00
lda (ZPPTR1) Get flags
bpl .12
ldy #S.MEM.OWNERPID
lda (ZPPTR1),y
2018-12-18 14:37:07 +00:00
jsr CS.RUN.CHECKPS
bcc .12
2018-08-22 15:23:27 +00:00
>PUSHBI 0
>LDYA L.MSG1.INV
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-08-22 15:23:27 +00:00
.12 >PUSHBI 9
>LDYA L.MSG1
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-08-21 13:12:47 +00:00
lda (ZPPTR1)
and #S.MEM.F.CODE
2018-08-22 15:23:27 +00:00
bne CS.RUN.PRINTMEM.BIN
2018-08-21 13:12:47 +00:00
****** DATA
ldy #S.MEM.PTR
2016-10-07 20:48:49 +00:00
lda (ZPPTR1),y
sta ZPPTR2
iny
lda (ZPPTR1),y
sta ZPPTR2+1
ldy #$0
2016-10-07 20:48:49 +00:00
.1 lda (ZPPTR2),y Check if it looks like a printable string
beq .11
bmi .2
2016-10-07 20:48:49 +00:00
cmp #$20
bcc .2 not printable....->hex
iny
2016-10-07 20:48:49 +00:00
bne .1
.11 tya
beq .2 Startig with 0...PrintHEX
>PUSHW ZPPTR2 String
tya Len
>PUSHA
2018-08-22 15:23:27 +00:00
>PUSHBI 3
>LDYA L.MSG1.STR
2019-01-21 06:52:04 +00:00
bra CS.RUN.PRINTMEM.OUT
.2 ldy #15
.3 >PUSHB (ZPPTR2),y
dey
bpl .3
2016-10-07 20:48:49 +00:00
2018-08-22 15:23:27 +00:00
>PUSHBI 16
>LDYA L.MSG1.HEX
2019-01-21 06:52:04 +00:00
bra CS.RUN.PRINTMEM.OUT
2018-08-22 15:23:27 +00:00
CS.RUN.PRINTMEM.BIN
ldy #S.MEM.BIN
2018-08-21 13:12:47 +00:00
lda (ZPPTR1),y
>SYSCALL GetMemPtr
>PUSHYA
2018-08-22 15:23:27 +00:00
>PUSHBI 2
>LDYA L.MSG1.BIN
2019-01-21 06:52:04 +00:00
CS.RUN.PRINTMEM.OUT
2018-08-22 15:23:27 +00:00
>SYSCALL printf
2016-10-07 20:48:49 +00:00
>INC.G LINE.COUNT
2016-10-07 20:48:49 +00:00
cmp #PAGELEN
beq .9
rts
2016-10-07 20:48:49 +00:00
.9 lda #$FF
>STA.G bSTOP
2016-10-07 20:48:49 +00:00
inc
>STA.G LINE.COUNT
2016-10-07 20:48:49 +00:00
rts
2016-10-07 20:48:49 +00:00
*--------------------------------------
2018-12-18 14:37:07 +00:00
CS.RUN.CHECKPS ldx #0
.1 cmp PS.Table.PID,x
beq .8
inx
cpx K.PS.MAX
bne .1
rts CS
.8 clc
rts
*--------------------------------------
CS.DOEVENT sec
2016-10-07 20:48:49 +00:00
rts
*--------------------------------------
CS.QUIT clc
2016-10-07 20:48:49 +00:00
rts
*--------------------------------------
CS.END
2019-02-28 16:45:33 +00:00
MSG0 .AZ "hMem Flags PID REF PTR LEN BINPATH/DATA"
MSG1.INV .AZ "\e[7m"
2019-02-28 16:45:33 +00:00
MSG1 .AZ "$%h %s %3d %3d $%H %5D "
MSG1.BIN .AZ "{%s}\e[0m\r\n"
MSG1.STR .AZ "[%03d:%s]\e[0m\r\n"
MSG1.HEX .AZ "?HEX:%h%h.%h%h.%h%h.%h%h.%h%h.%h%h.%h%h.%h%h\e[0m\r\n"
MSG2 .AZ "\r\nAllocated hMem:%d, Total:%d\r\n"
MSG3 .AZ "High Memory: $%H\r\n"
MSG4 .AZ "Free ULimit: $%H\r\n"
MSG5 .AZ "Low Memory: $%H\r\n"
MSG.FREE .AZ "\r\nFree Memory: %D Bytes.\r\n"
2018-08-11 10:57:57 +00:00
MSG.FLAGS .AS "UZNAfcds"
2016-10-07 20:48:49 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
LINE.COUNT .BS 1
MEM.COUNT .BS 1
USED.COUNT .BS 1
bSTOP .BS 1
MemStat .BS S.MSTAT
MEM.FLAGS .BS 9
2016-10-07 20:48:49 +00:00
DS.END
.ED
*--------------------------------------
MAN
2019-01-28 07:44:37 +00:00
SAVE USR/SRC/BIN/MEMDUMP.S
2016-10-07 20:48:49 +00:00
ASM