From 2c8d464108a51cb6c99a4e8731f34c94f20ea021 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Thu, 4 Aug 2022 19:28:36 -0700 Subject: [PATCH] Add MEM command, inspired by A2osX's BASIC.FX --- COMMANDS | 1 + README.md | 1 + mem.cmd.s | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 mem.cmd.s diff --git a/COMMANDS b/COMMANDS index 7769cd0..425556b 100644 --- a/COMMANDS +++ b/COMMANDS @@ -7,6 +7,7 @@ copy date echo hello +mem online type touch diff --git a/README.md b/README.md index c7ff3b3..bab39e2 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Sample commands included: * `ECHO` - echoes back anything following the command * `CD` - like `PREFIX` but accepts `..`, e.g. `cd ../dir` * `ONLINE` - lists online volumes (volume name, slot and drive) +* `MEM` - show memory stats for the BASIC environment * `COPY` - copy a single file, e.g. `copy /path/to/file,dstfile` * `TYPE` - show file contents (TXT, BAS, or BIN/other), e.g. `type filename` * `TOUCH` - apply current ProDOS date/time to a file's modification time, e.g. `touch filename` diff --git a/mem.cmd.s b/mem.cmd.s new file mode 100644 index 0000000..8812ac5 --- /dev/null +++ b/mem.cmd.s @@ -0,0 +1,76 @@ +;;; ============================================================ +;;; +;;; MEM - Print memory stats +;;; +;;; Usage: MEM +;;; +;;; Inspiration from A2osX +;;; +;;; ============================================================ + + .include "apple2.inc" + .include "more_apple2.inc" + +;;; ============================================================ + + .org $4000 + + jsr CROUT + jsr CROUT + +.macro SHOW suffix + lda #<.ident(.concat("str_", .string(suffix))) + ldx #>.ident(.concat("str_", .string(suffix))) + ldy #.ident(.concat("addr_", .string(suffix))) + jsr Print +.endmacro + + SHOW pgm_start + SHOW lomem + SHOW array_start + SHOW array_end + SHOW string_start + SHOW himem + + clc + rts + +addr_pgm_start := $67 +str_pgm_start: .byte "Program start: $", 0 +addr_lomem := $69 +str_lomem: .byte "LOMEM: $", 0 +addr_array_start := $6B +str_array_start: .byte "Array start: $", 0 +addr_array_end := $6D +str_array_end: .byte "Array end: $", 0 +addr_string_start := $6F +str_string_start: .byte "String start: $", 0 +addr_himem := $73 +str_himem: .byte "HIMEM: $", 0 + +.proc Print + sta msg_addr + stx msg_addr+1 + iny ; MSB first + sty zp_addr + + ldx #0 + msg_addr := *+1 +loop: lda $1234,x ; self-modified + beq :+ + ora #$80 + jsr COUT + inx + bne loop ; always +: + jsr getb + jsr PRBYTE + jsr getb + jsr PRBYTE + jmp CROUT + + zp_addr := *+1 +getb: lda $12 ; self-modified + dec zp_addr + rts +.endproc