aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
Diffstat (limited to 'src/example')
-rw-r--r--src/example/cpc.asm8
-rw-r--r--src/example/dump.c87
2 files changed, 83 insertions, 12 deletions
diff --git a/src/example/cpc.asm b/src/example/cpc.asm
index 1a368f2..0c9ff5e 100644
--- a/src/example/cpc.asm
+++ b/src/example/cpc.asm
@@ -8,7 +8,7 @@
option output-format,cpc
option cpc-start,start
-start: org $8000
+start: org $8000
ld hl,msg
loop:
@@ -16,7 +16,7 @@ loop:
ret z
call $bb5a
inc hl
- jr loop
+ jr loop
-msg: org $8800
- defb "Hello World",0
+ org $8800
+msg: defb "Hello World",0
diff --git a/src/example/dump.c b/src/example/dump.c
index 71d153a..231e495 100644
--- a/src/example/dump.c
+++ b/src/example/dump.c
@@ -2,6 +2,7 @@
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
typedef struct
{
@@ -9,6 +10,45 @@ typedef struct
unsigned char *addr;
} Block;
+static void HexDump(const unsigned char *p, int len)
+{
+ int o = 0;
+ int f;
+ char buff[17] = {0};
+
+ while(o < len)
+ {
+ strcpy(buff, " ");
+
+ printf("%4.4X: ", o);
+
+ for(f = 0; f < 16; f++)
+ {
+ if (o < len)
+ {
+ printf(" %2.2X", p[o]);
+ }
+ else
+ {
+ printf(" **");
+ }
+
+ if (isprint(p[o]))
+ {
+ buff[f] = p[o];
+ }
+ else
+ {
+ buff[f] = '.';
+ }
+
+ o++;
+ }
+
+ printf(" %s\n", buff);
+ }
+}
+
static int Word(FILE *fp)
{
int i0;
@@ -35,23 +75,51 @@ static int Triplet(FILE *fp)
static Block *DumpBlock(FILE *fp)
{
+ static int first = 1;
Block *block;
- Word(fp); /* PILOT */
- Word(fp); /* SYNC1 */
- Word(fp); /* SYNC2 */
- Word(fp); /* ZERO */
- Word(fp); /* ONE */
- Word(fp); /* PILOT LEN */
- getc(fp); /* USED BITS */
- Word(fp); /* PAUSE */
+ if (first)
+ {
+ printf("PILOT=%4.4x\n", Word(fp)); /* PILOT */
+ printf("SYNC1=%4.4x\n", Word(fp)); /* SYNC1 */
+ printf("SYNC2=%4.4x\n", Word(fp)); /* SYNC2 */
+ printf("ZERO=%4.4x\n", Word(fp)); /* ZERO */
+ printf("ONE=%4.4x\n", Word(fp)); /* ONE */
+ printf("PILOT LEN=%4.4x\n", Word(fp)); /* PILOT LEN */
+ printf("USED BITS=%2.2x\n", getc(fp)); /* USED BITS */
+ printf("PAUSE=%4.4x\n", Word(fp)); /* PAUSE */
+ }
+ else
+ {
+ Word(fp); /* PILOT */
+ Word(fp); /* SYNC1 */
+ Word(fp); /* SYNC2 */
+ Word(fp); /* ZERO */
+ Word(fp); /* ONE */
+ Word(fp); /* PILOT LEN */
+ getc(fp); /* USED BITS */
+ Word(fp); /* PAUSE */
+ }
block = malloc(sizeof *block);
block->len = Triplet(fp); /* LEN */
+
+ if (first)
+ {
+ printf("LEN=%6.6x\n", block->len);
+ }
+
block->addr = malloc(block->len);
fread(block->addr, 1, block->len, fp);
+ if (first)
+ {
+ HexDump(block->addr, block->len);
+ }
+
+ first = 1;
+
return block;
}
@@ -114,6 +182,9 @@ int main(int argc, char *argv[])
int count;
int f;
Block *block[256] = {0};
+ char buff[9];
+
+ fread(buff, 1, sizeof buff, stdin);
ch = getc(stdin);