comparison 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
comparison
equal deleted inserted replaced
8:96a067cf4c4f 9:cb7aa75418b8
57 prog = (char*)mem; 57 prog = (char*)mem;
58 disasm(pc,pc); 58 disasm(pc,pc);
59 } 59 }
60 60
61 char *romfile = "v09.rom"; 61 char *romfile = "v09.rom";
62 int romstart = 0x8000; 62 long romstart = 0x8000;
63 63
64 long 64 long
65 filesize(FILE *image) 65 filesize(FILE *image)
66 { 66 {
67 struct stat buf; 67 struct stat buf;
79 if((image=fopen("..\\v09.rom","rb"))==NULL) { 79 if((image=fopen("..\\v09.rom","rb"))==NULL) {
80 perror("v09, image file"); 80 perror("v09, image file");
81 exit(2); 81 exit(2);
82 } 82 }
83 long len = filesize(image); 83 long len = filesize(image);
84 fread(mem+romstart,len,1,image); 84 if (romstart==0x8000) {
85 #ifdef USE_MMU
86 romstart = memsize - len;
87 #else
88 romstart = 0x10000 - len;
89 #endif
90 }
91 fread(mem+(romstart&0xffff),len,1,image);
85 fclose(image); 92 fclose(image);
86 } 93 }
87 94
88 void usage(void) 95 void usage(void)
89 { 96 {
90 fprintf(stderr,"Usage: v09 [-l romstart] [-rom rom-image] [-t tracefile [-tl addr] [-nt]" 97 fprintf(stderr,"Usage: v09 [-rom rom-image] [-l romstart] [-t tracefile [-tl addr] [-nt]"
91 "[-th addr] ]\n[-e escchar] \n"); 98 "[-th addr] ]\n[-e escchar] \n");
92 exit(1); 99 exit(1);
93 } 100 }
94 101
95 102
114 tracing=1;attention=1; 121 tracing=1;attention=1;
115 } else if (strcmp(argv[i],"-rom")==0) { 122 } else if (strcmp(argv[i],"-rom")==0) {
116 i++; 123 i++;
117 timer = 0; // non standard rom image, don't start timer 124 timer = 0; // non standard rom image, don't start timer
118 romfile = argv[i]; 125 romfile = argv[i];
126
119 } else if (strcmp(argv[i],"-0")==0) { 127 } else if (strcmp(argv[i],"-0")==0) {
120 i++; 128 i++;
121 disk[0] = fopen(argv[i],"r+"); 129 disk[0] = fopen(argv[i],"r+");
122 } else if (strcmp(argv[i],"-1")==0) { 130 } else if (strcmp(argv[i],"-1")==0) {
123 i++; 131 i++;
144 } else usage(); 152 } else usage();
145 } 153 }
146 #ifdef USE_MMU 154 #ifdef USE_MMU
147 phymem = malloc(memsize); 155 phymem = malloc(memsize);
148 mem = phymem + memsize - 0x10000 ; 156 mem = phymem + memsize - 0x10000 ;
157 mmu = mem + 0xffa0;
149 #else 158 #else
150 #ifdef MSDOS 159 #ifdef MSDOS
151 if((mem=farmalloc(65535))==0) { 160 if((mem=farmalloc(65535))==0) {
152 fprintf(stderr,"Not enough memory\n"); 161 fprintf(stderr,"Not enough memory\n");
153 exit(2); 162 exit(2);