diff v09.c @ 9:cb7aa75418b8

mmu and io
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 05 Jul 2018 16:00:19 +0900
parents 6159cc57d44e
children ce7323f9b937
line wrap: on
line diff
--- a/v09.c	Thu Jul 05 12:07:06 2018 +0900
+++ b/v09.c	Thu Jul 05 16:00:19 2018 +0900
@@ -59,7 +59,7 @@
 } 
 
 char *romfile = "v09.rom";
-int romstart = 0x8000;
+long romstart = 0x8000;
 
 long
 filesize(FILE *image)
@@ -81,13 +81,20 @@
     exit(2);
  }
  long len = filesize(image);
- fread(mem+romstart,len,1,image);
+ if (romstart==0x8000) {
+#ifdef USE_MMU
+     romstart = memsize - len;
+#else
+     romstart = 0x10000 - len; 
+#endif
+ }
+ fread(mem+(romstart&0xffff),len,1,image);
  fclose(image);
 }
 
 void usage(void)
 {
- fprintf(stderr,"Usage: v09 [-l romstart] [-rom rom-image] [-t tracefile [-tl addr] [-nt]"
+ fprintf(stderr,"Usage: v09 [-rom rom-image] [-l romstart] [-t tracefile [-tl addr] [-nt]"
                 "[-th addr] ]\n[-e escchar] \n");
  exit(1); 
 }
@@ -116,6 +123,7 @@
      i++;
      timer = 0;  // non standard rom image, don't start timer
      romfile = argv[i];
+
    } else if (strcmp(argv[i],"-0")==0) {
       i++;
       disk[0] = fopen(argv[i],"r+");
@@ -146,6 +154,7 @@
  #ifdef USE_MMU
     phymem = malloc(memsize);
     mem    = phymem + memsize - 0x10000 ;
+    mmu    = mem + 0xffa0;
  #else
  #ifdef MSDOS
  if((mem=farmalloc(65535))==0) {