about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-09 17:50:34 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-09 17:50:34 +0100
commitb7683b77a71c76b6f3c502c5d22ca24792730be8 (patch)
tree315c4e30d08c349555987a9629c1a8b2c3d72f92 /src
parent3b81d444919adea23ebb4167d1c929716bdd32b8 (diff)
downloadbox64-b7683b77a71c76b6f3c502c5d22ca24792730be8.tar.gz
box64-b7683b77a71c76b6f3c502c5d22ca24792730be8.zip
Added a bunch of various opcodes
Diffstat (limited to 'src')
-rwxr-xr-xsrc/emu/x64run.c54
-rw-r--r--src/emu/x64run66.c48
-rw-r--r--src/emu/x64run660f.c37
-rw-r--r--src/emu/x64runf20f.c6
4 files changed, 145 insertions, 0 deletions
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index 0b1450b9..f3269a9f 100755
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -451,6 +451,29 @@ x64emurun:
                 R_RDX=(R_EAX & 0x80000000)?0xFFFFFFFFFFFFFFFFL:0x0000000000000000L;
             break;
 
+        case 0xA5:              /* (REP) MOVSD */
+            tmp8s = ACCESS_FLAG(F_DF)?-1:+1;
+            tmp64u = (rep)?R_RCX:1L;
+            if(rex.w) {
+                tmp8s *= 8;
+                while(tmp64u) {
+                    --tmp64u;
+                    *(uint64_t*)R_RDI = *(uint64_t*)R_RSI;
+                    R_RDI += tmp8s;
+                    R_RSI += tmp8s;
+                }
+            } else {
+                tmp8s *= 4;
+                while(tmp64u) {
+                    --tmp64u;
+                    *(uint32_t*)R_RDI = *(uint32_t*)R_RSI;
+                    R_RDI += tmp8s;
+                    R_RSI += tmp8s;
+                }
+            }
+            if(rep)
+                R_RCX = tmp64u;
+            break;
         case 0xA6:                      /* (REPZ/REPNE) CMPSB */
             tmp8s = ACCESS_FLAG(F_DF)?-1:+1;
             switch(rep) {
@@ -590,6 +613,21 @@ x64emurun:
                 emu->regs[(opcode&7)+(rex.b<<3)].q[0] = F32;
             break;
 
+        case 0xC0:                      /* GRP2 Eb,Ib */
+            nextop = F8;
+            GETEB(1);
+            tmp8u = F8/* & 0x1f*/; // masking done in each functions
+            switch((nextop>>3)&7) {
+                case 0: EB->byte[0] = rol8(emu, EB->byte[0], tmp8u); break;
+                case 1: EB->byte[0] = ror8(emu, EB->byte[0], tmp8u); break;
+                case 2: EB->byte[0] = rcl8(emu, EB->byte[0], tmp8u); break;
+                case 3: EB->byte[0] = rcr8(emu, EB->byte[0], tmp8u); break;
+                case 4:
+                case 6: EB->byte[0] = shl8(emu, EB->byte[0], tmp8u); break;
+                case 5: EB->byte[0] = shr8(emu, EB->byte[0], tmp8u); break;
+                case 7: EB->byte[0] = sar8(emu, EB->byte[0], tmp8u); break;
+            }
+            break;
         case 0xC1:                      /* GRP2 Ed,Ib */
             nextop = F8;
             GETED(1);
@@ -663,6 +701,22 @@ x64emurun:
             if(emu->quit) goto fini;
             break;
 
+        case 0xD0:                      /* GRP2 Eb,1 */
+        case 0xD2:                      /* GRP2 Eb,CL */
+            nextop = F8;
+            GETEB(0);
+            tmp8u = (opcode==0xD0)?1:R_CL;
+            switch((nextop>>3)&7) {
+                case 0: EB->byte[0] = rol8(emu, EB->byte[0], tmp8u); break;
+                case 1: EB->byte[0] = ror8(emu, EB->byte[0], tmp8u); break;
+                case 2: EB->byte[0] = rcl8(emu, EB->byte[0], tmp8u); break;
+                case 3: EB->byte[0] = rcr8(emu, EB->byte[0], tmp8u); break;
+                case 4: 
+                case 6: EB->byte[0] = shl8(emu, EB->byte[0], tmp8u); break;
+                case 5: EB->byte[0] = shr8(emu, EB->byte[0], tmp8u); break;
+                case 7: EB->byte[0] = sar8(emu, EB->byte[0], tmp8u); break;
+            }
+            break;
         case 0xD1:                      /* GRP2 Ed,1 */
         case 0xD3:                      /* GRP2 Ed,CL */
             nextop = F8;
diff --git a/src/emu/x64run66.c b/src/emu/x64run66.c
index a8c76926..74d08a3f 100644
--- a/src/emu/x64run66.c
+++ b/src/emu/x64run66.c
@@ -48,6 +48,54 @@ int Run66(x64emu_t *emu, rex_t rex)
     }

 

     switch(opcode) {

+    #define GO(B, OP)                                               \

+    case B+0:                                                       \

+        nextop = F8;                                                \

+        GETEB(0);                                                   \

+        GETGB;                                                      \

+        EB->byte[0] = OP##8(emu, EB->byte[0], GB);                  \

+        break;                                                      \

+    case B+1:                                                       \

+        nextop = F8;                                                \

+        GETEW(0);                                                   \

+        GETGW;                                                      \

+        if(rex.w)                                                   \

+            EW->q[0] = OP##64(emu, EW->q[0], GW->q[0]);             \

+        else                                                        \

+            EW->word[0] = OP##16(emu, EW->word[0], GW->word[0]);    \

+        break;                                                      \

+    case B+2:                                                       \

+        nextop = F8;                                                \

+        GETEB(0);                                                   \

+        GETGB;                                                      \

+        GB = OP##8(emu, GB, EB->byte[0]);                           \

+        break;                                                      \

+    case B+3:                                                       \

+        nextop = F8;                                                \

+        GETEW(0);                                                   \

+        GETGW;                                                      \

+        if(rex.w)                                                   \

+            GW->q[0] = OP##64(emu, GW->q[0], EW->q[0]);             \

+        else                                                        \

+        GW->word[0] = OP##16(emu, GW->word[0], EW->word[0]);        \

+        break;                                                      \

+    case B+4:                                                       \

+        R_AL = OP##8(emu, R_AL, F8);                                \

+        break;                                                      \

+    case B+5:                                                       \

+        if(rex.w)                                                   \

+            R_RAX = OP##64(emu, R_RAX, F32S64);                     \

+        else                                                        \

+            R_AX = OP##16(emu, R_AX, F16);                          \

+        break;

+

+    GO(0x00, add)                   /* ADD 0x01 ~> 0x05 */

+    GO(0x08, or)                    /*  OR 0x09 ~> 0x0D */

+    GO(0x10, adc)                   /* ADC 0x11 ~> 0x15 */

+    GO(0x18, sbb)                   /* SBB 0x19 ~> 0x1D */

+    GO(0x20, and)                   /* AND 0x21 ~> 0x25 */

+    GO(0x28, sub)                   /* SUB 0x29 ~> 0x2D */

+    GO(0x30, xor)                   /* XOR 0x31 ~> 0x35 */

 

     case 0x0F:                              /* more opcdes */

         return Run660F(emu, rex);

diff --git a/src/emu/x64run660f.c b/src/emu/x64run660f.c
index fbf2f045..8fe491ff 100644
--- a/src/emu/x64run660f.c
+++ b/src/emu/x64run660f.c
@@ -33,16 +33,53 @@ int Run660F(x64emu_t *emu, rex_t rex)
     int32_t tmp32s;

     reg64_t *oped, *opgd;

     sse_regs_t *opex, *opgx;

+    mmx87_regs_t *opem;

 

     opcode = F8;

 

     switch(opcode) {

 

+    case 0x14:                      /* UNPCKLPD Gx, Ex */

+        nextop = F8;

+        GETEX(0);

+        GETGX;

+        GX->q[1] = EX->q[0];

+        break;

+    case 0x15:                      /* UNPCKHPD Gx, Ex */

+        nextop = F8;

+        GETEX(0);

+        GETGX;

+        GX->q[0] = GX->q[1];

+        GX->q[1] = EX->q[1];

+        break;

+

     case 0x1F:                      /* NOP (multi-byte) */

         nextop = F8;

         GETED(0);

         break;

 

+    case 0x28:                      /* MOVAPD Gx, Ex */

+        nextop = F8;

+        GETEX(0);

+        GETGX;

+        GX->q[0] = EX->q[0];

+        GX->q[1] = EX->q[1];

+        break;

+    case 0x29:                      /* MOVAPD Ex, Gx */

+        nextop = F8;

+        GETEX(0);

+        GETGX;

+        EX->q[0] = GX->q[0];

+        EX->q[1] = GX->q[1];

+        break;

+    case 0x2A:                      /* CVTPI2PD Gx, Em */

+        nextop = F8;

+        GETEM(0);

+        GETGX;

+        GX->d[0] = EM->sd[0];

+        GX->d[1] = EM->sd[1];

+        break;

+

     case 0x2E:                      /* UCOMISD Gx, Ex */

         // no special check...

     case 0x2F:                      /* COMISD Gx, Ex */

diff --git a/src/emu/x64runf20f.c b/src/emu/x64runf20f.c
index a462f74a..10ab06c3 100644
--- a/src/emu/x64runf20f.c
+++ b/src/emu/x64runf20f.c
@@ -74,6 +74,12 @@ int RunF20F(x64emu_t *emu, rex_t rex)
             GD->sdword[0] = EX->d[0];

         break;

 

+    case 0x58:  /* ADDSD Gx, Ex */

+        nextop = F8;

+        GETEX(0);

+        GETGX;

+        GX->d[0] += EX->d[0];

+        break;

     case 0x59:  /* MULSD Gx, Ex */

         nextop = F8;

         GETEX(0);