From 1741dd8f642629c1cdb762729ae6e37a0fc3792a Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Sat, 7 Jul 2018 22:52:04 -0400 Subject: [PATCH] Created py65/testmio.c02 --- py65/testmio.c02 | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 py65/testmio.c02 diff --git a/py65/testmio.c02 b/py65/testmio.c02 new file mode 100644 index 0000000..7ec21bf --- /dev/null +++ b/py65/testmio.c02 @@ -0,0 +1,56 @@ +/**************************************** + * TESTMIO - Test Memory File Functions * + ****************************************/ + +#include +#include +#include +#include +#include + +char zp = $80; //Zero Page Location for Memory Pointer +char lsb, msb; //Memory Pointer Contents +char passed; //Flags +char c, e, i, mp, s[128]; + +main: + +mp = 0; //Initialize Memory Pointer + +putln("Opening memory file at $8000."); +mp = mopen(zp, &$8000); + +puts(" Memory pointer: "); +prbyte(mp); +if (mp == zp) pass(); else fail(); + +puts(" Address: "); +lsb, msb = maddr(mp); +prbyte(msb); prbyte(lsb); +passed = 1; +if (msb <> $80) passed = 0; +if (lsb <> $00) passed = 0; +if (passed) pass(); else fail(); + +puts(" Error? "); +e = merror(mp); +prbyte(e); +if (e) { puts(" Yes"); fail(); } +else { puts(" No "); pass(); } + +newlin(); +putln("Reading File using mgetc()"); +do { + lsb, msb = maddr(mp); + c = mgetc(mp); + e = meof(mp); + prbyte(msb); prbyte(lsb); puts(": "); + prbyte(c); putc(' '); + if (c>' ') putc(c); else putc(' '); + puts(" EOF: "); prbyte(e); newlin(); +} while (!e); + +goto exit; + +void pass() { putln(" Passed"); } +void fail() { putln(" Failed"); }