Revisão | fe519622fb41bc1d1d04ca609f26d416bc6f6bde (tree) |
---|---|
Hora | 2014-07-07 23:06:45 |
Autor | hikarupsp <hikarupsp@user...> |
Commiter | hikarupsp |
コードの整理。
wikiドキュメント生成機能は削除された。
@@ -14,6 +14,7 @@ | ||
14 | 14 | 1786B0941956C18800FD4F7B /* label.c in Sources */ = {isa = PBXBuildFile; fileRef = 1786B0931956C18800FD4F7B /* label.c */; }; |
15 | 15 | 17DD55BB1967992200DA7D82 /* args.c in Sources */ = {isa = PBXBuildFile; fileRef = 17DD55BA1967992200DA7D82 /* args.c */; }; |
16 | 16 | 17E5092A1967F7B00091A22A /* src.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17E509291967F7770091A22A /* src.txt */; }; |
17 | + 17E50932196AD91D0091A22A /* debug.c in Sources */ = {isa = PBXBuildFile; fileRef = 17E50931196AD91D0091A22A /* debug.c */; }; | |
17 | 18 | 17F95C01194C8DA70064E1B6 /* bios.c in Sources */ = {isa = PBXBuildFile; fileRef = 17F95C00194C8DA70064E1B6 /* bios.c */; }; |
18 | 19 | /* End PBXBuildFile section */ |
19 | 20 |
@@ -42,6 +43,8 @@ | ||
42 | 43 | 1786B0931956C18800FD4F7B /* label.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = label.c; sourceTree = "<group>"; }; |
43 | 44 | 17DD55BA1967992200DA7D82 /* args.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = args.c; sourceTree = "<group>"; }; |
44 | 45 | 17E509291967F7770091A22A /* src.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = src.txt; sourceTree = "<group>"; }; |
46 | + 17E50930196AD6BF0091A22A /* opcache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = opcache.h; sourceTree = "<group>"; }; | |
47 | + 17E50931196AD91D0091A22A /* debug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = debug.c; path = ../debug.c; sourceTree = "<group>"; }; | |
45 | 48 | 17F95C00194C8DA70064E1B6 /* bios.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bios.c; sourceTree = "<group>"; }; |
46 | 49 | /* End PBXFileReference section */ |
47 | 50 |
@@ -76,15 +79,17 @@ | ||
76 | 79 | 17478CF2193E2A4900293791 /* chncpu */ = { |
77 | 80 | isa = PBXGroup; |
78 | 81 | children = ( |
82 | + 17478CFC193E2A7800293791 /* chncpu.h */, | |
79 | 83 | 17478CF3193E2A4900293791 /* chncpu.c */, |
84 | + 17E50931196AD91D0091A22A /* debug.c */, | |
80 | 85 | 17DD55BA1967992200DA7D82 /* args.c */, |
81 | - 17478CFC193E2A7800293791 /* chncpu.h */, | |
82 | 86 | 17478D00193F3D0000293791 /* ch4.c */, |
83 | 87 | 17478D02193F586100293791 /* ch4.h */, |
84 | - 17478CFD193E2ADA00293791 /* test.hex */, | |
88 | + 17E50930196AD6BF0091A22A /* opcache.h */, | |
85 | 89 | 17478D031940B66700293791 /* opcode.c */, |
86 | 90 | 17F95C00194C8DA70064E1B6 /* bios.c */, |
87 | 91 | 1786B0931956C18800FD4F7B /* label.c */, |
92 | + 17478CFD193E2ADA00293791 /* test.hex */, | |
88 | 93 | 17E509291967F7770091A22A /* src.txt */, |
89 | 94 | ); |
90 | 95 | path = chncpu; |
@@ -142,6 +147,7 @@ | ||
142 | 147 | buildActionMask = 2147483647; |
143 | 148 | files = ( |
144 | 149 | 1786B0941956C18800FD4F7B /* label.c in Sources */, |
150 | + 17E50932196AD91D0091A22A /* debug.c in Sources */, | |
145 | 151 | 17F95C01194C8DA70064E1B6 /* bios.c in Sources */, |
146 | 152 | 17DD55BB1967992200DA7D82 /* args.c in Sources */, |
147 | 153 | 17478D041940B66700293791 /* opcode.c in Sources */, |
@@ -31,7 +31,7 @@ CHNCPU_VMArgs *bindVMArgs(int argc, const char *argv[]) | ||
31 | 31 | s = CHNCPU_VMArgs_GetNextAsString(argc, argv, &nextIndex); |
32 | 32 | for(;*s != '\0'; s++){ |
33 | 33 | if(*s == 'i'){ |
34 | - args->VMFlags |= CHNCPU_VM_FLAG_PRINT_OPLIST; | |
34 | + args->VMFlags |= CHNCPU_VM_FLAG_PRINT_INFO; | |
35 | 35 | } else{ |
36 | 36 | printf("bindVMArgs: unknown flag %c.\n", *s); |
37 | 37 | argc = 0; |
@@ -16,8 +16,8 @@ int main(int argc, const char *argv[]) | ||
16 | 16 | vmArgs = bindVMArgs(argc, argv); |
17 | 17 | env = CHNCPU_CreateRuntimeEnvironment(CHNCPU_CreateOpTableSet(), CHNCPU_CreateBIOS()); |
18 | 18 | |
19 | - if(vmArgs->VMFlags & CHNCPU_VM_FLAG_PRINT_OPLIST){ | |
20 | - printOpTableWikiDoc(env); | |
19 | + if(vmArgs->VMFlags & CHNCPU_VM_FLAG_PRINT_INFO){ | |
20 | + printf("chncpu, inspired by OSECPU-VM. \nCompiled at %s, %s.\n", __TIME__, __DATE__); | |
21 | 21 | return 0; |
22 | 22 | } |
23 | 23 |
@@ -34,18 +34,6 @@ int main(int argc, const char *argv[]) | ||
34 | 34 | return 0; |
35 | 35 | } |
36 | 36 | |
37 | -void printOpTableWikiDoc(CHNCPU_RuntimeEnvironment *env) | |
38 | -{ | |
39 | - int i; | |
40 | - | |
41 | - puts(", mnemonic, OpCode(Hex), OpCode(ch4_uint Hex), +!, +2, +3, +4, +5, +6, +7, code, type"); | |
42 | - for(i = 0; i <= CHNCPU_OPECODE_MAX; i++){ | |
43 | - if(env->opSet->docFuncTable[i]){ | |
44 | - env->opSet->docFuncTable[i](i, stdout); | |
45 | - } | |
46 | - } | |
47 | -} | |
48 | - | |
49 | 37 | int decodeHexString(char *src0, char *src1, unsigned char *dst0, unsigned char *dst1) |
50 | 38 | { |
51 | 39 | // ASCII文字のみ対応 |
@@ -380,61 +368,6 @@ int CHNCPU_Execute(CHNCPU_RuntimeEnvironment *env) | ||
380 | 368 | return count; |
381 | 369 | } |
382 | 370 | |
383 | -void CHNCPU_DumpAppBin(CHNCPU_RuntimeEnvironment *env) | |
384 | -{ | |
385 | - int i; | |
386 | - | |
387 | - for(i = 0; i < env->appbinsize; i++){ | |
388 | - printf("%02X ", env->appbin0[i]); | |
389 | - if((i & 0xf) == 0xf){ | |
390 | - putchar('\n'); | |
391 | - } | |
392 | - } | |
393 | - if(((i - 1) & 0xf) != 0xf){ | |
394 | - putchar('\n'); | |
395 | - } | |
396 | -} | |
397 | - | |
398 | -void CHNCPU_DumpIReg(CHNCPU_RuntimeEnvironment *env) | |
399 | -{ | |
400 | - int i, regs = 0; | |
401 | - | |
402 | - puts(">>> Integer registers"); | |
403 | - | |
404 | - for(i = 0; i < CHNCPU_NUMBER_OF_IREG; i++){ | |
405 | - if(env->iRegBits[i]){ | |
406 | - printf("R%02X = %10d = 0x%08X(%2d) ", i, env->iReg[i], env->iReg[i], env->iRegBits[i]); | |
407 | - putchar('\n'); | |
408 | - regs++; | |
409 | - } | |
410 | - } | |
411 | - if(((regs - 1) & 0xF) != 0xF){ | |
412 | - putchar('\n'); | |
413 | - } | |
414 | -} | |
415 | - | |
416 | -void CHNCPU_DumpPReg(CHNCPU_RuntimeEnvironment *env) | |
417 | -{ | |
418 | - int i, regs = 0; | |
419 | - | |
420 | - puts(">>> Pointer registers"); | |
421 | - | |
422 | - for(i = 0; i < CHNCPU_NUMBER_OF_PREG; i++){ | |
423 | - if(env->pReg[i].type != CHNCPU_PType_Undefined){ | |
424 | - if(env->pReg[i].mindex != CHNCPU_MemoryIndex_INVALID){ | |
425 | - printf("P%02X: Type:%2X mem[%d][%d]", i, env->pReg[i].type, env->pReg[i].mindex, env->pReg[i].pindex); | |
426 | - } else{ | |
427 | - printf("P%02X: Type:%2X %s[%d]", i, env->pReg[i].type, CHNCPU_Op_DATA_GetFilePath(env->pReg[i].opTag), env->pReg[i].pindex); | |
428 | - } | |
429 | - putchar('\n'); | |
430 | - regs++; | |
431 | - } | |
432 | - } | |
433 | - if(((regs - 1) & 0xF) != 0xF){ | |
434 | - putchar('\n'); | |
435 | - } | |
436 | -} | |
437 | - | |
438 | 371 | int CHNCPU_CHK_IsAvailableBits(CHNCPU_RuntimeEnvironment *env, ch4_uint bits) |
439 | 372 | { |
440 | 373 | if(bits > 32){ |
@@ -22,7 +22,7 @@ | ||
22 | 22 | #define DEBUG_PRINT_OP_EXECUTING 0 |
23 | 23 | |
24 | 24 | // VM flags |
25 | -#define CHNCPU_VM_FLAG_PRINT_OPLIST 0x01 | |
25 | +#define CHNCPU_VM_FLAG_PRINT_INFO 0x01 | |
26 | 26 | |
27 | 27 | |
28 | 28 | // Settings |
@@ -110,7 +110,6 @@ struct _CHNCPU_OP_TABLE_SET { | ||
110 | 110 | int (*bindFuncTable[CHNCPU_OPECODE_MAX + 1])(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
111 | 111 | int (*execFuncTable[CHNCPU_OPECODE_MAX + 1])(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
112 | 112 | int (*printFuncTable[CHNCPU_OPECODE_MAX + 1])(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
113 | - int (*docFuncTable[CHNCPU_OPECODE_MAX + 1])(int opCode, FILE *file); | |
114 | 113 | }; |
115 | 114 | |
116 | 115 | struct _CHNCPU_LABEL_TAG { |
@@ -166,15 +165,11 @@ struct _CHNCPU_VM_ARGS { | ||
166 | 165 | |
167 | 166 | |
168 | 167 | // @chncpu.c |
169 | -void printOpTableWikiDoc(CHNCPU_RuntimeEnvironment *env); | |
170 | 168 | int decodeHexString(char *src0, char *src1, unsigned char *dst0, unsigned char *dst1); |
171 | 169 | CHNCPU_RuntimeEnvironment *CHNCPU_CreateRuntimeEnvironment(CHNCPU_OpTableSet *opSet, CHNCPU_BIOS *bios); |
172 | 170 | int CHNCPU_LoadBinaryFromHexStringFilePath(CHNCPU_RuntimeEnvironment *env, const char *path); |
173 | 171 | int CHNCPU_PrepareBinaryForExecution(CHNCPU_RuntimeEnvironment *env); |
174 | 172 | int CHNCPU_Execute(CHNCPU_RuntimeEnvironment *env); |
175 | -void CHNCPU_DumpAppBin(CHNCPU_RuntimeEnvironment *env); | |
176 | -void CHNCPU_DumpIReg(CHNCPU_RuntimeEnvironment *env); | |
177 | -void CHNCPU_DumpPReg(CHNCPU_RuntimeEnvironment *env); | |
178 | 173 | int CHNCPU_CHK_IsAvailableBits(CHNCPU_RuntimeEnvironment *env, ch4_uint bits); |
179 | 174 | int CHNCPU_AdjustValueForBit(CHNCPU_RuntimeEnvironment *env, int *value, ch4_uint bit, int prefix); |
180 | 175 |
@@ -192,53 +187,42 @@ int CHNCPU_VMArgs_GetNextAsSignedHexValue(int argc, const char *argv[], int *nex | ||
192 | 187 | CHNCPU_OpTableSet *CHNCPU_CreateOpTableSet(void); |
193 | 188 | int CHNCPU_Op_Init(CHNCPU_OpTableSet *env); |
194 | 189 | // |
195 | -int CHNCPU_Op_NOP_PrintWikiDoc(int opCode, FILE *file); | |
196 | -// | |
197 | 190 | int CHNCPU_Op_LB_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
198 | 191 | int CHNCPU_Op_LB_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
199 | 192 | int CHNCPU_Op_LB_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
200 | -int CHNCPU_Op_LB_PrintWikiDoc(int opCode, FILE *file); | |
201 | 193 | // |
202 | 194 | int CHNCPU_Op_LIMM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
203 | 195 | int CHNCPU_Op_LIMM_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
204 | 196 | int CHNCPU_Op_LIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
205 | -int CHNCPU_Op_LIMM_PrintWikiDoc(int opCode, FILE *file); | |
206 | 197 | // |
207 | 198 | int CHNCPU_Op_PLIMM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
208 | 199 | int CHNCPU_Op_PLIMM_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
209 | 200 | int CHNCPU_Op_PLIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
210 | -int CHNCPU_Op_PLIMM_PrintWikiDoc(int opCode, FILE *file); | |
211 | 201 | // |
212 | 202 | int CHNCPU_Op_CND_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
213 | 203 | int CHNCPU_Op_CND_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
214 | 204 | int CHNCPU_Op_CND_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
215 | -int CHNCPU_Op_CND_PrintWikiDoc(int opCode, FILE *file); | |
216 | 205 | // |
217 | 206 | int CHNCPU_Op_CALLBIOS_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
218 | 207 | int CHNCPU_Op_CALLBIOS_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
219 | 208 | int CHNCPU_Op_CALLBIOS_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
220 | -int CHNCPU_Op_CALLBIOS_PrintWikiDoc(int opCode, FILE *file); | |
221 | 209 | // |
222 | 210 | int CHNCPU_Op_LMEM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
223 | 211 | int CHNCPU_Op_LMEM_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
224 | 212 | int CHNCPU_Op_LMEM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
225 | -int CHNCPU_Op_LMEM_PrintWikiDoc(int opCode, FILE *file); | |
226 | 213 | // |
227 | 214 | int CHNCPU_Op_TernaryReg_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
228 | 215 | int CHNCPU_Op_TernaryRegBitwise_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
229 | 216 | int CHNCPU_Op_TernaryRegArithmetic_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
230 | 217 | int CHNCPU_Op_TernaryReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
231 | -int CHNCPU_Op_TernaryReg_PrintWikiDoc(int opCode, FILE *file); | |
232 | 218 | // |
233 | 219 | int CHNCPU_Op_CompareIReg_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
234 | 220 | int CHNCPU_Op_CompareIReg_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
235 | 221 | int CHNCPU_Op_CompareIReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
236 | -int CHNCPU_Op_CompareIReg_PrintWikiDoc(int opCode, FILE *file); | |
237 | 222 | // |
238 | 223 | int CHNCPU_Op_DATA_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix); |
239 | 224 | int CHNCPU_Op_DATA_Execute(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op); |
240 | 225 | int CHNCPU_Op_DATA_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file); |
241 | -int CHNCPU_Op_DATA_PrintWikiDoc(int opCode, FILE *file); | |
242 | 226 | CHNCPU_OpTag *CHNCPU_Op_DATA_CreateDataFromFileAsPType(const char dataPath[], ch4_sint pType); |
243 | 227 | int CHNCPU_Op_DATA_WriteRawDataToFile(CHNCPU_OpTag *op, const char dataPath[], int dataCount, int dataType); |
244 | 228 | int CHNCPU_Op_DATA_ReadAtIndex(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, int index); |
@@ -260,4 +244,9 @@ CHNCPU_LabelSet *CHNCPU_CreateLabelSet(void); | ||
260 | 244 | int CHNCPU_Label_Add(CHNCPU_LabelSet *lbSet, int mindex, ch4_uint labelID, ch4_uint opt, ch4_sint pType); |
261 | 245 | CHNCPU_LabelTag *CHNCPU_Label_GetTagFromLabelID(CHNCPU_LabelSet *lbSet, int labelID); |
262 | 246 | |
247 | +// @debug.c | |
248 | +void CHNCPU_DumpAppBin(CHNCPU_RuntimeEnvironment *env); | |
249 | +void CHNCPU_DumpIReg(CHNCPU_RuntimeEnvironment *env); | |
250 | +void CHNCPU_DumpPReg(CHNCPU_RuntimeEnvironment *env); | |
251 | + | |
263 | 252 | #endif |
@@ -0,0 +1,164 @@ | ||
1 | +// | |
2 | +// opcache.h | |
3 | +// chncpu | |
4 | +// | |
5 | +// Created by 西田 耀 on 2014/07/07. | |
6 | +// Copyright (c) 2014年 CHNOSProject. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +#ifndef chncpu_opcache_h | |
10 | +#define chncpu_opcache_h | |
11 | + | |
12 | +#include "chncpu.h" | |
13 | + | |
14 | +// | |
15 | +// 00 NOP (not cached) | |
16 | +// | |
17 | +// 00 | |
18 | +// | |
19 | + | |
20 | + | |
21 | +// | |
22 | +// 01 LB | |
23 | +// | |
24 | +// 01 labelID opt | |
25 | +// | |
26 | +typedef struct _CHNCPU_OP_CACHE_LB CHNCPU_OpCache_LB; | |
27 | +struct _CHNCPU_OP_CACHE_LB { | |
28 | + ch4_uint labelID; | |
29 | + ch4_uint opt; | |
30 | +}; | |
31 | + | |
32 | +// | |
33 | +// 02 LIMM | |
34 | +// | |
35 | +// 02 (sint)imm r bit | |
36 | +// | |
37 | +typedef struct _CHNCPU_OP_CACHE_LIMM CHNCPU_OpCache_LIMM; | |
38 | +struct _CHNCPU_OP_CACHE_LIMM { | |
39 | + ch4_sint imm; | |
40 | + ch4_uint r; | |
41 | + ch4_uint bit; | |
42 | +}; | |
43 | + | |
44 | +// | |
45 | +// 03 PLIMM | |
46 | +// | |
47 | +// 03 labelID p | |
48 | +// | |
49 | +typedef struct _CHNCPU_OP_CACHE_PLIMM CHNCPU_OpCache_PLIMM; | |
50 | +struct _CHNCPU_OP_CACHE_PLIMM { | |
51 | + ch4_uint labelID; | |
52 | + ch4_uint r; | |
53 | +}; | |
54 | + | |
55 | +// | |
56 | +// 04 CND | |
57 | +// | |
58 | +// 04 r | |
59 | +// | |
60 | +typedef struct _CHNCPU_OP_CACHE_CND CHNCPU_OpCache_CND; | |
61 | +struct _CHNCPU_OP_CACHE_CND { | |
62 | + ch4_uint r; | |
63 | +}; | |
64 | + | |
65 | +// | |
66 | +// 05 CALLBIOS | |
67 | +// | |
68 | +// 05 fid ... | |
69 | +// | |
70 | + | |
71 | +// | |
72 | +// 08 LMEM | |
73 | +// | |
74 | +// p (sint)pType (sint)pDiff rDst bitDst | |
75 | +// | |
76 | +typedef struct _CHNCPU_OP_CACHE_LMEM CHNCPU_OpCache_LMEM; | |
77 | +struct _CHNCPU_OP_CACHE_LMEM { | |
78 | + ch4_uint p; | |
79 | + ch4_sint pType; | |
80 | + ch4_sint pDiff; | |
81 | + ch4_uint r; | |
82 | + ch4_uint bitDst; | |
83 | +}; | |
84 | + | |
85 | +// | |
86 | +// 10-12, 14-16, 18-1B Ternary Register Operation | |
87 | +// | |
88 | +// opCode r1 r2 r0 bit | |
89 | +// | |
90 | +// Bitwise | |
91 | +// 10 CP/OR r0 = r1 | r2; (CP: r0 = r1) | |
92 | +// 11 XOR r0 = r1 ^ r2; | |
93 | +// 12 AND r0 = r1 & r2; | |
94 | +// | |
95 | +// Arithmetic | |
96 | +// 14 ADD r0 = r1 + r2; | |
97 | +// 15 SUB r0 = r1 - r2; | |
98 | +// 16 MUL r0 = r1 * r2; | |
99 | +// 18 SHL r0 = r1 << r2; | |
100 | +// 19 SAR r0 = r1 >> r2; | |
101 | +// 1A DIV r0 = r1 / r2; | |
102 | +// 1B MOD r0 = r1 % r2; | |
103 | +// | |
104 | +typedef struct _CHNCPU_OP_CACHE_TERNARY_REG CHNCPU_OpCache_TernaryReg; | |
105 | +struct _CHNCPU_OP_CACHE_TERNARY_REG { | |
106 | + ch4_uint r0; | |
107 | + ch4_uint r1; | |
108 | + ch4_uint r2; | |
109 | + ch4_uint bit; | |
110 | + unsigned int prefix; | |
111 | +}; | |
112 | + | |
113 | +// | |
114 | +// 20-27 Compare Integer Register Operation | |
115 | +// | |
116 | +// opCode r1 r2 bitCmp r0 bitDst | |
117 | +// | |
118 | +// 20 CMPE r0 = (r1 == r2) ? -1 : 0; | |
119 | +// 21 CMPNE r0 = (r1 != r2) ? -1 : 0; | |
120 | +// 22 CMPL r0 = (r1 < r2) ? -1 : 0; | |
121 | +// 23 CMPGE r0 = (r1 >= r2) ? -1 : 0; | |
122 | +// 24 CMPLE r0 = (r1 <= r2) ? -1 : 0; | |
123 | +// 25 CMPG r0 = (r1 > r2) ? -1 : 0; | |
124 | +// 26 TSTZ ((r1 & r2) == 0) ? -1 : 0; | |
125 | +// 27 TSTNZ ((r1 & r2) != 0) ? -1 : 0; | |
126 | +// | |
127 | + | |
128 | +typedef struct _CHNCPU_OP_CACHE_COMPARE_IREG CHNCPU_OpCache_CompareIReg; | |
129 | +struct _CHNCPU_OP_CACHE_COMPARE_IREG { | |
130 | + ch4_uint rSrc1; | |
131 | + ch4_uint rSrc2; | |
132 | + ch4_uint bitDiff; | |
133 | + ch4_uint rDst; | |
134 | + ch4_uint bitDst; | |
135 | + unsigned int prefix; | |
136 | +}; | |
137 | + | |
138 | + | |
139 | +// | |
140 | +// 2E DATA | |
141 | +// | |
142 | +// 2E labelID labelOpt (sint)dType dCount (rawData...) | |
143 | +// | |
144 | +typedef struct _CHNCPU_OP_CACHE_DATA CHNCPU_OpCache_DATA; | |
145 | +struct _CHNCPU_OP_CACHE_DATA { | |
146 | + ch4_uint labelID; | |
147 | + ch4_uint labelOpt; | |
148 | + ch4_sint dataType; | |
149 | + ch4_uint dataCount; | |
150 | + void *rawData; | |
151 | + // | |
152 | + int rawDataByteSize; | |
153 | + const char *filePath; | |
154 | +}; | |
155 | + | |
156 | +// | |
157 | +// 2F Prefix (not cached) | |
158 | +// | |
159 | +// 2F n | |
160 | +// | |
161 | + | |
162 | + | |
163 | + | |
164 | +#endif |
@@ -7,6 +7,7 @@ | ||
7 | 7 | // |
8 | 8 | |
9 | 9 | #include "chncpu.h" |
10 | +#include "opcache.h" | |
10 | 11 | |
11 | 12 | CHNCPU_OpTableSet *CHNCPU_CreateOpTableSet(void) |
12 | 13 | { |
@@ -32,107 +33,72 @@ int CHNCPU_Op_Init(CHNCPU_OpTableSet *opSet) | ||
32 | 33 | opSet->bindFuncTable[i] = NULL; |
33 | 34 | opSet->execFuncTable[i] = NULL; |
34 | 35 | opSet->printFuncTable[i] = NULL; |
35 | - opSet->docFuncTable[i] = NULL; | |
36 | 36 | } |
37 | - | |
38 | - // NOP | |
39 | - opSet->docFuncTable[0x00] = CHNCPU_Op_NOP_PrintWikiDoc; | |
40 | - | |
37 | + | |
41 | 38 | // LB |
42 | 39 | opSet->bindFuncTable[0x01] = CHNCPU_Op_LB_BindOperand; |
43 | 40 | opSet->execFuncTable[0x01] = CHNCPU_Op_LB_Execute; |
44 | 41 | opSet->printFuncTable[0x01] = CHNCPU_Op_LB_PrintCode; |
45 | - opSet->docFuncTable[0x01] = CHNCPU_Op_LB_PrintWikiDoc; | |
46 | 42 | |
47 | 43 | // LIMM |
48 | 44 | opSet->bindFuncTable[0x02] = CHNCPU_Op_LIMM_BindOperand; |
49 | 45 | opSet->execFuncTable[0x02] = CHNCPU_Op_LIMM_Execute; |
50 | 46 | opSet->printFuncTable[0x02] = CHNCPU_Op_LIMM_PrintCode; |
51 | - opSet->docFuncTable[0x02] = CHNCPU_Op_LIMM_PrintWikiDoc; | |
52 | 47 | |
53 | 48 | // PLIMM |
54 | 49 | opSet->bindFuncTable[0x03] = CHNCPU_Op_PLIMM_BindOperand; |
55 | 50 | opSet->execFuncTable[0x03] = CHNCPU_Op_PLIMM_Execute; |
56 | 51 | opSet->printFuncTable[0x03] = CHNCPU_Op_PLIMM_PrintCode; |
57 | - opSet->docFuncTable[0x03] = CHNCPU_Op_PLIMM_PrintWikiDoc; | |
58 | 52 | |
59 | 53 | // CND |
60 | 54 | opSet->bindFuncTable[0x04] = CHNCPU_Op_CND_BindOperand; |
61 | 55 | opSet->execFuncTable[0x04] = CHNCPU_Op_CND_Execute; |
62 | 56 | opSet->printFuncTable[0x04] = CHNCPU_Op_CND_PrintCode; |
63 | - opSet->docFuncTable[0x04] = CHNCPU_Op_CND_PrintWikiDoc; | |
64 | 57 | |
65 | 58 | // CALLBIOS |
66 | 59 | opSet->bindFuncTable[0x05] = CHNCPU_Op_CALLBIOS_BindOperand; |
67 | 60 | opSet->execFuncTable[0x05] = CHNCPU_Op_CALLBIOS_Execute; |
68 | 61 | opSet->printFuncTable[0x05] = CHNCPU_Op_CALLBIOS_PrintCode; |
69 | - opSet->docFuncTable[0x05] = CHNCPU_Op_CALLBIOS_PrintWikiDoc; | |
70 | 62 | |
71 | 63 | // LMEM |
72 | 64 | opSet->bindFuncTable[0x08] = CHNCPU_Op_LMEM_BindOperand; |
73 | 65 | opSet->execFuncTable[0x08] = CHNCPU_Op_LMEM_Execute; |
74 | 66 | opSet->printFuncTable[0x08] = CHNCPU_Op_LMEM_PrintCode; |
75 | - opSet->docFuncTable[0x08] = CHNCPU_Op_LMEM_PrintWikiDoc; | |
76 | 67 | |
77 | 68 | // TernaryRegBitwise |
78 | 69 | for(i = 0x10; i <= 0x12; i++){ |
79 | 70 | opSet->bindFuncTable[i] = CHNCPU_Op_TernaryReg_BindOperand; |
80 | 71 | opSet->execFuncTable[i] = CHNCPU_Op_TernaryRegBitwise_Execute; |
81 | 72 | opSet->printFuncTable[i] = CHNCPU_Op_TernaryReg_PrintCode; |
82 | - opSet->docFuncTable[i] = CHNCPU_Op_TernaryReg_PrintWikiDoc; | |
83 | 73 | } |
84 | 74 | // TernaryRegArithmetic |
85 | 75 | for(i = 0x14; i <= 0x16; i++){ |
86 | 76 | opSet->bindFuncTable[i] = CHNCPU_Op_TernaryReg_BindOperand; |
87 | 77 | opSet->execFuncTable[i] = CHNCPU_Op_TernaryRegArithmetic_Execute; |
88 | 78 | opSet->printFuncTable[i] = CHNCPU_Op_TernaryReg_PrintCode; |
89 | - opSet->docFuncTable[i] = CHNCPU_Op_TernaryReg_PrintWikiDoc; | |
90 | 79 | } |
91 | 80 | for(i = 0x18; i <= 0x1B; i++){ |
92 | 81 | opSet->bindFuncTable[i] = CHNCPU_Op_TernaryReg_BindOperand; |
93 | 82 | opSet->execFuncTable[i] = CHNCPU_Op_TernaryRegArithmetic_Execute; |
94 | 83 | opSet->printFuncTable[i] = CHNCPU_Op_TernaryReg_PrintCode; |
95 | - opSet->docFuncTable[i] = CHNCPU_Op_TernaryReg_PrintWikiDoc; | |
96 | 84 | } |
97 | 85 | // CompareIReg |
98 | 86 | for(i = 0x20; i <= 0x27; i++){ |
99 | 87 | opSet->bindFuncTable[i] = CHNCPU_Op_CompareIReg_BindOperand; |
100 | 88 | opSet->execFuncTable[i] = CHNCPU_Op_CompareIReg_Execute; |
101 | 89 | opSet->printFuncTable[i] = CHNCPU_Op_CompareIReg_PrintCode; |
102 | - opSet->docFuncTable[i] = CHNCPU_Op_CompareIReg_PrintWikiDoc; | |
103 | 90 | } |
104 | 91 | // DATA |
105 | 92 | opSet->bindFuncTable[0x2E] = CHNCPU_Op_DATA_BindOperand; |
106 | 93 | opSet->execFuncTable[0x2E] = CHNCPU_Op_DATA_Execute; |
107 | 94 | opSet->printFuncTable[0x2E] = CHNCPU_Op_DATA_PrintCode; |
108 | - opSet->docFuncTable[0x2E] = CHNCPU_Op_DATA_PrintWikiDoc; | |
109 | - // Prefix2F | |
110 | - opSet->docFuncTable[0x2f] = CHNCPU_Op_Prefix2F_PrintWikiDoc; | |
111 | 95 | return 0; |
112 | 96 | } |
113 | 97 | |
114 | 98 | // |
115 | -// 00 NOP | |
116 | -// | |
117 | -int CHNCPU_Op_NOP_PrintWikiDoc(int opCode, FILE *file) | |
118 | -{ | |
119 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
120 | - "NOP", | |
121 | - 0x00, 0x00, | |
122 | - "", "", "", "", "", "", "", | |
123 | - "No operation", ""); | |
124 | - | |
125 | - return 0; | |
126 | -} | |
127 | - | |
128 | -// | |
129 | 99 | // 01 LB |
130 | 100 | // |
131 | -typedef struct _CHNCPU_OP_CACHE_LB CHNCPU_OpCache_LB; | |
132 | -struct _CHNCPU_OP_CACHE_LB { | |
133 | - ch4_uint labelID; | |
134 | - ch4_uint opt; | |
135 | -}; | |
101 | + | |
136 | 102 | int CHNCPU_Op_LB_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
137 | 103 | { |
138 | 104 | CHNCPU_OpCache_LB *opCache; |
@@ -175,27 +141,10 @@ int CHNCPU_Op_LB_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FIL | ||
175 | 141 | return 0; |
176 | 142 | } |
177 | 143 | |
178 | -int CHNCPU_Op_LB_PrintWikiDoc(int opCode, FILE *file) | |
179 | -{ | |
180 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
181 | - "LB", | |
182 | - 0x01, 0x01, | |
183 | - "labelID", "opt", "", "", "", "", "", | |
184 | - "#labelID;", ""); | |
185 | - | |
186 | - return 0; | |
187 | -} | |
188 | - | |
189 | 144 | // |
190 | 145 | // 02 LIMM |
191 | 146 | // |
192 | 147 | |
193 | -typedef struct _CHNCPU_OP_CACHE_LIMM CHNCPU_OpCache_LIMM; | |
194 | -struct _CHNCPU_OP_CACHE_LIMM { | |
195 | - ch4_sint imm; | |
196 | - ch4_uint r; | |
197 | - ch4_uint bit; | |
198 | -}; | |
199 | 148 | int CHNCPU_Op_LIMM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
200 | 149 | { |
201 | 150 | CHNCPU_OpCache_LIMM *opCache; |
@@ -251,26 +200,9 @@ int CHNCPU_Op_LIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, F | ||
251 | 200 | return 0; |
252 | 201 | } |
253 | 202 | |
254 | -int CHNCPU_Op_LIMM_PrintWikiDoc(int opCode, FILE *file) | |
255 | -{ | |
256 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
257 | - "LIMM", | |
258 | - 0x02, 0x02, | |
259 | - "(sint)imm", "r", "bit", "", "", "", "", | |
260 | - "reg = imm;", ""); | |
261 | - | |
262 | - return 0; | |
263 | -} | |
264 | - | |
265 | 203 | // |
266 | 204 | // 03 PLIMM |
267 | 205 | // |
268 | - | |
269 | -typedef struct _CHNCPU_OP_CACHE_PLIMM CHNCPU_OpCache_PLIMM; | |
270 | -struct _CHNCPU_OP_CACHE_PLIMM { | |
271 | - ch4_uint labelID; | |
272 | - ch4_uint r; | |
273 | -}; | |
274 | 206 | int CHNCPU_Op_PLIMM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
275 | 207 | { |
276 | 208 | CHNCPU_OpCache_PLIMM *opCache; |
@@ -331,25 +263,9 @@ int CHNCPU_Op_PLIMM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, | ||
331 | 263 | return 0; |
332 | 264 | } |
333 | 265 | |
334 | -int CHNCPU_Op_PLIMM_PrintWikiDoc(int opCode, FILE *file) | |
335 | -{ | |
336 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
337 | - "PLIMM", | |
338 | - 0x03, 0x03, | |
339 | - "labelID", "p", "", "", "", "", "", | |
340 | - "p = #labelID;", ""); | |
341 | - | |
342 | - return 0; | |
343 | -} | |
344 | - | |
345 | 266 | // |
346 | 267 | // 04 CND |
347 | 268 | // |
348 | - | |
349 | -typedef struct _CHNCPU_OP_CACHE_CND CHNCPU_OpCache_CND; | |
350 | -struct _CHNCPU_OP_CACHE_CND { | |
351 | - ch4_uint r; | |
352 | -}; | |
353 | 269 | int CHNCPU_Op_CND_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
354 | 270 | { |
355 | 271 | CHNCPU_OpCache_CND *opCache; |
@@ -392,17 +308,6 @@ int CHNCPU_Op_CND_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FI | ||
392 | 308 | return 0; |
393 | 309 | } |
394 | 310 | |
395 | -int CHNCPU_Op_CND_PrintWikiDoc(int opCode, FILE *file) | |
396 | -{ | |
397 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
398 | - "CND", | |
399 | - 0x04, 0x04, | |
400 | - "r", "", "", "", "", "", "", | |
401 | - "if((reg0R & 1) == 0){ skip nextOp; }", "Prefix"); | |
402 | - | |
403 | - return 0; | |
404 | -} | |
405 | - | |
406 | 311 | // |
407 | 312 | // 05 CALLBIOS |
408 | 313 | // |
@@ -464,29 +369,9 @@ int CHNCPU_Op_CALLBIOS_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *o | ||
464 | 369 | return 0; |
465 | 370 | } |
466 | 371 | |
467 | -int CHNCPU_Op_CALLBIOS_PrintWikiDoc(int opCode, FILE *file) | |
468 | -{ | |
469 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
470 | - "CALLBIOS", | |
471 | - 0x05, 0x05, | |
472 | - "fid", "...", "", "", "", "", "", | |
473 | - "", ""); | |
474 | - | |
475 | - return 0; | |
476 | -} | |
477 | - | |
478 | 372 | // |
479 | 373 | // 08 LMEM |
480 | 374 | // |
481 | - | |
482 | -typedef struct _CHNCPU_OP_CACHE_LMEM CHNCPU_OpCache_LMEM; | |
483 | -struct _CHNCPU_OP_CACHE_LMEM { | |
484 | - ch4_uint p; | |
485 | - ch4_sint pType; | |
486 | - ch4_sint pDiff; | |
487 | - ch4_uint r; | |
488 | - ch4_uint bitDst; | |
489 | -}; | |
490 | 375 | int CHNCPU_Op_LMEM_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
491 | 376 | { |
492 | 377 | CHNCPU_OpCache_LMEM *opCache; |
@@ -553,43 +438,10 @@ int CHNCPU_Op_LMEM_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, F | ||
553 | 438 | |
554 | 439 | return 0; |
555 | 440 | } |
556 | -int CHNCPU_Op_LMEM_PrintWikiDoc(int opCode, FILE *file) | |
557 | -{ | |
558 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
559 | - "LMEM", | |
560 | - 0x08, 0x08 + 0x80, | |
561 | - "p", "(sint)pType", "(sint)pDiff", "r", "bitDst", "", "", | |
562 | - "", ""); | |
563 | - | |
564 | - return 0; | |
565 | -} | |
566 | 441 | |
567 | 442 | // |
568 | 443 | // Ternary Register Operation |
569 | 444 | // |
570 | - | |
571 | -// Bitwise | |
572 | -// 10 CP/OR | |
573 | -// 11 XOR | |
574 | -// 12 AND | |
575 | -// | |
576 | -// Arithmetic | |
577 | -// 14 ADD | |
578 | -// 15 SUB | |
579 | -// 16 MUL | |
580 | -// 18 SHL | |
581 | -// 19 SAR | |
582 | -// 1A DIV | |
583 | -// 1B MOD | |
584 | - | |
585 | -typedef struct _CHNCPU_OP_CACHE_TERNARY_REG CHNCPU_OpCache_TernaryReg; | |
586 | -struct _CHNCPU_OP_CACHE_TERNARY_REG { | |
587 | - ch4_uint r0; | |
588 | - ch4_uint r1; | |
589 | - ch4_uint r2; | |
590 | - ch4_uint bit; | |
591 | - unsigned int prefix; | |
592 | -}; | |
593 | 445 | int CHNCPU_Op_TernaryReg_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
594 | 446 | { |
595 | 447 | CHNCPU_OpCache_TernaryReg *opCache; |
@@ -714,22 +566,6 @@ char *CHNCPU_Op_TernaryReg_MnemonicList0[12] = { | ||
714 | 566 | "MOD" |
715 | 567 | }; |
716 | 568 | |
717 | -char *CHNCPU_Op_TernaryReg_CodeList0[12] = { | |
718 | - // 10 - 1B | |
719 | - "r0 = r1 | r2;", | |
720 | - "r0 = r1 ^ r2;", | |
721 | - "r0 = r1 & r2;", | |
722 | - "", | |
723 | - "r0 = r1 + r2;", | |
724 | - "r0 = r1 - r2;", | |
725 | - "r0 = r1 * r2;", | |
726 | - "", | |
727 | - "r0 = r1 << r2;", | |
728 | - "r0 = r1 >> r2;", | |
729 | - "r0 = r1 / r2;", | |
730 | - "r0 = r1 % r2;" | |
731 | -}; | |
732 | - | |
733 | 569 | int CHNCPU_Op_TernaryReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file) |
734 | 570 | { |
735 | 571 | CHNCPU_OpCache_TernaryReg *opCache; |
@@ -750,47 +586,9 @@ int CHNCPU_Op_TernaryReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag | ||
750 | 586 | return 0; |
751 | 587 | } |
752 | 588 | |
753 | -int CHNCPU_Op_TernaryReg_PrintWikiDoc(int opCode, FILE *file) | |
754 | -{ | |
755 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
756 | - CHNCPU_Op_TernaryReg_MnemonicList0[opCode - 0x10], | |
757 | - opCode, opCode + 0x80, | |
758 | - "r1", "r2", "r0", "bit", "", "", "", | |
759 | - CHNCPU_Op_TernaryReg_CodeList0[opCode - 0x10], ""); | |
760 | - | |
761 | - if(opCode == 0x10){ | |
762 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
763 | - "CP", | |
764 | - opCode, opCode + 0x80, | |
765 | - "r1", "r1", "r0", "bit", "", "", "", | |
766 | - "r0 = r1", ""); | |
767 | - } | |
768 | - | |
769 | - return 0; | |
770 | -} | |
771 | - | |
772 | 589 | // |
773 | 590 | // Compare Integer Register Operation |
774 | 591 | // |
775 | - | |
776 | -// 20 CMPE | |
777 | -// 21 CMPNE | |
778 | -// 22 CMPL | |
779 | -// 23 CMPGE | |
780 | -// 24 CMPLE | |
781 | -// 25 CMPG | |
782 | -// 26 TSTZ | |
783 | -// 27 TSTNZ | |
784 | - | |
785 | -typedef struct _CHNCPU_OP_CACHE_COMPARE_IREG CHNCPU_OpCache_CompareIReg; | |
786 | -struct _CHNCPU_OP_CACHE_COMPARE_IREG { | |
787 | - ch4_uint rSrc1; | |
788 | - ch4_uint rSrc2; | |
789 | - ch4_uint bitDiff; | |
790 | - ch4_uint rDst; | |
791 | - ch4_uint bitDst; | |
792 | - unsigned int prefix; | |
793 | -}; | |
794 | 592 | int CHNCPU_Op_CompareIReg_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
795 | 593 | { |
796 | 594 | CHNCPU_OpCache_CompareIReg *opCache; |
@@ -890,19 +688,6 @@ char *CHNCPU_Op_CompareIReg_MnemonicList0[8] = { | ||
890 | 688 | "TSTNZ", |
891 | 689 | }; |
892 | 690 | |
893 | -char *CHNCPU_Op_CompareIReg_CodeList0[8] = { | |
894 | - // 20-27 | |
895 | - "r0 = (r1 == r2) ? -1 : 0;", | |
896 | - "r0 = (r1 != r2) ? -1 : 0;", | |
897 | - "r0 = (r1 < r2) ? -1 : 0;", | |
898 | - "r0 = (r1 >= r2) ? -1 : 0;", | |
899 | - "r0 = (r1 <= r2) ? -1 : 0;", | |
900 | - "r0 = (r1 > r2) ? -1 : 0;", | |
901 | - "r0 = ((r1 & r2) == 0) ? -1 : 0;", | |
902 | - "r0 = ((r1 & r2) != 0) ? -1 : 0;", | |
903 | -}; | |
904 | - | |
905 | - | |
906 | 691 | int CHNCPU_Op_CompareIReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, FILE *file) |
907 | 692 | { |
908 | 693 | CHNCPU_OpCache_CompareIReg *opCache; |
@@ -920,31 +705,9 @@ int CHNCPU_Op_CompareIReg_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag | ||
920 | 705 | return 0; |
921 | 706 | } |
922 | 707 | |
923 | -int CHNCPU_Op_CompareIReg_PrintWikiDoc(int opCode, FILE *file) | |
924 | -{ | |
925 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
926 | - CHNCPU_Op_CompareIReg_MnemonicList0[opCode - 0x20], | |
927 | - opCode, opCode + 0x80, | |
928 | - "r1", "r2", "bitDiff", "r0", "bitDst", "", "", | |
929 | - CHNCPU_Op_CompareIReg_CodeList0[opCode - 0x20], ""); | |
930 | - | |
931 | - return 0; | |
932 | -} | |
933 | - | |
934 | 708 | // |
935 | 709 | // 2E DATA |
936 | 710 | // |
937 | -typedef struct _CHNCPU_OP_CACHE_DATA CHNCPU_OpCache_DATA; | |
938 | -struct _CHNCPU_OP_CACHE_DATA { | |
939 | - ch4_uint labelID; | |
940 | - ch4_uint labelOpt; | |
941 | - ch4_sint dataType; | |
942 | - ch4_uint dataCount; | |
943 | - void *rawData; | |
944 | - // | |
945 | - int rawDataByteSize; | |
946 | - const char *filePath; | |
947 | -}; | |
948 | 711 | int CHNCPU_Op_DATA_BindOperand(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, unsigned int prefix) |
949 | 712 | { |
950 | 713 | CHNCPU_OpCache_DATA *opCache; |
@@ -1020,16 +783,6 @@ int CHNCPU_Op_DATA_PrintCode(CHNCPU_RuntimeEnvironment *env, CHNCPU_OpTag *op, F | ||
1020 | 783 | |
1021 | 784 | return 0; |
1022 | 785 | } |
1023 | -int CHNCPU_Op_DATA_PrintWikiDoc(int opCode, FILE *file) | |
1024 | -{ | |
1025 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
1026 | - "DATA", | |
1027 | - 0x2E, 0x2E + 0x80, | |
1028 | - "labelID", "labelOpt", "(sint)dataType", "dataCount", "(rawData)...", "", "", | |
1029 | - "", ""); | |
1030 | - | |
1031 | - return 0; | |
1032 | -} | |
1033 | 786 | CHNCPU_OpTag *CHNCPU_Op_DATA_CreateDataFromFileAsPType(const char dataPath[], ch4_sint pType) |
1034 | 787 | { |
1035 | 788 | FILE *fp; |
@@ -1174,19 +927,3 @@ const char *CHNCPU_Op_DATA_GetFilePath(CHNCPU_OpTag *op) | ||
1174 | 927 | return ((CHNCPU_OpCache_DATA *)op->opCache)->filePath; |
1175 | 928 | } |
1176 | 929 | |
1177 | -// | |
1178 | -// Prefix2F | |
1179 | -// | |
1180 | - | |
1181 | -int CHNCPU_Op_Prefix2F_PrintWikiDoc(int opCode, FILE *file) | |
1182 | -{ | |
1183 | - fprintf(file, ", %s, %02X, %X, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", | |
1184 | - "Prefix2F-0", | |
1185 | - 0x2F, 0x2F + 0x80, | |
1186 | - "0", "", "", "", "", "", "", | |
1187 | - "DISABLE_BOUND_CHECK;", ""); | |
1188 | - | |
1189 | - return 0; | |
1190 | -} | |
1191 | - | |
1192 | - |
@@ -0,0 +1,64 @@ | ||
1 | +// | |
2 | +// debug.c | |
3 | +// chncpu | |
4 | +// | |
5 | +// Created by 西田 耀 on 2014/07/07. | |
6 | +// Copyright (c) 2014年 CHNOSProject. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +#include "chncpu.h" | |
10 | + | |
11 | +void CHNCPU_DumpAppBin(CHNCPU_RuntimeEnvironment *env) | |
12 | +{ | |
13 | + int i; | |
14 | + | |
15 | + for(i = 0; i < env->appbinsize; i++){ | |
16 | + printf("%02X ", env->appbin0[i]); | |
17 | + if((i & 0xf) == 0xf){ | |
18 | + putchar('\n'); | |
19 | + } | |
20 | + } | |
21 | + if(((i - 1) & 0xf) != 0xf){ | |
22 | + putchar('\n'); | |
23 | + } | |
24 | +} | |
25 | + | |
26 | +void CHNCPU_DumpIReg(CHNCPU_RuntimeEnvironment *env) | |
27 | +{ | |
28 | + int i, regs = 0; | |
29 | + | |
30 | + puts(">>> Integer registers"); | |
31 | + | |
32 | + for(i = 0; i < CHNCPU_NUMBER_OF_IREG; i++){ | |
33 | + if(env->iRegBits[i]){ | |
34 | + printf("R%02X = %10d = 0x%08X(%2d) ", i, env->iReg[i], env->iReg[i], env->iRegBits[i]); | |
35 | + putchar('\n'); | |
36 | + regs++; | |
37 | + } | |
38 | + } | |
39 | + if(((regs - 1) & 0xF) != 0xF){ | |
40 | + putchar('\n'); | |
41 | + } | |
42 | +} | |
43 | + | |
44 | +void CHNCPU_DumpPReg(CHNCPU_RuntimeEnvironment *env) | |
45 | +{ | |
46 | + int i, regs = 0; | |
47 | + | |
48 | + puts(">>> Pointer registers"); | |
49 | + | |
50 | + for(i = 0; i < CHNCPU_NUMBER_OF_PREG; i++){ | |
51 | + if(env->pReg[i].type != CHNCPU_PType_Undefined){ | |
52 | + if(env->pReg[i].mindex != CHNCPU_MemoryIndex_INVALID){ | |
53 | + printf("P%02X: Type:%2X mem[%d][%d]", i, env->pReg[i].type, env->pReg[i].mindex, env->pReg[i].pindex); | |
54 | + } else{ | |
55 | + printf("P%02X: Type:%2X %s[%d]", i, env->pReg[i].type, CHNCPU_Op_DATA_GetFilePath(env->pReg[i].opTag), env->pReg[i].pindex); | |
56 | + } | |
57 | + putchar('\n'); | |
58 | + regs++; | |
59 | + } | |
60 | + } | |
61 | + if(((regs - 1) & 0xF) != 0xF){ | |
62 | + putchar('\n'); | |
63 | + } | |
64 | +} |