about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-08 21:30:04 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-08 21:30:04 +0100
commit59779aea37ee365b8471cddf74ba78d395473c3a (patch)
tree77906e613efdb46a9086780d9ce13591258c245a /src
parent50fa1046c762ba27c4e704b7a1cfbca552e2c5c5 (diff)
downloadbox64-59779aea37ee365b8471cddf74ba78d395473c3a.tar.gz
box64-59779aea37ee365b8471cddf74ba78d395473c3a.zip
Added (F2/F3) A6 (REPNZ/REPZ) CMPSB
Diffstat (limited to 'src')
-rwxr-xr-xsrc/emu/x64run.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index 9d6312d1..1198ed71 100755
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -33,7 +33,7 @@ int Run(x64emu_t *emu, int step)
     uint8_t opcode;
     uint8_t nextop;
     reg64_t *oped, *opgd;
-    uint8_t tmp8u;
+    uint8_t tmp8u, tmp8u2;
     int8_t tmp8s;
     uint32_t tmp32u;
     uint64_t tmp64u;
@@ -451,6 +451,47 @@ x64emurun:
                 R_RDX=(R_EAX & 0x80000000)?0xFFFFFFFFFFFFFFFFL:0x0000000000000000L;
             break;
 
+        case 0xA6:                      /* (REPZ/REPNE) CMPSB */
+            tmp8s = ACCESS_FLAG(F_DF)?-1:+1;
+            switch(rep) {
+                case 1:
+                    tmp64u = R_RCX;
+                    while(tmp64u) {
+                        --tmp64u;
+                        tmp8u  = *(uint8_t*)R_RDI;
+                        tmp8u2 = *(uint8_t*)R_RSI;
+                        R_RDI += tmp8s;
+                        R_RSI += tmp8s;
+                        if(tmp8u==tmp8u2)
+                            break;
+                    }
+                    if(tmp64u) cmp8(emu, tmp8u2, tmp8u);
+                    R_RCX = tmp64u;
+                    break;
+                case 2:
+                    tmp64u = R_RCX;
+                    while(tmp64u) {
+                        --tmp64u;
+                    tmp8u  = *(uint8_t*)R_RDI;
+                    tmp8u2 = *(uint8_t*)R_RSI;
+                    R_RDI += tmp8s;
+                    R_RSI += tmp8s;
+                    if(tmp8u!=tmp8u2)
+                        break;
+                    }
+                    if(tmp64u) cmp8(emu, tmp8u2, tmp8u);
+                    R_RCX = tmp64u;
+                    break;
+                default:
+                    tmp8s = ACCESS_FLAG(F_DF)?-1:+1;
+                    tmp8u  = *(uint8_t*)R_RDI;
+                    tmp8u2 = *(uint8_t*)R_RSI;
+                    R_RDI += tmp8s;
+                    R_RSI += tmp8s;
+                    cmp8(emu, tmp8u2, tmp8u);
+            }
+            break;
+
         case 0xA8:                      /* TEST AL, Ib */
             test8(emu, R_AL, F8);
             break;