Revisión | afbd9e7d9e1b82ec62469069f25c9157b5704a07 (tree) |
---|---|
Tiempo | 2014-06-29 18:46:11 |
Autor | hikarupsp <hikarupsp@user...> |
Commiter | hikarupsp |
オペコードリスト自動生成を追加
@@ -59,9 +59,13 @@ | ||
59 | 59 | </BuildableProductRunnable> |
60 | 60 | <CommandLineArguments> |
61 | 61 | <CommandLineArgument |
62 | - argument = "test.hex" | |
62 | + argument = "-e test.hex" | |
63 | 63 | isEnabled = "YES"> |
64 | 64 | </CommandLineArgument> |
65 | + <CommandLineArgument | |
66 | + argument = "-f i" | |
67 | + isEnabled = "NO"> | |
68 | + </CommandLineArgument> | |
65 | 69 | </CommandLineArguments> |
66 | 70 | <AdditionalOptions> |
67 | 71 | </AdditionalOptions> |
@@ -8,22 +8,86 @@ | ||
8 | 8 | |
9 | 9 | #include "chncpu.h" |
10 | 10 | |
11 | -int main(int argc, const char * argv[]) | |
11 | +int main(int argc, const char *argv[]) | |
12 | 12 | { |
13 | 13 | CHNCPU_RuntimeEnvironment *env; |
14 | + CHNCPU_VMArgs *vmArgs; | |
15 | + | |
16 | + vmArgs = bindVMArgs(argc, argv); | |
17 | + env = CHNCPU_CreateRuntimeEnvironment(CHNCPU_CreateOpTableSet(), CHNCPU_CreateBIOS()); | |
18 | + | |
19 | + if(vmArgs->VMFlags & CHNCPU_VM_FLAG_PRINT_OPLIST){ | |
20 | + printOpTableWikiDoc(env); | |
21 | + return 0; | |
22 | + } | |
14 | 23 | |
15 | - if(argc < 2){ | |
16 | - puts("chncpu:Usage > chncpu filepath [flags]\n"); | |
17 | - exit(EXIT_SUCCESS); | |
18 | - } | |
19 | - env = CHNCPU_CreateRuntimeEnvironment(CHNCPU_CreateOpTableSet(), CHNCPU_CreateBIOS()); | |
20 | - CHNCPU_LoadBinaryFromHexStringFilePath(env, argv[1]); | |
24 | + CHNCPU_LoadBinaryFromHexStringFilePath(env, vmArgs->appPath); | |
21 | 25 | if(!env->errFlags){ |
22 | 26 | CHNCPU_Execute(env); |
23 | 27 | } |
24 | 28 | return 0; |
25 | 29 | } |
26 | 30 | |
31 | +CHNCPU_VMArgs *bindVMArgs(int argc, const char *argv[]) | |
32 | +{ | |
33 | + int i; | |
34 | + const char *s; | |
35 | + CHNCPU_VMArgs *args = malloc(sizeof(CHNCPU_VMArgs)); | |
36 | + if(!args){ | |
37 | + puts("bindVMArgs: malloc error."); | |
38 | + exit(EXIT_FAILURE); | |
39 | + } | |
40 | + | |
41 | + args->appPath = NULL; | |
42 | + args->VMFlags = 0; | |
43 | + | |
44 | + for(i = 0; i < argc; i++){ | |
45 | + s = argv[i]; | |
46 | + if(strcmp("-e", s) == 0){ | |
47 | + i++; | |
48 | + if(i < argc){ | |
49 | + args->appPath = argv[i]; | |
50 | + } else{ | |
51 | + argc = 0; | |
52 | + } | |
53 | + } else if(strcmp("-f", s) == 0){ | |
54 | + i++; | |
55 | + if(i < argc){ | |
56 | + s = argv[i]; | |
57 | + for(;*s != '\0'; s++){ | |
58 | + if(*s == 'i'){ | |
59 | + args->VMFlags |= CHNCPU_VM_FLAG_PRINT_OPLIST; | |
60 | + } else{ | |
61 | + printf("bindVMArgs: unknown flag %c.\n", *s); | |
62 | + argc = 0; | |
63 | + } | |
64 | + } | |
65 | + } else{ | |
66 | + argc = 0; | |
67 | + } | |
68 | + } | |
69 | + } | |
70 | + | |
71 | + if(argc < 3){ | |
72 | + puts("chncpu:Usage > chncpu [-e appPath] [-f flags]"); | |
73 | + exit(EXIT_FAILURE); | |
74 | + } | |
75 | + | |
76 | + return args; | |
77 | +} | |
78 | + | |
79 | +void printOpTableWikiDoc(CHNCPU_RuntimeEnvironment *env) | |
80 | +{ | |
81 | + int i; | |
82 | + | |
83 | + puts(", mnemonic, OpCode(Hex), OpCode(ch4_uint Hex), +!, +2, +3, +4, +5, +6, +7, code, type"); | |
84 | + for(i = 0; i <= CHNCPU_OPECODE_MAX; i++){ | |
85 | + if(env->opSet->docFuncTable[i]){ | |
86 | + env->opSet->docFuncTable[i](i, stdout); | |
87 | + } | |
88 | + } | |
89 | +} | |
90 | + | |
27 | 91 | int decodeHexString(char *src0, char *src1, unsigned char *dst0, unsigned char *dst1) |
28 | 92 | { |
29 | 93 | // ASCII文字のみ対応 |
@@ -11,6 +11,7 @@ | ||
11 | 11 | |
12 | 12 | #include <stdio.h> |
13 | 13 | #include <stdlib.h> |
14 | +#include <string.h> | |
14 | 15 | #include "ch4.h" |
15 | 16 | |
16 | 17 | // DEBUG Flag |
@@ -18,6 +19,10 @@ | ||
18 | 19 | #define DEBUG_PRINT_OP_BINDING 0 |
19 | 20 | #define DEBUG_PRINT_OP_EXECUTING 0 |
20 | 21 | |
22 | +// VM flags | |
23 | +#define CHNCPU_VM_FLAG_PRINT_OPLIST 0x01 | |
24 | + | |
25 | + | |
21 | 26 | // Settings |
22 | 27 | #define SIZE_TMPDATA (1024 * 1024 * 1) |
23 | 28 |
@@ -83,10 +88,12 @@ | ||
83 | 88 | typedef struct _CHNCPU_OP_TAG CHNCPU_OpTag; |
84 | 89 | typedef struct _CHNCPU_BIOS CHNCPU_BIOS; |
85 | 90 | typedef struct _CHNCPU_OP_TABLE_SET CHNCPU_OpTableSet; |
86 | -typedef struct _CHNCPU_RUN_TIME_ENVIRONMENT CHNCPU_RuntimeEnvironment; | |
87 | 91 | typedef struct _CHNCPU_LABEL_TAG CHNCPU_LabelTag; |
88 | 92 | typedef struct _CHNCPU_LABEL_SET CHNCPU_LabelSet; |
89 | 93 | typedef struct _CHNCPU_POINTER_TAG CHNCPU_PointerTag; |
94 | +typedef struct _CHNCPU_RUN_TIME_ENVIRONMENT CHNCPU_RuntimeEnvironment; | |
95 | +typedef struct _CHNCPU_VM_ARGS CHNCPU_VMArgs; | |
96 | + | |
90 | 97 | |
91 | 98 | |
92 | 99 | struct _CHNCPU_OP_TAG { |
@@ -104,6 +111,7 @@ struct _CHNCPU_OP_TABLE_SET { | ||
104 | 111 | int (*bindFuncTable[CHNCPU_OPECODE_MAX + 1])(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
105 | 112 | int (*execFuncTable[CHNCPU_OPECODE_MAX + 1])(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
106 | 113 | int (*printFuncTable[CHNCPU_OPECODE_MAX + 1])(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
114 | + int (*docFuncTable[CHNCPU_OPECODE_MAX + 1])(int opCode, FILE *file); | |
107 | 115 | }; |
108 | 116 | |
109 | 117 | struct _CHNCPU_LABEL_TAG { |
@@ -138,7 +146,14 @@ struct _CHNCPU_RUN_TIME_ENVIRONMENT { | ||
138 | 146 | int currentLabel; |
139 | 147 | }; |
140 | 148 | |
149 | +struct _CHNCPU_VM_ARGS { | |
150 | + const char *appPath; | |
151 | + unsigned int VMFlags; | |
152 | +}; | |
153 | + | |
141 | 154 | // @chncpu.c |
155 | +CHNCPU_VMArgs *bindVMArgs(int argc, const char *argv[]); | |
156 | +void printOpTableWikiDoc(CHNCPU_RuntimeEnvironment *env); | |
142 | 157 | int decodeHexString(char *src0, char *src1, unsigned char *dst0, unsigned char *dst1); |
143 | 158 | CHNCPU_RuntimeEnvironment *CHNCPU_CreateRuntimeEnvironment(CHNCPU_OpTableSet *opSet, CHNCPU_BIOS *bios); |
144 | 159 | int CHNCPU_LoadBinaryFromHexStringFilePath(CHNCPU_RuntimeEnvironment *env, const char *path); |
@@ -152,28 +167,46 @@ int CHNCPU_AdjustValueForBit(CHNCPU_RuntimeEnvironment *env, int *value, ch4_uin | ||
152 | 167 | // @opcode.c |
153 | 168 | CHNCPU_OpTableSet *CHNCPU_CreateOpTableSet(void); |
154 | 169 | int CHNCPU_Op_Init(CHNCPU_OpTableSet *env); |
170 | +// | |
171 | +int CHNCPU_Op_NOP_PrintWikiDoc(int opCode, FILE *file); | |
172 | +// | |
155 | 173 | int CHNCPU_Op_LB_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
156 | 174 | int CHNCPU_Op_LB_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
157 | 175 | int CHNCPU_Op_LB_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
176 | +int CHNCPU_Op_LB_PrintWikiDoc(int opCode, FILE *file); | |
177 | +// | |
158 | 178 | int CHNCPU_Op_LIMM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
159 | 179 | int CHNCPU_Op_LIMM_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
160 | 180 | int CHNCPU_Op_LIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
181 | +int CHNCPU_Op_LIMM_PrintWikiDoc(int opCode, FILE *file); | |
182 | +// | |
161 | 183 | int CHNCPU_Op_PLIMM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
162 | 184 | int CHNCPU_Op_PLIMM_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
163 | 185 | int CHNCPU_Op_PLIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
186 | +int CHNCPU_Op_PLIMM_PrintWikiDoc(int opCode, FILE *file); | |
187 | +// | |
164 | 188 | int CHNCPU_Op_CND_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
165 | 189 | int CHNCPU_Op_CND_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
166 | 190 | int CHNCPU_Op_CND_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
191 | +int CHNCPU_Op_CND_PrintWikiDoc(int opCode, FILE *file); | |
192 | +// | |
167 | 193 | int CHNCPU_Op_CALLBIOS_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
168 | 194 | int CHNCPU_Op_CALLBIOS_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
169 | 195 | int CHNCPU_Op_CALLBIOS_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
196 | +int CHNCPU_Op_CALLBIOS_PrintWikiDoc(int opCode, FILE *file); | |
197 | +// | |
170 | 198 | int CHNCPU_Op_TernaryReg_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
171 | 199 | int CHNCPU_Op_TernaryRegBitwise_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
172 | 200 | int CHNCPU_Op_TernaryRegArithmetic_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
173 | 201 | int CHNCPU_Op_TernaryReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
202 | +int CHNCPU_Op_TernaryReg_PrintWikiDoc(int opCode, FILE *file); | |
203 | +// | |
174 | 204 | int CHNCPU_Op_CompareIReg_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
175 | 205 | int CHNCPU_Op_CompareIReg_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
176 | 206 | int CHNCPU_Op_CompareIReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
207 | +int CHNCPU_Op_CompareIReg_PrintWikiDoc(int opCode, FILE *file); | |
208 | +// | |
209 | +int CHNCPU_Op_Prefix2F_PrintWikiDoc(int opCode, FILE *file); | |
177 | 210 | |
178 | 211 | // @bios.c |
179 | 212 | CHNCPU_BIOS *CHNCPU_CreateBIOS(void); |
@@ -32,60 +32,89 @@ int CHNCPU_Op_Init(CHNCPU_OpTableSet *opSet) | ||
32 | 32 | opSet->bindFuncTable[i] = NULL; |
33 | 33 | opSet->execFuncTable[i] = NULL; |
34 | 34 | opSet->printFuncTable[i] = NULL; |
35 | + opSet->docFuncTable[i] = NULL; | |
35 | 36 | } |
36 | 37 | |
38 | + // NOP | |
39 | + opSet->docFuncTable[0x00] = CHNCPU_Op_NOP_PrintWikiDoc; | |
40 | + | |
37 | 41 | // LB |
38 | 42 | opSet->bindFuncTable[0x01] = CHNCPU_Op_LB_BindOperand; |
39 | 43 | opSet->execFuncTable[0x01] = CHNCPU_Op_LB_Execute; |
40 | 44 | opSet->printFuncTable[0x01] = CHNCPU_Op_LB_PrintCode; |
45 | + opSet->docFuncTable[0x01] = CHNCPU_Op_LB_PrintWikiDoc; | |
41 | 46 | |
42 | 47 | // LIMM |
43 | 48 | opSet->bindFuncTable[0x02] = CHNCPU_Op_LIMM_BindOperand; |
44 | 49 | opSet->execFuncTable[0x02] = CHNCPU_Op_LIMM_Execute; |
45 | 50 | opSet->printFuncTable[0x02] = CHNCPU_Op_LIMM_PrintCode; |
51 | + opSet->docFuncTable[0x02] = CHNCPU_Op_LIMM_PrintWikiDoc; | |
46 | 52 | |
47 | - // LIMM | |
53 | + // PLIMM | |
48 | 54 | opSet->bindFuncTable[0x03] = CHNCPU_Op_PLIMM_BindOperand; |
49 | 55 | opSet->execFuncTable[0x03] = CHNCPU_Op_PLIMM_Execute; |
50 | 56 | opSet->printFuncTable[0x03] = CHNCPU_Op_PLIMM_PrintCode; |
57 | + opSet->docFuncTable[0x03] = CHNCPU_Op_PLIMM_PrintWikiDoc; | |
51 | 58 | |
52 | 59 | // CND |
53 | 60 | opSet->bindFuncTable[0x04] = CHNCPU_Op_CND_BindOperand; |
54 | 61 | opSet->execFuncTable[0x04] = CHNCPU_Op_CND_Execute; |
55 | 62 | opSet->printFuncTable[0x04] = CHNCPU_Op_CND_PrintCode; |
63 | + opSet->docFuncTable[0x04] = CHNCPU_Op_CND_PrintWikiDoc; | |
56 | 64 | |
57 | 65 | // CALLBIOS |
58 | 66 | opSet->bindFuncTable[0x05] = CHNCPU_Op_CALLBIOS_BindOperand; |
59 | 67 | opSet->execFuncTable[0x05] = CHNCPU_Op_CALLBIOS_Execute; |
60 | 68 | opSet->printFuncTable[0x05] = CHNCPU_Op_CALLBIOS_PrintCode; |
69 | + opSet->docFuncTable[0x05] = CHNCPU_Op_CALLBIOS_PrintWikiDoc; | |
61 | 70 | |
62 | 71 | // TernaryRegBitwise |
63 | 72 | for(i = 0x10; i <= 0x12; i++){ |
64 | 73 | opSet->bindFuncTable[i] = CHNCPU_Op_TernaryReg_BindOperand; |
65 | 74 | opSet->execFuncTable[i] = CHNCPU_Op_TernaryRegBitwise_Execute; |
66 | 75 | opSet->printFuncTable[i] = CHNCPU_Op_TernaryReg_PrintCode; |
76 | + opSet->docFuncTable[i] = CHNCPU_Op_TernaryReg_PrintWikiDoc; | |
67 | 77 | } |
68 | 78 | // TernaryRegArithmetic |
69 | 79 | for(i = 0x14; i <= 0x16; i++){ |
70 | 80 | opSet->bindFuncTable[i] = CHNCPU_Op_TernaryReg_BindOperand; |
71 | 81 | opSet->execFuncTable[i] = CHNCPU_Op_TernaryRegArithmetic_Execute; |
72 | 82 | opSet->printFuncTable[i] = CHNCPU_Op_TernaryReg_PrintCode; |
83 | + opSet->docFuncTable[i] = CHNCPU_Op_TernaryReg_PrintWikiDoc; | |
73 | 84 | } |
74 | 85 | for(i = 0x18; i <= 0x1B; i++){ |
75 | 86 | opSet->bindFuncTable[i] = CHNCPU_Op_TernaryReg_BindOperand; |
76 | 87 | opSet->execFuncTable[i] = CHNCPU_Op_TernaryRegArithmetic_Execute; |
77 | 88 | opSet->printFuncTable[i] = CHNCPU_Op_TernaryReg_PrintCode; |
89 | + opSet->docFuncTable[i] = CHNCPU_Op_TernaryReg_PrintWikiDoc; | |
78 | 90 | } |
79 | - // | |
91 | + // CompareIReg | |
80 | 92 | for(i = 0x20; i <= 0x27; i++){ |
81 | 93 | opSet->bindFuncTable[i] = CHNCPU_Op_CompareIReg_BindOperand; |
82 | 94 | opSet->execFuncTable[i] = CHNCPU_Op_CompareIReg_Execute; |
83 | 95 | opSet->printFuncTable[i] = CHNCPU_Op_CompareIReg_PrintCode; |
96 | + opSet->docFuncTable[i] = CHNCPU_Op_CompareIReg_PrintWikiDoc; | |
84 | 97 | } |
98 | + // Prefix2F | |
99 | + opSet->docFuncTable[0x2f] = CHNCPU_Op_Prefix2F_PrintWikiDoc; | |
85 | 100 | return 0; |
86 | 101 | } |
87 | 102 | |
88 | 103 | // |
104 | +// 00 NOP | |
105 | +// | |
106 | +int CHNCPU_Op_NOP_PrintWikiDoc(int opCode, FILE *file) | |
107 | +{ | |
108 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
109 | + "NOP", | |
110 | + 0x00, 0x00, | |
111 | + "", "", "", "", "", "", "", | |
112 | + "No operation", ""); | |
113 | + | |
114 | + return 0; | |
115 | +} | |
116 | + | |
117 | +// | |
89 | 118 | // 01 LB |
90 | 119 | // |
91 | 120 | typedef struct _CHNCPU_OP_CACHE_LB CHNCPU_OpCache_LB; |
@@ -135,6 +164,17 @@ int CHNCPU_Op_LB_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FIL | ||
135 | 164 | return 0; |
136 | 165 | } |
137 | 166 | |
167 | +int CHNCPU_Op_LB_PrintWikiDoc(int opCode, FILE *file) | |
168 | +{ | |
169 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
170 | + "LB", | |
171 | + 0x01, 0x01, | |
172 | + "labelID", "opt", "", "", "", "", "", | |
173 | + "#labelID;", ""); | |
174 | + | |
175 | + return 0; | |
176 | +} | |
177 | + | |
138 | 178 | // |
139 | 179 | // 02 LIMM |
140 | 180 | // |
@@ -195,6 +235,17 @@ int CHNCPU_Op_LIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, F | ||
195 | 235 | return 0; |
196 | 236 | } |
197 | 237 | |
238 | +int CHNCPU_Op_LIMM_PrintWikiDoc(int opCode, FILE *file) | |
239 | +{ | |
240 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
241 | + "LIMM", | |
242 | + 0x02, 0x02, | |
243 | + "(sint)imm", "r", "bit", "", "", "", "", | |
244 | + "reg = imm;", ""); | |
245 | + | |
246 | + return 0; | |
247 | +} | |
248 | + | |
198 | 249 | // |
199 | 250 | // 03 PLIMM |
200 | 251 | // |
@@ -259,6 +310,17 @@ int CHNCPU_Op_PLIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, | ||
259 | 310 | return 0; |
260 | 311 | } |
261 | 312 | |
313 | +int CHNCPU_Op_PLIMM_PrintWikiDoc(int opCode, FILE *file) | |
314 | +{ | |
315 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
316 | + "PLIMM", | |
317 | + 0x03, 0x03, | |
318 | + "labelID", "p", "", "", "", "", "", | |
319 | + "p = #labelID;", ""); | |
320 | + | |
321 | + return 0; | |
322 | +} | |
323 | + | |
262 | 324 | // |
263 | 325 | // 04 CND |
264 | 326 | // |
@@ -309,6 +371,17 @@ int CHNCPU_Op_CND_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FI | ||
309 | 371 | return 0; |
310 | 372 | } |
311 | 373 | |
374 | +int CHNCPU_Op_CND_PrintWikiDoc(int opCode, FILE *file) | |
375 | +{ | |
376 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
377 | + "CND", | |
378 | + 0x04, 0x04, | |
379 | + "r", "", "", "", "", "", "", | |
380 | + "if((reg0R & 1) == 0){ skip nextOp; }", "Prefix"); | |
381 | + | |
382 | + return 0; | |
383 | +} | |
384 | + | |
312 | 385 | // |
313 | 386 | // 05 CALLBIOS |
314 | 387 | // |
@@ -370,7 +443,16 @@ int CHNCPU_Op_CALLBIOS_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *o | ||
370 | 443 | return 0; |
371 | 444 | } |
372 | 445 | |
373 | - | |
446 | +int CHNCPU_Op_CALLBIOS_PrintWikiDoc(int opCode, FILE *file) | |
447 | +{ | |
448 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
449 | + "CALLBIOS", | |
450 | + 0x05, 0x05, | |
451 | + "fid", "...", "", "", "", "", "", | |
452 | + "", ""); | |
453 | + | |
454 | + return 0; | |
455 | +} | |
374 | 456 | |
375 | 457 | // |
376 | 458 | // Ternary Register Operation |
@@ -521,6 +603,23 @@ char *CHNCPU_Op_TernaryReg_MnemonicList0[12] = { | ||
521 | 603 | "DIV", |
522 | 604 | "MOD" |
523 | 605 | }; |
606 | + | |
607 | +char *CHNCPU_Op_TernaryReg_CodeList0[12] = { | |
608 | + // 10 - 1B | |
609 | + "r0 = r1 | r2;", | |
610 | + "r0 = r1 ^ r2;", | |
611 | + "r0 = r1 & r2;", | |
612 | + "", | |
613 | + "r0 = r1 + r2;", | |
614 | + "r0 = r1 - r2;", | |
615 | + "r0 = r1 * r2;", | |
616 | + "", | |
617 | + "r0 = r1 << r2;", | |
618 | + "r0 = r1 >> r2;", | |
619 | + "r0 = r1 / r2;", | |
620 | + "r0 = r1 % r2;" | |
621 | +}; | |
622 | + | |
524 | 623 | int CHNCPU_Op_TernaryReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file) |
525 | 624 | { |
526 | 625 | CHNCPU_OpCache_TernaryReg *opCache; |
@@ -541,6 +640,25 @@ int CHNCPU_Op_TernaryReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag | ||
541 | 640 | return 0; |
542 | 641 | } |
543 | 642 | |
643 | +int CHNCPU_Op_TernaryReg_PrintWikiDoc(int opCode, FILE *file) | |
644 | +{ | |
645 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
646 | + CHNCPU_Op_TernaryReg_MnemonicList0[opCode - 0x10], | |
647 | + opCode, opCode + 0x80, | |
648 | + "r1", "r2", "r0", "bit", "", "", "", | |
649 | + CHNCPU_Op_TernaryReg_CodeList0[opCode - 0x10], ""); | |
650 | + | |
651 | + if(opCode == 0x10){ | |
652 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
653 | + "CP", | |
654 | + opCode, opCode + 0x80, | |
655 | + "r1", "r1", "r0", "bit", "", "", "", | |
656 | + "r0 = r1", ""); | |
657 | + } | |
658 | + | |
659 | + return 0; | |
660 | +} | |
661 | + | |
544 | 662 | // |
545 | 663 | // Compare Integer Register Operation |
546 | 664 | // |
@@ -661,6 +779,20 @@ char *CHNCPU_Op_CompareIReg_MnemonicList0[8] = { | ||
661 | 779 | "TSTZ", |
662 | 780 | "TSTNZ", |
663 | 781 | }; |
782 | + | |
783 | +char *CHNCPU_Op_CompareIReg_CodeList0[8] = { | |
784 | + // 20-27 | |
785 | + "r0 = (r1 == r2) ? -1 : 0;", | |
786 | + "r0 = (r1 != r2) ? -1 : 0;", | |
787 | + "r0 = (r1 < r2) ? -1 : 0;", | |
788 | + "r0 = (r1 >= r2) ? -1 : 0;", | |
789 | + "r0 = (r1 <= r2) ? -1 : 0;", | |
790 | + "r0 = (r1 > r2) ? -1 : 0;", | |
791 | + "r0 = ((r1 & r2) == 0) ? -1 : 0;", | |
792 | + "r0 = ((r1 & r2) != 0) ? -1 : 0;", | |
793 | +}; | |
794 | + | |
795 | + | |
664 | 796 | int CHNCPU_Op_CompareIReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file) |
665 | 797 | { |
666 | 798 | CHNCPU_OpCache_CompareIReg *opCache; |
@@ -678,4 +810,30 @@ int CHNCPU_Op_CompareIReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag | ||
678 | 810 | return 0; |
679 | 811 | } |
680 | 812 | |
813 | +int CHNCPU_Op_CompareIReg_PrintWikiDoc(int opCode, FILE *file) | |
814 | +{ | |
815 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
816 | + CHNCPU_Op_CompareIReg_MnemonicList0[opCode - 0x20], | |
817 | + opCode, opCode + 0x80, | |
818 | + "r1", "r2", "bitDiff", "r0", "bitDst", "", "", | |
819 | + CHNCPU_Op_CompareIReg_CodeList0[opCode - 0x20], ""); | |
820 | + | |
821 | + return 0; | |
822 | +} | |
823 | + | |
824 | +// | |
825 | +// Prefix2F | |
826 | +// | |
827 | + | |
828 | +int CHNCPU_Op_Prefix2F_PrintWikiDoc(int opCode, FILE *file) | |
829 | +{ | |
830 | + fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
831 | + "Prefix2F-0", | |
832 | + 0x2F, 0x2F + 0x80, | |
833 | + "0", "", "", "", "", "", "", | |
834 | + "DISABLE_BOUND_CHECK;", ""); | |
835 | + | |
836 | + return 0; | |
837 | +} | |
838 | + | |
681 | 839 |