aboutsummaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/blk.c2
-rw-r--r--c/gbos.h1
-rw-r--r--c/libc.s10
-rw-r--r--c/ls.c8
4 files changed, 14 insertions, 7 deletions
diff --git a/c/blk.c b/c/blk.c
index adf2a58..36839c0 100644
--- a/c/blk.c
+++ b/c/blk.c
@@ -6,7 +6,7 @@ void main(void) {
if (argc >= 3 && argv[0][0] == 'f') {
bfill(atou(argv[1]), atou(argv[2]));
} else if (argc >= 2 && argv[0][0] == 'p') {
- putu(bpeek(atou(argv[1]))); nl();
+ putu(bpeek2(atou(argv[1]), argc>=3?atou(argv[2]):0)); nl();
} else {
puts("usage: blk fill <n> <v> | blk peek <n>"); nl();
}
diff --git a/c/gbos.h b/c/gbos.h
index 03a91de..6badd16 100644
--- a/c/gbos.h
+++ b/c/gbos.h
@@ -45,4 +45,5 @@ void yield(void);
unsigned char reap(void); /* reap a finished bg job, or 0 */
void bfill(unsigned char block, unsigned char byte); /* [debug] disk */
unsigned char bpeek(unsigned char block); /* [debug] disk */
+unsigned char bpeek2(unsigned char block, unsigned char off);
#endif
diff --git a/c/libc.s b/c/libc.s
index 5b81dca..c245bbd 100644
--- a/c/libc.s
+++ b/c/libc.s
@@ -200,7 +200,7 @@ _reap:
rst #0x30
ret
- .globl _bfill, _bpeek
+ .globl _bfill, _bpeek, _bpeek2
;; void bfill(unsigned char block /*A*/, unsigned char byte /*E*/)
_bfill:
ld b, a
@@ -210,6 +210,14 @@ _bfill:
;; unsigned char bpeek(unsigned char block /*A*/) -> A
_bpeek:
ld b, a
+ ld e, #0
ld c, #24 ; SYS_BPEEK
rst #0x30
ret
+ ;; unsigned char bpeek2(unsigned char block /*A*/, unsigned char off /*E*/) -> A
+_bpeek2:
+ ld b, a
+ ld c, #24 ; SYS_BPEEK (off already in E)
+ rst #0x30
+ ret
+
diff --git a/c/ls.c b/c/ls.c
index f7e5161..5d5ce43 100644
--- a/c/ls.c
+++ b/c/ls.c
@@ -1,9 +1,7 @@
#include "gbos.h"
-/* ls: list files in the RAM filesystem. */
+/* ls: list files in the filesystem. */
void main(void) {
- char name[9];
+ char name[16];
unsigned char i;
- for (i = 0; i < 8; i++) {
- if (flist(i, name)) { name[8] = 0; puts(name); nl(); }
- }
+ for (i = 0; flist(i, name); i++) { name[15] = 0; puts(name); nl(); }
}