annotate v09.c @ 16:807141dc5ee8

sysgo fork
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 08 Jul 2018 09:34:34 +0900
parents 111e5defb8ab
children e3b08716aa53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* 6809 Simulator V09.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Copyright 1994, L.C. Benschop, Eidnhoven The Netherlands.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This version of the program is distributed under the terms and conditions
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 of the GNU General Public License version 2. See the file COPYING.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 THERE IS NO WARRANTY ON THIS PROGRAM!!!
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 This program simulates a 6809 processor.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 System dependencies: short must be 16 bits.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 char must be 8 bits.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 long must be more than 16 bits.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 arrays up to 65536 bytes must be supported.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 machine must be twos complement.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 Most Unix machines will work. For MSODS you need long pointers
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 and you may have to malloc() the mem array of 65536 bytes.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 Define BIG_ENDIAN if you have a big-endian machine (680x0 etc)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 Special instructions:
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 SWI2 writes char to stdout from register B.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 SWI3 reads char from stdout to register B, sets carry at EOF.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 (or when no key available when using term control).
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 SWI retains its normal function.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 CWAI and SYNC stop simulator.
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 */
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #include <stdio.h>
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #include <stdlib.h>
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #include <strings.h>
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #include <sys/stat.h>
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #define engine extern
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #include "v09.h"
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 FILE *tracefile;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
2
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
41 extern FILE *disk[];
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
42 extern FILE *fp; // for disasm
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
43 extern char *prog; // for disasm
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 extern void disasm(int,int);
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
45 extern void do_mmu(Word,Byte);
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 void do_trace(FILE *tracefile)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 Word pc=pcreg;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 Byte ir;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 // fprintf(tracefile,"pc=%04x ",pc);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 // ir=mem[pc++];
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 // fprintf(tracefile,"i=%02x ",ir); if((ir&0xfe)==0x10) fprintf(tracefile,"%02x ",mem[pc]);else
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 // fprintf(tracefile," ");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 fprintf(tracefile,"x=%04x y=%04x u=%04x s=%04x a=%02x b=%02x cc=%02x pc=",
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 xreg,yreg,ureg,sreg,*areg,*breg,ccreg);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 fp = tracefile;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 disasm(pc,pc);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 char *romfile = "v09.rom";
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
62 long romstart = 0x8000;
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 long
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 filesize(FILE *image)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 struct stat buf;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 fstat(fileno(image),&buf);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 return buf.st_size;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 void
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 read_image()
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 FILE *image;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 if((image=fopen(romfile,"rb"))==NULL)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 if((image=fopen("../v09.rom","rb"))==NULL)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 if((image=fopen("..\\v09.rom","rb"))==NULL) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 perror("v09, image file");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 exit(2);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 long len = filesize(image);
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
84 #ifdef USE_MMU
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
85 phymem = malloc(memsize + len - 0x2000);
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
86 rommemsize = memsize + len - 0x2000;
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
87 mem = phymem + memsize - 0x10000 ;
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
88 prog = (char*)mem;
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
89 if (romstart==0x8000) {
11
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
90 romstart = memsize - 0x2000;
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
91 }
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
92 #else
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
93 if (romstart==0x8000) {
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
94 romstart = 0x10000 - len;
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
95 }
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
96 #endif
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
97 fread(mem+(romstart&0xffff),len,1,image);
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 fclose(image);
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
99 #ifdef USE_MMU
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
100 do_mmu(0x91,0); // set mmu
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
101 do_mmu(0xa7,0x3f); // initial mmu value
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
102 #endif
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 void usage(void)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 {
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
107 fprintf(stderr,"Usage: v09 [-rom rom-image] [-l romstart] [-t tracefile [-tl addr] [-nt]"
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 "[-th addr] ]\n[-e escchar] \n");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 exit(1);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 #define CHECKARG if(i==argc)usage();else i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 int
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 main(int argc,char *argv[])
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 char *imagename=0;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 int i;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 int setterm = 1;
4
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
121 memsize = 512*1024;
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 escchar='\x1d';
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 tracelo=0;tracehi=0xffff;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 for(i=1;i<argc;i++) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 if (strcmp(argv[i],"-t")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 if((tracefile=fopen(argv[i],"w"))==NULL) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 perror("v09, tracefile");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 exit(2);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 tracing=1;attention=1;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 } else if (strcmp(argv[i],"-rom")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 i++;
1
3c736a81b886 add disk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
134 timer = 0; // non standard rom image, don't start timer
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 romfile = argv[i];
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
136
2
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
137 } else if (strcmp(argv[i],"-0")==0) {
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
138 i++;
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
139 disk[0] = fopen(argv[i],"r+");
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
140 } else if (strcmp(argv[i],"-1")==0) {
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
141 i++;
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
142 disk[1] = fopen(argv[i],"r+");
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 } else if (strcmp(argv[i],"-tl")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 tracelo=strtol(argv[i],(char**)0,0);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 } else if (strcmp(argv[i],"-th")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 tracehi=strtol(argv[i],(char**)0,0);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 } else if (strcmp(argv[i],"-e")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 escchar=strtol(argv[i],(char**)0,0);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 } else if (strcmp(argv[i],"-l")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 romstart=strtol(argv[i],(char**)0,0);
1
3c736a81b886 add disk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
155 } else if (strcmp(argv[i],"-nt")==0) { // start debugger at the start
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 attention = escape = 1;
1
3c736a81b886 add disk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
157 timer = 0; // no timer
4
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
158 } else if (strcmp(argv[i],"-m")==0) {
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
159 i++;
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
160 memsize=strtol(argv[i],(char**)0,0) & ~0xffff;
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
161 if (memsize < 512*1024) memsize = 512*1024;
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 } else usage();
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 #ifdef MSDOS
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 if((mem=farmalloc(65535))==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 fprintf(stderr,"Not enough memory\n");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 exit(2);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 #endif
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 read_image();
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 if (setterm) set_term(escchar);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 pcreg=(mem[0xfffe]<<8)+mem[0xffff];
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
173 prog = (char*)mem; // for disasm
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 interpr();
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 return 0;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177