A2osX/BIN/MEMDUMP.S.txt
2016-10-24 17:54:43 +02:00

321 lines
5.7 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.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.DEV/BIN/MEMDUMP
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
*--------------------------------------
PAGELEN .EQ 22
FOOTERLEN .EQ 8
*--------------------------------------
ZPPTR1 .EQ ZPBIN
ZPPTR2 .EQ ZPBIN+2
*--------------------------------------
* 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 Code Length To Relocate
.DA DS.END-DS.START Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG1.BIN .DA MSG1.BIN
L.MSG1.STR .DA MSG1.STR
L.MSG1.HEX .DA MSG1.HEX
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
L.MSG4 .DA MSG4
L.MSG5 .DA MSG5
L.MSG6 .DA MSG6
.DA 0
*--------------------------------------
CS.INIT ldy #MEM.COUNT Skip SLOT0
lda (pData),y
inc
sta (pData),y
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
.9 rts
*--------------------------------------
CS.RUN ldy #bCANCEL
lda (pData),y
bne .9
ldy #bSTOP
lda (pData),y
bne .8
ldy #MEM.COUNT
lda (pData),y
cmp MemMgr.LastSlot
beq .10
ldy #LINE.COUNT
lda (pData),y
bne .1
>LDYA L.MSG0
>SYSCALL PrintFYA
.1 ldy #MEM.COUNT
lda (pData),y
>SYSCALL GetMemByIDA
>STYA ZPPTR1
lda (ZPPTR1)
bpl .2
ldy #USED.COUNT
lda (pData),y
inc
sta (pData),y
.2 jsr CS.RUN.PRINTMEM
ldy #MEM.COUNT
lda (pData),y
inc
sta (pData),y
.8 clc
rts
.9 sec
rts
.10 ldy #LINE.COUNT
lda (pData),y
clc
adc #FOOTERLEN
cmp #PAGELEN
bcc .11
lda #$FF
ldy #bSTOP
sta (pData),y
lda #0
ldy #LINE.COUNT
sta (pData),y
clc
rts
.11 ldy #MEM.COUNT
>PUSHB (pData),y
ldy #USED.COUNT
>PUSHB (pData),y
>LDYA L.MSG2
>SYSCALL PrintFYA
>PUSHW MemMgr.HiMem
>LDYA L.MSG3
>SYSCALL PrintFYA
>PUSHW MemMgr.Free
>LDYA L.MSG4
>SYSCALL PrintFYA
>PUSHW MemMgr.LoMem
>LDYA L.MSG5
>SYSCALL PrintFYA
lda MemMgr.Free
sec
sbc MemMgr.LoMem
tay
lda MemMgr.Free+1
sbc MemMgr.LoMem+1
>PUSHYA
>LDYA L.MSG6
>SYSCALL PrintFYA
sec
rts
*--------------------------------------
CS.RUN.PRINTMEM ldy #S.MEM.LEN
lda (ZPPTR1),y
pha
iny
lda (ZPPTR1),y
ply
>PUSHYA
ldy #S.MEM.PTR
lda (ZPPTR1),y
pha
iny
lda (ZPPTR1),y
ply
>PUSHYA
ldy #S.MEM.REFCNT
lda (ZPPTR1),y
>PUSHA
ldy #S.MEM.OWNERPID
lda (ZPPTR1),y
>PUSHA
lda (ZPPTR1)
>PUSHA
ldy #MEM.COUNT
lda (pData),y
>PUSHA
>LDYA L.MSG1
>SYSCALL PrintFYA
ldy #S.MEM.BIN
lda (ZPPTR1),y
bne .7
****** DATA
ldy #S.MEM.PTR
lda (ZPPTR1),y
sta ZPPTR2
iny
lda (ZPPTR1),y
sta ZPPTR2+1
lda (ZPPTR2)
tay
.1 lda (ZPPTR2),y Check if it looks like a printable string
cmp #$20
bcc .2 not printable....->hex
dey
bne .1
>PUSHW ZPPTR2 String
>PUSHB (ZPPTR2) Len
>LDYA L.MSG1.STR
>SYSCALL PrintFYA
bra .8
.2 ldy #15
.3 >PUSHB (ZPPTR2),y
dey
bpl .3
>LDYA L.MSG1.HEX
>SYSCALL PrintFYA
bra .8
****** BIN
.7 >SYSCALL GetMemPtrA
>PUSHYA
>LDYA L.MSG1.BIN
>SYSCALL PrintFYA
.8 ldy #LINE.COUNT
lda (pData),y
inc
sta (pData),y
cmp #PAGELEN
bne .9
lda #$FF
ldy #bSTOP
sta (pData),y
ldy #LINE.COUNT
lda #0
sta (pData),y
.9 rts
*--------------------------------------
CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
lda (pEvent),y
ldy #S.PS.hINDEV
cmp (pPs),y
bne .9
lda (pEvent)
and #S.EVT.F.KEY is it a KEY event?
beq .9
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
lda (pEvent),y
bne .9
ldy #S.EVT.DATALO
lda (pEvent),y
cmp #$03 Ctrl-C
bne .1
lda #$FF
ldy #bCANCEL
sta (pData),y
bra .8
.1 cmp #$13 Ctrl-S
bne .2
ldy #bSTOP
lda (pData),y
eor #$FF
sta (pData),y
bra .8
.2 ldy #bSTOP
lda #0
sta (pData),y
.8 clc
rts
.9 sec
rts
*--------------------------------------
CS.QUIT clc
rts
*--------------------------------------
CS.END
MSG0 >CSTR "hMem Flags PID REF PTR LEN BINPATH/DATA\n"
MSG1 >CSTR " %03d %b %03d %03d $%H %05D "
MSG1.BIN >CSTR "!BIN:%40S\n"
MSG1.STR >CSTR "#STR:[%03d]:%32S\n"
MSG1.HEX >CSTR "?HEX:%h%h%h%h.%h%h%h%h.%h%h%h%h.%h%h%h%h\n"
MSG2 >CSTR "\nAllocated hMem:%d, Total:%d\n"
MSG3 >CSTR "High Memory: $%H\n"
MSG4 >CSTR "Free ULimit: $%H\n"
MSG5 >CSTR "Low Memory: $%H\n"
MSG6 >CSTR "\nFree Memory: %D Bytes.\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
LINE.COUNT .BS 1
MEM.COUNT .BS 1
USED.COUNT .BS 1
bSTOP .BS 1
bCANCEL .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE BIN/MEMDUMP.S
ASM