A2osX/BIN/MEMDUMP.S.txt

444 lines
7.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
2020-02-18 06:55:54 +00:00
.TF bin/memdump
2016-10-07 20:48:49 +00:00
*--------------------------------------
2020-08-17 20:47:31 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/io.i
2016-10-07 20:48:49 +00:00
*--------------------------------------
2018-12-18 14:37:07 +00:00
.DUMMY
.OR ZPBIN
ZS.START
ZPPTR1 .BS 2
ZPPTR2 .BS 2
2020-03-04 16:38:32 +00:00
MEM.COUNT .BS 1
USED.COUNT .BS 1
bSTOP .BS 1
ZPReadAux sta SETREADAUX
lda (ZPPTR1),y
sta CLRREADAUX
rts
2020-08-17 20:47:31 +00:00
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
2019-10-03 06:25:27 +00:00
*--------------------------------------
2016-10-07 20:48:49 +00:00
.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
2020-03-04 16:38:32 +00:00
L.MSG1X .DA MSG1X
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
.DA 0
*--------------------------------------
2019-02-01 16:32:29 +00:00
CS.INIT clc
2020-03-04 16:38:32 +00:00
CS.INIT.RTS rts
2016-10-07 20:48:49 +00:00
*--------------------------------------
2020-03-04 16:38:32 +00:00
CS.RUN ldx #ZPCodeLen-1
2019-02-01 16:32:29 +00:00
2020-03-04 16:38:32 +00:00
.1 lda ZPCode,x
sta ZPReadAux,x
dex
bpl .1
2019-02-01 16:32:29 +00:00
2020-03-04 16:38:32 +00:00
>LEA.G MemStat
>SYSCALL GetMemStat
2019-02-20 16:07:43 +00:00
2020-03-04 16:38:32 +00:00
jsr CS.RUN.INIT
CS.RUN.LOOP inc MEM.COUNT skip slot 0
lda bSTOP
2019-02-20 16:07:43 +00:00
beq .1
2020-02-18 06:55:54 +00:00
2019-02-25 07:39:19 +00:00
.10 >SYSCALL GetChar
2020-03-04 16:38:32 +00:00
bcs CS.INIT.RTS
cmp #3 Ctrl-C
beq CS.INIT.RTS
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
cmp #$13 Ctrl-S
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
stz bSTOP
2018-08-20 15:15:37 +00:00
.1 lda (ZPPTR1)
2016-10-07 20:48:49 +00:00
bpl .2
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
inc USED.COUNT
2020-02-18 06:55:54 +00:00
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
2020-03-04 16:38:32 +00:00
.3 lda MEM.COUNT
2018-08-20 15:15:37 +00:00
>CMP.G MemStat+S.MSTAT.MLast
2020-03-04 16:38:32 +00:00
bne CS.RUN.LOOP
jsr CS.RUN.MSTAT
jsr CS.RUN.INIT
CS.RUN.LOOPX inc MEM.COUNT skip slot 0
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
lda bSTOP
beq .1
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
.10 >SYSCALL GetChar
bcs CS.INIT.RTS
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
cmp #3 Ctrl-C ?
beq CS.INIT.RTS
cmp #$13 Ctrl-S
bne .10
stz bSTOP
.1 ldy #S.MEM.F
jsr ZPReadAux
bpl .2
inc USED.COUNT
.2 jsr CS.RUN.PRINTMEMX
lda ZPPTR1
clc
adc #S.MEM
sta ZPPTR1
bcc .3
inc ZPPTR1+1
.3 lda MEM.COUNT
>CMP.G MemStat+S.MSTAT.XLast
bne CS.RUN.LOOPX
CS.RUN.XSTAT >PUSHW L.MSG2
>PUSHB USED.COUNT
>PUSHB MEM.COUNT
>PUSHBI 2
>SYSCALL PrintF
>PUSHW L.MSG3
>PUSHW.G MemStat+S.MSTAT.XH
>PUSHW.G MemStat+S.MSTAT.XF
>PUSHW.G MemStat+S.MSTAT.XL
>LDA.G MemStat+S.MSTAT.XF
sec
>SBC.G MemStat+S.MSTAT.XL
pha
>LDA.G MemStat+S.MSTAT.XF+1
>SBC.G MemStat+S.MSTAT.XL+1
ply
>PUSHYA
>PUSHBI 8
>SYSCALL PrintF
lda #0
sec
rts
*--------------------------------------
CS.RUN.MSTAT >PUSHW L.MSG2
>PUSHB USED.COUNT
>PUSHB MEM.COUNT
2018-08-22 15:23:27 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2016-10-07 20:48:49 +00:00
2020-02-18 06:55:54 +00:00
>PUSHW L.MSG3
2018-07-24 06:24:23 +00:00
>PUSHW.G MemStat+S.MSTAT.MH
>PUSHW.G MemStat+S.MSTAT.MF
>PUSHW.G MemStat+S.MSTAT.ML
>LDA.G MemStat+S.MSTAT.MF
2020-02-18 06:55:54 +00:00
sec
>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
2020-02-18 06:55:54 +00:00
>PUSHBI 8
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-02-18 06:55:54 +00:00
2018-08-11 10:57:57 +00:00
lda #0
2019-10-03 06:25:27 +00:00
sec
2016-10-07 20:48:49 +00:00
rts
*--------------------------------------
2020-03-04 16:38:32 +00:00
CS.RUN.INIT >LDYAI Mem.Table+S.MEM skip slot 0
>STYA ZPPTR1
>LDYA L.MSG0
>SYSCALL PutS
stz MEM.COUNT
stz USED.COUNT
rts
*--------------------------------------
2020-02-18 06:55:54 +00:00
CS.RUN.PRINTMEM >PUSHW L.MSG1
2020-03-04 16:38:32 +00:00
>PUSHB MEM.COUNT
2018-08-22 15:23:27 +00:00
lda (ZPPTR1) Get flags
ldy #MEM.FLAGS+7
ldx #7
2020-02-18 06:55:54 +00:00
.20 lsr
pha
lda #'-'
bcc .30
2020-02-18 06:55:54 +00:00
lda MSG.FLAGS,x
2020-02-18 06:55:54 +00:00
.30 sta (pData),y
pla
dey
dex
2019-10-03 06:25:27 +00:00
bpl .20
>PUSHEA.G MEM.FLAGS
2020-02-18 06:55:54 +00:00
ldy #S.MEM.OWNERPID
lda (ZPPTR1),y
2020-03-04 16:38:32 +00:00
tax
2020-02-18 06:55:54 +00:00
>PUSHA
ldy #S.MEM.REFCNT
lda (ZPPTR1),y
>PUSHA
ldy #S.MEM.PTR+1
lda (ZPPTR1),y
>PUSHA
dey
lda (ZPPTR1),y
>PUSHA
ldy #S.MEM.LEN+1
lda (ZPPTR1),y
>PUSHA
dey
lda (ZPPTR1),y
>PUSHA
lda (ZPPTR1) Get flags
bpl .12
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
txa
2018-12-18 14:37:07 +00:00
jsr CS.RUN.CHECKPS
bcc .12
2020-02-18 06:55:54 +00:00
>PUSHW L.MSG1.INV
2018-08-22 15:23:27 +00:00
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2018-08-22 15:23:27 +00:00
.12 >PUSHBI 9
2020-02-28 07:21:46 +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
2020-02-18 06:55:54 +00:00
CS.RUN.PRINTMEM.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
2020-03-04 16:38:32 +00:00
ldy #0
.1 lda (ZPPTR2),y Check if it looks like a printable string
beq .11
2020-03-04 16:38:32 +00:00
bmi .2
2020-03-04 16:38:32 +00:00
2016-10-07 20:48:49 +00:00
cmp #$20
bcc .2 not printable....->hex
2020-03-04 16:38:32 +00:00
iny
2016-10-07 20:48:49 +00:00
bne .1
2020-02-18 06:55:54 +00:00
.11 >PUSHW L.MSG1.STR
tya
beq .2 Starting with 0...PrintHEX
>PUSHA len
>PUSHW ZPPTR2 String
2018-08-22 15:23:27 +00:00
>PUSHBI 3
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
>SYSCALL PrintF
rts
2020-02-18 06:55:54 +00:00
.2 >PUSHW L.MSG1.HEX
ldy #0
.3 >PUSHB (ZPPTR2),y
2020-02-18 06:55:54 +00:00
iny
cpy #16
bne .3
2018-08-22 15:23:27 +00:00
>PUSHBI 16
2020-02-18 06:55:54 +00:00
2020-03-04 16:38:32 +00:00
>SYSCALL PrintF
rts
2018-08-22 15:23:27 +00:00
CS.RUN.PRINTMEM.BIN
2020-02-18 06:55:54 +00:00
>PUSHW L.MSG1.BIN
2018-08-22 15:23:27 +00:00
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
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
rts
2020-03-04 16:38:32 +00:00
*--------------------------------------
CS.RUN.PRINTMEMX
>PUSHW L.MSG1X
>PUSHB MEM.COUNT
ldy #S.MEM.F Get flags
jsr ZPReadAux
ldy #MEM.FLAGS+7
ldx #7
.20 lsr
pha
lda #'-'
bcc .30
2020-03-06 16:20:29 +00:00
lda MSG.FLAGSX,x
2020-03-04 16:38:32 +00:00
.30 sta (pData),y
pla
dey
dex
bpl .20
>PUSHEA.G MEM.FLAGS
ldy #S.MEM.OWNERPID
jsr ZPReadAux
tax
>PUSHA
ldy #S.MEM.REFCNT
jsr ZPReadAux
>PUSHA
ldy #S.MEM.PTR+1
jsr ZPReadAux
>PUSHA
dey
jsr ZPReadAux
>PUSHA
ldy #S.MEM.LEN+1
jsr ZPReadAux
>PUSHA
dey
jsr ZPReadAux
>PUSHA
ldy #S.MEM.F
jsr ZPReadAux Get flags
bpl .12
2020-03-06 16:20:29 +00:00
2020-03-04 16:38:32 +00:00
txa
jsr CS.RUN.CHECKPS
bcc .12
2020-03-06 16:20:29 +00:00
2020-03-04 16:38:32 +00:00
>PUSHW L.MSG1.INV
>PUSHBI 0
>SYSCALL PrintF
.12 >PUSHBI 9
>SYSCALL PrintF
rts
2016-10-07 20:48:49 +00:00
*--------------------------------------
2018-12-18 14:37:07 +00:00
CS.RUN.CHECKPS ldx #0
2020-03-04 16:38:32 +00:00
2018-12-18 14:37:07 +00:00
.1 cmp PS.Table.PID,x
beq .8
2020-03-04 16:38:32 +00:00
2018-12-18 14:37:07 +00:00
inx
2020-03-06 16:20:29 +00:00
cpx #K.PS.MAX
2018-12-18 14:37:07 +00:00
bne .1
2020-03-04 16:38:32 +00:00
2018-12-18 14:37:07 +00:00
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
2020-03-04 16:38:32 +00:00
ZPCode sta SETREADAUX
lda (ZPPTR1),y
sta CLRREADAUX
rts
ZPCodeLen .EQ *-ZPCode
*--------------------------------------
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 "
2020-03-04 16:38:32 +00:00
MSG1X .AZ "$%h %s %3d %3d $%H %5D\e[0m\r\n"
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"
2020-02-18 06:55:54 +00:00
MSG3 .AS "High Memory: $%H\r\n"
.AS "Free ULimit: $%H\r\n"
.AS "Low Memory: $%H\r\n"
2020-03-04 16:38:32 +00:00
.AZ "\r\nFree Memory: %D Bytes.\r\n\r\n"
2019-11-15 14:40:48 +00:00
MSG.FLAGS .AS "UZXAfcds"
2020-03-06 16:20:29 +00:00
MSG.FLAGSX .AS "UZXAidep"
2016-10-07 20:48:49 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
MemStat .BS S.MSTAT
MEM.FLAGS .BS 9
2020-08-17 20:47:31 +00:00
DS.END .ED
2016-10-07 20:48:49 +00:00
*--------------------------------------
MAN
2020-08-17 20:47:31 +00:00
SAVE usr/src/bin/memdump.s
2016-10-07 20:48:49 +00:00
ASM