• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisióne60dffbbb2da2872fc46a56d18c83ad56baadbce (tree)
Tiempo2014-05-22 20:15:13
Autorhikarupsp <hikarupsp@user...>
Commiterhikarupsp

Log Message

osecpu106a

Cambiar Resumen

Diferencia incremental

--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
1+CC = cc
2+SRCS = extend.c float.c integer.c osecpu-vm.c pointer.c test.c
3+BINNAME = osecpu-test.bin
4+
5+$(BINNAME): $(SRCS)
6+ $(CC) -o $@ $(SRCS)
7+
8+
--- a/memo.txt
+++ b/memo.txt
@@ -28,3 +28,8 @@
2828 倍精度である64bitをサポートするかは処理系依存。
2929 floatのサポートそのものがない場合も許す。
3030
31+2014.05.22木:
32+ data文まではとりあえずできた。
33+ data命令でも浮動小数点を使えるようになりたいからそれは後日がんばる。
34+ 次はLMEMだなー。その次がPADD。
35+
--- a/osecpu-vm.h
+++ b/osecpu-vm.h
@@ -6,8 +6,20 @@ typedef int Int32; // 32bit
66
77 #define DEFINES_MAXLABELS 4096
88
9+typedef struct _PtrCtrl {
10+ int liveSign;
11+ int size, typ;
12+ unsigned char *p0;
13+} PtrCtrl;
14+
915 typedef struct _PReg {
10- void *p;
16+ unsigned char *p;
17+ int typ;
18+ unsigned char *p0, *p1;
19+ int liveSign;
20+ struct PtrCtrl *pls;
21+ int flags; /* read/writeなど */
22+ unsigned char *bit;
1123 } PReg;
1224
1325 typedef struct _Label {
--- a/pointer.c
+++ b/pointer.c
@@ -1,6 +1,6 @@
11 #include "osecpu-vm.h"
22
3-// ポインタ関連命令: 01, 03
3+// ポインタ関連命令: 01, 03, 2E
44
55 void jitcInitPointer(OsecpuJitc *jitc)
66 {
@@ -15,16 +15,21 @@ void jitcStep_checkPxx(int *pRC, int pxx)
1515 }
1616
1717 void getTypSize(int typ, int *typSize0, int *typSize1, int *typSign)
18+// typSize0: 入力バイナリ内でのビット数.
19+// typSize1: 出力バイナリ内でのバイト数.
1820 {
1921 *typSize0 = *typSize1 = -1;
2022 if (2 <= typ && typ <= 21) {
2123 static unsigned char table[10] = { 8, 16, 32, 4, 2, 1, 12, 20, 24, 28 };
24+ int bytes;
2225 if ((typ & 1) == 0)
2326 *typSign = -1; // typが偶数なら符号あり.
2427 else
2528 *typSign = 0; // typが奇数なら符号なし.
2629 *typSize0 = table[(typ - 2) / 2];
27- *typSize1 = (*typSize0 + 7) / 8;
30+ bytes = (*typSize0 + 7) / 8;
31+ if (bytes == 3) bytes = 4;
32+ *typSize1 = bytes;
2833 }
2934 return;
3035 }
@@ -126,6 +131,9 @@ int jitcStepPointer(OsecpuJitc *jitc)
126131 psi[i] = bitReaderGetNbitSigned(&br, typSize0);
127132 }
128133 jitc->dst += (typSize1 * len + 3) / 4;
134+ unsigned char *puc = (unsigned char *) jitc->dst;
135+ for (i = 0; i < len; i++)
136+ puc[i] = 0xff; // bits=255.
129137 jitc->dst += (len + 3) / 4;
130138 }
131139 for (j = 0; j < JITC_DSTLOG_SIZE; j++) {
@@ -136,6 +144,8 @@ int jitcStepPointer(OsecpuJitc *jitc)
136144 jitc->defines->label[i].typ = typ;
137145 jitc->defines->label[i].dst = ip;
138146 }
147+ goto fin;
148+
139149 }
140150 goto fin1;
141151 fin:
@@ -163,14 +173,30 @@ void execStepPointer(OsecpuVm *vm)
163173 i = ip[1]; p = ip[2];
164174 if (p == 0x3f)
165175 ip = (const Int32 *) vm->defines->label[i].dst;
166- else
176+ else {
177+ typ = vm->defines->label[i].typ;
178+ vm->p[p].p = (unsigned char *) vm->defines->label[i].dst;
179+ vm->p[p].typ = typ;
180+ vm->p[p].p0 = vm->p[p].p;
181+ if (typ >= 2) {
182+ len = vm->defines->label[i].dst[2]; // 2e(data)のlenフィールド値.
183+ getTypSize(typ, NULL, &typSize1, NULL);
184+ vm->p[p].p1 = vm->p[p].p + typSize1 * len;
185+ vm->p[p].bit = vm->p[p].p + ((typSize1 * len + 3) / 4) * 4;
186+ }
187+ if (typ == -1) { // コードラベル.
188+ vm->p[p].p1 = vm->p[p].p + 1;
189+ }
190+ if (typ == 1) { // VPtr.
191+ }
167192 ip += 3;
193+ }
168194 goto fin;
169195 }
170196 if (opecode == 0x2e) { // data
171197 typ = ip[1]; len = ip[2];
172198 getTypSize(typ, &typSize0, &typSize1, &typSign);
173- ip += 3 + (typSize1 * len + 3) / 4;
199+ ip += 3 + (typSize1 * len + 3) / 4 + (len + 3) / 4;
174200 goto fin;
175201 }
176202 fin:
--- a/test.c
+++ b/test.c
@@ -9,6 +9,7 @@ int main(int argc, const char **argv)
99 OsecpuVm vm;
1010 unsigned char hh4src[BUFFER_SIZE], *hh4src1;
1111 Int32 i32buf[BUFFER_SIZE], j32buf[BUFFER_SIZE];
12+ int rc;
1213 jitc.defines = &defs;
1314 vm.defines = &defs;
1415
@@ -31,6 +32,7 @@ int main(int argc, const char **argv)
3132 "4 bf" // CND(R3F);
3233 "3 0 bf" // PLIMM(P3F, 0);
3334
35+#if 0
3436 // F03 = 4 * (1 - 1/3 + 1/5 - 1/7 + ...)
3537 // テストなので速度とかを気にせず、極力Fxxを使ってみる.
3638 "c40 0 0 3 c40" // FLIMM64(F03, 0);
@@ -47,10 +49,21 @@ int main(int argc, const char **argv)
4749 "c49 5 bf c40 bf a0" // FCMPNE32_64(R3F, F05, F3F);
4850 "4 bf" // CND(R3F);
4951 "3 1 bf" // PLIMM(P3F, 1);
52+#endif
5053
54+#if 0
5155 "2 0 3 0" // LIMM0(R03, 0);
52- "90 3 3 3 a0", // CP32(R03, R03); // ここでエラーコード1になる.
53- NULL, hh4src, &hh4src[BUFFER_SIZE]
56+ "90 3 3 3 a0" // CP32(R03, R03); // ここでエラーコード1になる.
57+#endif
58+
59+#if 1
60+ "1 2 1" // LB1(2);
61+ "ae 2 84 01 23 45 67" // data(UINT8, 4, 0x01, 0x23, 0x45, 0x67);
62+ "3 2 1" // PLIMM(P01, 2);
63+ "2 1 3 a0" // LIMM32(R03, 1);
64+#endif
65+
66+ , NULL, hh4src, &hh4src[BUFFER_SIZE]
5467 );
5568
5669 if (hh4src1 == NULL) {
@@ -63,7 +76,9 @@ int main(int argc, const char **argv)
6376 hh4ReaderInit(&jitc.hh4r, hh4src, 0, hh4src1, 0);
6477 jitc.dst = j32buf;
6578 jitc.dst1 = &j32buf[BUFFER_SIZE];
66- printf("jitcAll()=%d\n", jitcAll(&jitc)); // 0なら成功.
79+ rc = jitcAll(&jitc);
80+ printf("jitcAll()=%d\n", rc); // 0なら成功.
81+ if (rc != 0) return 1;
6782 *jitc.dst = -1; // デバッグ用の特殊opecode.
6883 vm.ip = j32buf;
6984 vm.ip1 = jitc.dst;
@@ -72,11 +87,12 @@ int main(int argc, const char **argv)
7287 // execAll()を使って、j32buf[]内の中間コードを実行する.
7388 printf("execAll()=%d\n", execAll(&vm)); // 65535なら成功(EXEC_ABORT_OPECODE_M1).
7489 printf("R00=%d\n", vm.r[0x00]);
90+ printf("R01=%d\n", vm.r[0x01]);
91+ printf("R02=%d\n", vm.r[0x02]);
92+ printf("R03=%d\n", vm.r[0x03]);
7593 printf("F00=%f\n", vm.f[0x00]);
7694 printf("F01=%.15f\n", vm.f[0x01]);
7795 printf("F02=%.15f\n", vm.f[0x02]);
78- printf("R01=%d\n", vm.r[0x01]);
79- printf("R02=%d\n", vm.r[0x02]);
8096 printf("F03=%f\n", vm.f[0x03]);
8197 printf("F04=%f\n", vm.f[0x04]);
8298