OSDN Git Service

added some comments
authorttwilb <ttwilb@users.sourceforge.jp>
Mon, 10 Mar 2014 13:48:10 +0000 (22:48 +0900)
committerttwilb <ttwilb@users.sourceforge.jp>
Mon, 10 Mar 2014 13:48:10 +0000 (22:48 +0900)
jitc.c
main.c
osecpu.h
switch.h

diff --git a/jitc.c b/jitc.c
index 9986d4c..6d80bf1 100644 (file)
--- a/jitc.c
+++ b/jitc.c
@@ -481,6 +481,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                        *       03      PXX     imm32
                        *
                        * ・P28 はAPI用
+                       * ・P30 はリターンアドレス
                        * ・P3F はプログラムカウンタ
                        */
 
@@ -558,6 +559,12 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr
                        break;
 
                case 0x04:      /* CND (prefix) */
+
+                       /*
+                        * CND命令
+                        * 与えられたRxxの最下位ビットが1であれば後続の命令を実行、そうでなければ飛ばす。
+                        */
+                       
                        if (src[1] >= 0x40) w.err = JITC_ERR_REGNUM;    // R00-R3F 以外のレジスタは比較対象にできない
 
                        // 比較対象のレジスタがメモリ上にあれば-1, それ以外なら適切なレジスタ番号を返す
@@ -1633,7 +1640,7 @@ void errHndl(struct Regs *r)
 int jitc0(unsigned char **qq, unsigned char *q1, const unsigned char *p0, const unsigned char *p1, int level, struct LabelTable *label)
 {
        unsigned char *q = *qq;
-       if (p0[0] != 0x05 || p0[1] != SIGN1)
+       if (p0[0] != 0x05 || p0[1] != SIGN1)    // OSECPUのヘッダ (05E1) を確認
                return 1;
 
        *q++ = 0x55; /* PUSH(EBP); */
diff --git a/main.c b/main.c
index 4b17520..cae2aa5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -67,8 +67,6 @@ int osecpuMain(int argc, char **argv)
        if (syslib[0] == 0x05 && syslib[1] == 0xc1) {
                
                // 一体この部分ではなにをやっているのだろう?
-               // OSECPUに0x05, 0x1bという命令はないが... ヘッダ?
-               // どうせ初めからの32バイトは無視されるのだろうに...
 
                memcpy(systmp0, syslib, appsiz0);
                ComLib_main(systmp0 + 2, syslib + 2);
index 38925f0..7d636c2 100644 (file)
--- a/osecpu.h
+++ b/osecpu.h
@@ -37,6 +37,8 @@ struct LabelTable {
         * default = -1
         * TYP_CODE = 0
         * T_UINT8 = 3
+        *
+        * 将来的には UInt8, SInt32, Flt64, UInt8, VPtr が使えるようになる http://osecpu.osask.jp/wiki/?page0053
         */
        int typ;
 };
index 51abed1..94953c6 100644 (file)
--- a/switch.h
+++ b/switch.h
  * OSECPUの動作にはsyslib.oseが必要。
  */
 #define SYSLIB_OSE     "syslib.ose"
+
+/*
+ * OSECPUバイナリのシグネチャ (05 e1)の2バイト目。
+ * rev.2 ではこれが e2 になる。(バイナリレベルの互換性はない)
+ */
 #define SIGN1          0xe1