annotate src/v09.c @ 127:321b7fffadab

TL/1 simple test worked
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 05 Jan 2019 19:08:54 +0900
parents 4652761a60f9
children ef5959682d03
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);
20
49fac9474858 separate trace file
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
46 extern void init_term(void) ;
64
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
47 #ifdef USE_VDISK
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
48 extern int setVdisk(int drv,char *name) ;
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
49 #endif
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
50
20
49fac9474858 separate trace file
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
51
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 void do_trace(FILE *tracefile)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 Word pc=pcreg;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 Byte ir;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 // fprintf(tracefile,"pc=%04x ",pc);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 // ir=mem[pc++];
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 // 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
60 // fprintf(tracefile," ");
85
4652761a60f9 mmeu fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 84
diff changeset
61 fprintf(tracefile,"x=%04x y=%04x u=%04x s=%04x a=%02x b=%02x cc=%02x dp=%02x pc=",
4652761a60f9 mmeu fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 84
diff changeset
62 xreg,yreg,ureg,sreg,*areg,*breg,ccreg,dpreg);
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 fp = tracefile;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 disasm(pc,pc);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 }
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 char *romfile = "v09.rom";
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
68 long romstart = 0x8000;
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 long
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 filesize(FILE *image)
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 struct stat buf;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 fstat(fileno(image),&buf);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 return buf.st_size;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 void
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 read_image()
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 FILE *image;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 if((image=fopen(romfile,"rb"))==NULL)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 if((image=fopen("../v09.rom","rb"))==NULL)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 if((image=fopen("..\\v09.rom","rb"))==NULL) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 perror("v09, image file");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 exit(2);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 long len = filesize(image);
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
90 /*
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
91 *
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
92 * 0x0000-0xdfff normal mem
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
93 * 0xxxxx-0xdfff rom
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
94 * 0xe000-0xe100 i/o
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
95 * 0xe000-0xffff rom
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
96 *
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
97 * discless boot
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
98 * rom image will be copyied from 0xed00-0x1xxxx
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
99 * boot copies 0x10000-0x1xxxx to os9's boot memory
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
100 */
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
101 #ifdef USE_MMU
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
102 /*
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
103 * In case of Coco, there is no ROM (switched out after boot )
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
104 * 0x00000-0x0fdff normal mem
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
105 * 0x0fe00-0x0ffff ram fixed address ram including io
84
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
106 * 0x10000-0x1fffff ram (2MB memory )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
107 * >0x200000 lapround
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
108 *
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
109 * discless boot
84
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
110 * rom image will be copyied from 0x7eed00-0x7fxxxx (all ram)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
111 * boot copies 0x800000-0x8xxxx to os9's boot memory (ususally done by rel.asm )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
112 * (original system copies it from fd or hd)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
113 * after that 0x800000-0x8xxxx will be all free
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
114 */
84
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
115 phymem = malloc(memsize );
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
116 rommemsize = memsize ;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
117 mem = phymem + 0x38*0x2000;
24
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 20
diff changeset
118 mmu = &mem[0xffa0];
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
119 prog = (char*)mem;
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
120 if (romstart==0x8000) {
33
7c5379eb406e nitors9 version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
121 romstart = memsize ; // full 512kb mem
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
122 }
84
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
123 fread(mem+ 0xe000,len,1,image);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
124 mem[0xff90] = 0;
33
7c5379eb406e nitors9 version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 29
diff changeset
125 mem[0xffa7] = 0x3f;
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
126 #else
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
127 if (romstart==0x8000) {
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
128 romstart = 0x10000 - len;
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
129 }
29
3c14d647bb51 assembler and emulator fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
130 fread(mem+(romstart&0xffff),len,1,image);
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
131 #endif
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 fclose(image);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 void usage(void)
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 {
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
137 fprintf(stderr,"Usage: v09 [-rom rom-image] [-l romstart] [-t tracefile [-tl addr] [-nt]"
64
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
138 "[-[01] disk-image ] "
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
139 #ifdef USE_VDISK
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
140 "[v vdisk-base-dir ] "
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
141 #endif
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 "[-th addr] ]\n[-e escchar] \n");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 exit(1);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 #define CHECKARG if(i==argc)usage();else i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 int
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 main(int argc,char *argv[])
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 char *imagename=0;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 int i;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 int setterm = 1;
55
8d151f303bee FIRQ does not worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
155 timerirq = 2; // use FIRQ default
84
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
156 memsize = 512*1024*4; // full 2 mbute
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 escchar='\x1d';
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 tracelo=0;tracehi=0xffff;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 for(i=1;i<argc;i++) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 if (strcmp(argv[i],"-t")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 if((tracefile=fopen(argv[i],"w"))==NULL) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 perror("v09, tracefile");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 exit(2);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 tracing=1;attention=1;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 } else if (strcmp(argv[i],"-rom")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 i++;
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
169 timer = 3; // non standard rom image, don't start timer, and timder start call enabled
55
8d151f303bee FIRQ does not worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
170 timerirq = 1 ; // os9 cannot handle FIRQ
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 romfile = argv[i];
9
cb7aa75418b8 mmu and io
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
172
2
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
173 } 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
174 i++;
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
175 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
176 } 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
177 i++;
31d96e2b364e add virtual hd option to v09
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
178 disk[1] = fopen(argv[i],"r+");
64
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
179 #ifdef USE_VDISK
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
180 } else if (strcmp(argv[i],"-v")==0) {
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
181 i++;
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
182 setVdisk(0,argv[i]);
41f14f365b34 add trace command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
183 #endif
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 } else if (strcmp(argv[i],"-tl")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 tracelo=strtol(argv[i],(char**)0,0);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 } else if (strcmp(argv[i],"-th")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 tracehi=strtol(argv[i],(char**)0,0);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 } else if (strcmp(argv[i],"-e")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 escchar=strtol(argv[i],(char**)0,0);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 } else if (strcmp(argv[i],"-l")==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 i++;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 romstart=strtol(argv[i],(char**)0,0);
1
3c736a81b886 add disk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
196 } 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
197 attention = escape = 1;
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
198 timer = 1; // desable default timer interrupt and don't start timer on timer start IO
4
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
199 } else if (strcmp(argv[i],"-m")==0) {
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
200 i++;
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
201 memsize=strtol(argv[i],(char**)0,0) & ~0xffff;
6159cc57d44e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
202 if (memsize < 512*1024) memsize = 512*1024;
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 } else usage();
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 #ifdef MSDOS
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 if((mem=farmalloc(65535))==0) {
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 fprintf(stderr,"Not enough memory\n");
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 exit(2);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 #endif
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 read_image();
20
49fac9474858 separate trace file
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
212 init_term();
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 if (setterm) set_term(escchar);
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 pcreg=(mem[0xfffe]<<8)+mem[0xffff];
16
807141dc5ee8 sysgo fork
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
215 prog = (char*)mem; // for disasm
0
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 interpr();
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 return 0;
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 }
9a224bd9b45f os9 emulation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219