mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-14 13:29:02 +00:00
320 lines
5.8 KiB
Plaintext
320 lines
5.8 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/BIN/DEV/MEMDUMP
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/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 CS
|
||
.DA DS.END-DS.START DS
|
||
.DA #32 SS
|
||
.DA #4 ZP
|
||
.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
|
||
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.MSG.FREE .DA MSG.FREE
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT >INC.G MEM.COUNT Skip SLOT0
|
||
|
||
>LEA.G MemStat
|
||
>SYSCALL GetMemStat.YA
|
||
|
||
* lda (pPs)
|
||
* ora #S.PS.F.EVENT Now accept events
|
||
* sta (pPs)
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN >SYSCALL GetChar
|
||
bcs .13
|
||
|
||
cmp #3 Ctrl-C ?
|
||
beq .9
|
||
|
||
cmp #19 Ctrl-S ?
|
||
bne .12
|
||
|
||
ldy #bSTOP
|
||
lda (pData),y
|
||
eor #$ff
|
||
sta (pData),y
|
||
bra .13
|
||
|
||
.12 ldy #bSTOP
|
||
lda #0
|
||
sta (pData),y
|
||
|
||
.13 ldy #bSTOP
|
||
lda (pData),y
|
||
bne .8
|
||
|
||
>LDA.G MEM.COUNT
|
||
>CMP.G MemStat+S.MEMSTAT.MLastSlot
|
||
beq .10
|
||
|
||
ldy #LINE.COUNT
|
||
lda (pData),y
|
||
bne .1
|
||
|
||
>LDYA L.MSG0
|
||
>SYSCALL PrintF.YA
|
||
|
||
.1 >LDA.G MEM.COUNT
|
||
>SYSCALL GetMemByID.A
|
||
>STYA ZPPTR1
|
||
lda (ZPPTR1)
|
||
bpl .2
|
||
|
||
>INC.G USED.COUNT
|
||
|
||
.2 jsr CS.RUN.PRINTMEM
|
||
|
||
>INC.G MEM.COUNT
|
||
|
||
.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 PrintF.YA
|
||
|
||
>LDYA.G MemStat+S.MEMSTAT.MH
|
||
>PUSHYA
|
||
>LDYA L.MSG3
|
||
>SYSCALL PrintF.YA
|
||
|
||
>LDYA.G MemStat+S.MEMSTAT.MF
|
||
>PUSHYA
|
||
>LDYA L.MSG4
|
||
>SYSCALL PrintF.YA
|
||
|
||
>LDYA.G MemStat+S.MEMSTAT.ML
|
||
>PUSHYA
|
||
>LDYA L.MSG5
|
||
>SYSCALL PrintF.YA
|
||
|
||
sec
|
||
>LDA.G MemStat+S.MEMSTAT.MF
|
||
>SBC.G MemStat+S.MEMSTAT.ML
|
||
pha
|
||
>LDA.G MemStat+S.MEMSTAT.MF+1
|
||
>SBC.G MemStat+S.MEMSTAT.ML+1
|
||
ply
|
||
|
||
>PUSHYA
|
||
>LDYA L.MSG.FREE
|
||
>SYSCALL PrintF.YA
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.PRINTMEM ldy #S.MEM.LEN+1
|
||
lda (ZPPTR1),y
|
||
>PUSHA
|
||
dey
|
||
lda (ZPPTR1),y
|
||
>PUSHA
|
||
|
||
ldy #S.MEM.PTR+1
|
||
lda (ZPPTR1),y
|
||
>PUSHA
|
||
dey
|
||
lda (ZPPTR1),y
|
||
>PUSHA
|
||
|
||
ldy #S.MEM.REFCNT
|
||
lda (ZPPTR1),y
|
||
>PUSHA
|
||
|
||
ldy #S.MEM.OWNERPID
|
||
lda (ZPPTR1),y
|
||
>PUSHA
|
||
|
||
lda (ZPPTR1) Get flags
|
||
|
||
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
|
||
|
||
>LDA.G MEM.COUNT
|
||
>PUSHA
|
||
|
||
lda (ZPPTR1) Get flags
|
||
bpl .12
|
||
|
||
ldy #S.MEM.OWNERPID
|
||
lda (ZPPTR1),y
|
||
>SYSCALL GetPSStatus.A
|
||
bcc .12
|
||
|
||
>LDYA L.MSG1.INV
|
||
>SYSCALL PrintF.YA
|
||
|
||
.12 >LDYA L.MSG1
|
||
>SYSCALL PrintF.YA
|
||
|
||
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
|
||
|
||
ldy #$0
|
||
|
||
.1 lda (ZPPTR2),y Check if it looks like a printable string
|
||
beq .11
|
||
bmi .2
|
||
cmp #$20
|
||
bcc .2 not printable....->hex
|
||
iny
|
||
bne .1
|
||
|
||
.11 tya
|
||
beq .2 Startig with 0...PrintHEX
|
||
|
||
>PUSHW ZPPTR2 String
|
||
tya Len
|
||
>PUSHA
|
||
>LDYA L.MSG1.STR
|
||
bra .8
|
||
|
||
.2 ldy #15
|
||
|
||
.3 >PUSHB (ZPPTR2),y
|
||
dey
|
||
bpl .3
|
||
|
||
>LDYA L.MSG1.HEX
|
||
bra .8
|
||
****** BIN
|
||
.7 >SYSCALL GetMemPtr.A
|
||
>PUSHYA
|
||
>LDYA L.MSG1.BIN
|
||
|
||
.8 >SYSCALL PrintF.YA
|
||
|
||
>INC.G LINE.COUNT
|
||
cmp #PAGELEN
|
||
beq .9
|
||
rts
|
||
|
||
.9 lda #$FF
|
||
>STA.G bSTOP
|
||
|
||
inc
|
||
>STA.G LINE.COUNT
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG0 >CSTR " # Flags PID REF PTR LEN BINPATH/DATA\r\n"
|
||
MSG1.INV >CSTR "\e[7m"
|
||
MSG1 >CSTR "%03d %s %03d %03d $%H %05D "
|
||
MSG1.BIN >CSTR "{%s}\e[0m\r\n"
|
||
MSG1.STR >CSTR "[%03d:%s]\e[0m\r\n"
|
||
MSG1.HEX >CSTR "?HEX:%h%h.%h%h.%h%h.%h%h.%h%h.%h%h.%h%h.%h%h\e[0m\r\n"
|
||
MSG2 >CSTR "\r\nAllocated hMem:%d, Total:%d\r\n"
|
||
MSG3 >CSTR "High Memory: $%H\r\n"
|
||
MSG4 >CSTR "Free ULimit: $%H\r\n"
|
||
MSG5 >CSTR "Low Memory: $%H\r\n"
|
||
MSG.FREE >CSTR "\r\nFree Memory: %D Bytes.\r\n"
|
||
MSG.FLAGS .AS "UZCNA--"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
LINE.COUNT .BS 1
|
||
MEM.COUNT .BS 1
|
||
USED.COUNT .BS 1
|
||
bSTOP .BS 1
|
||
MemStat .BS S.MEMSTAT
|
||
MEM.FLAGS .BS 9
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/BIN/MEMDUMP.S
|
||
ASM
|