about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-07-05 21:58:11 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-07-05 21:58:11 +0200
commitab83d86300a8d7e5cca08ac60b867ed85a7bab03 (patch)
tree6d019b2de34eb341a48f754852f5f101a76c16fc /src
parent450cad7a4d5c7f6aa011c670e7b9fec1f732a464 (diff)
downloadbox64-ab83d86300a8d7e5cca08ac60b867ed85a7bab03.tar.gz
box64-ab83d86300a8d7e5cca08ac60b867ed85a7bab03.zip
Added F0 80 opcode ([DYNAREC] too)
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/dynarec_arm64_f0.c163
-rw-r--r--src/emu/x64runf0.c32
2 files changed, 193 insertions, 2 deletions
diff --git a/src/dynarec/dynarec_arm64_f0.c b/src/dynarec/dynarec_arm64_f0.c
index 4cf6a230..b6c3c650 100644
--- a/src/dynarec/dynarec_arm64_f0.c
+++ b/src/dynarec/dynarec_arm64_f0.c
@@ -29,7 +29,7 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
 
     uint8_t opcode = F8;
     uint8_t nextop;
-    uint8_t gd, ed;
+    uint8_t gd, ed, u8;
     uint8_t wback, wb1, wb2, gb1, gb2;
     int32_t i32;
     int64_t i64, j64;
@@ -436,6 +436,167 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             }
             break;
 
+        case 0x80:
+            nextop = F8;
+            switch((nextop>>3)&7) {
+                case 0: //ADD
+                    INST_NAME("ADD Eb, Ib");
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    if(MODREG) {
+                        GETEB(x1, 1);
+                        u8 = F8;
+                        emit_add8c(dyn, ninst, x1, u8, x2, x4);
+                        wb1 = 0;
+                    } else {
+                        addr = geted(dyn, addr, ninst, nextop, &wback, x5, &fixedaddress, 0, 0, rex, 0, 1);
+                        u8 = F8;
+                        wb1 = 1;
+                        MARKLOCK;
+                        LDAXRB(x1, wback);
+                        emit_add8c(dyn, ninst, x1, u8, x2, x4);
+                        STLXRB(x3, x1, wback);
+                        CBNZx_MARKLOCK(x3);
+                    }
+                    EBBACK;
+                    break;
+                case 1: //OR
+                    INST_NAME("OR Eb, Ib");
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    if(MODREG) {
+                        GETEB(x1, 1);
+                        u8 = F8;
+                        emit_or8c(dyn, ninst, x1, u8, x2, x4);
+                        wb1 = 0;
+                    } else {
+                        addr = geted(dyn, addr, ninst, nextop, &wback, x5, &fixedaddress, 0, 0, rex, 0, 1);
+                        u8 = F8;
+                        wb1 = 1;
+                        MARKLOCK;
+                        LDAXRB(x1, wback);
+                        emit_or8c(dyn, ninst, x1, u8, x2, x4);
+                        STLXRB(x3, x1, wback);
+                        CBNZx_MARKLOCK(x3);
+                    }
+                    EBBACK;
+                    break;
+                case 2: //ADC
+                    INST_NAME("ADC Eb, Ib");
+                    READFLAGS(X_CF);
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    if(MODREG) {
+                        GETEB(x1, 1);
+                        u8 = F8;
+                        emit_adc8c(dyn, ninst, x1, u8, x2, x4, x5);
+                        wb1 = 0;
+                    } else {
+                        addr = geted(dyn, addr, ninst, nextop, &wback, x5, &fixedaddress, 0, 0, rex, 0, 1);
+                        u8 = F8;
+                        wb1 = 1;
+                        MARKLOCK;
+                        LDAXRB(x1, wback);
+                        emit_adc8c(dyn, ninst, x1, u8, x2, x4, x5);
+                        STLXRB(x3, x1, wback);
+                        CBNZx_MARKLOCK(x3);
+                    }
+                    EBBACK;
+                    break;
+                case 3: //SBB
+                    INST_NAME("SBB Eb, Ib");
+                    READFLAGS(X_CF);
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    if(MODREG) {
+                        GETEB(x1, 1);
+                        u8 = F8;
+                        emit_sbb8c(dyn, ninst, x1, u8, x2, x4, x5);
+                        wb1 = 0;
+                    } else {
+                        addr = geted(dyn, addr, ninst, nextop, &wback, x5, &fixedaddress, 0, 0, rex, 0, 1);
+                        u8 = F8;
+                        wb1 = 1;
+                        MARKLOCK;
+                        LDAXRB(x1, wback);
+                        emit_sbb8c(dyn, ninst, x1, u8, x2, x4, x5);
+                        STLXRB(x3, x1, wback);
+                        CBNZx_MARKLOCK(x3);
+                    }
+                    EBBACK;
+                    break;
+                case 4: //AND
+                    INST_NAME("AND Eb, Ib");
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    if(MODREG) {
+                        GETEB(x1, 1);
+                        u8 = F8;
+                        emit_and8c(dyn, ninst, x1, u8, x2, x4);
+                        wb1 = 0;
+                    } else {
+                        addr = geted(dyn, addr, ninst, nextop, &wback, x5, &fixedaddress, 0, 0, rex, 0, 1);
+                        u8 = F8;
+                        wb1 = 1;
+                        MARKLOCK;
+                        LDAXRB(x1, wback);
+                        emit_and8c(dyn, ninst, x1, u8, x2, x4);
+                        STLXRB(x3, x1, wback);
+                        CBNZx_MARKLOCK(x3);
+                    }
+                    EBBACK;
+                    break;
+                case 5: //SUB
+                    INST_NAME("SUB Eb, Ib");
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    if(MODREG) {
+                        GETEB(x1, 1);
+                        u8 = F8;
+                        emit_sub8c(dyn, ninst, x1, u8, x2, x4, x5);
+                        wb1 = 0;
+                    } else {
+                        addr = geted(dyn, addr, ninst, nextop, &wback, x5, &fixedaddress, 0, 0, rex, 0, 1);
+                        u8 = F8;
+                        wb1 = 1;
+                        MARKLOCK;
+                        LDAXRB(x1, wback);
+                        emit_sub8c(dyn, ninst, x1, u8, x2, x4, x5);
+                        STLXRB(x3, x1, wback);
+                        CBNZx_MARKLOCK(x3);
+                    }
+                    EBBACK;
+                    break;
+                case 6: //XOR
+                    INST_NAME("XOR Eb, Ib");
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    if(MODREG) {
+                        GETEB(x1, 1);
+                        u8 = F8;
+                        emit_xor8c(dyn, ninst, x1, u8, x2, x4);
+                        wb1 = 0;
+                    } else {
+                        addr = geted(dyn, addr, ninst, nextop, &wback, x5, &fixedaddress, 0, 0, rex, 0, 1);
+                        u8 = F8;
+                        wb1 = 1;
+                        MARKLOCK;
+                        LDAXRB(x1, wback);
+                        emit_xor8c(dyn, ninst, x1, u8, x2, x4);
+                        STLXRB(x3, x1, wback);
+                        CBNZx_MARKLOCK(x3);
+                    }
+                    EBBACK;
+                    break;
+                case 7: //CMP
+                    INST_NAME("CMP Eb, Ib");
+                    SETFLAGS(X_ALL, SF_SET_PENDING);
+                    GETEB(x1, 1);
+                    u8 = F8;
+                    if(u8) {
+                        MOV32w(x2, u8);
+                        emit_cmp8(dyn, ninst, x1, x2, x3, x4, x5);
+                    } else {
+                        emit_cmp8_0(dyn, ninst, x1, x3, x4);
+                    }
+                    break;
+                default:
+                    DEFAULT;
+            }
+            break;
         case 0x81:
         case 0x83:
             nextop = F8;
diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c
index 1a0ada10..4c4d504d 100644
--- a/src/emu/x64runf0.c
+++ b/src/emu/x64runf0.c
@@ -30,7 +30,7 @@ int RunF0(x64emu_t *emu, rex_t rex)
 {

     uint8_t opcode;

     uint8_t nextop;

-    uint8_t tmp8u;

+    uint8_t tmp8u, tmp8u2;      (void)tmp8u2;

     int32_t tmp32s;             (void)tmp32s;

     uint32_t tmp32u, tmp32u2;

     int64_t tmp64s;

@@ -523,6 +523,36 @@ int RunF0(x64emu_t *emu, rex_t rex)
         case 0x66:

             return Run66F0(emu, rex);   // more opcode F0 66 and 66 F0 is the same

 

+        case 0x80:                      /* GRP Eb,Ib */

+            nextop = F8;

+            GETEB(1);

+            tmp8u = F8;

+#ifdef DYNAREC

+            switch((nextop>>3)&7) {

+                case 0: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = add8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 1: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 =  or8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 2: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = adc8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 3: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = sbb8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 4: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = and8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 5: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = sub8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 6: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = xor8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 7:               cmp8(emu, EB->byte[0], tmp8u); break;

+            }

+#else

+            pthread_mutex_lock(&emu->context->mutex_lock);

+            switch((nextop>>3)&7) {

+                case 0: EB->byte[0] = add8(emu, EB->byte[0], tmp8u); break;

+                case 1: EB->byte[0] =  or8(emu, EB->byte[0], tmp8u); break;

+                case 2: EB->byte[0] = adc8(emu, EB->byte[0], tmp8u); break;

+                case 3: EB->byte[0] = sbb8(emu, EB->byte[0], tmp8u); break;

+                case 4: EB->byte[0] = and8(emu, EB->byte[0], tmp8u); break;

+                case 5: EB->byte[0] = sub8(emu, EB->byte[0], tmp8u); break;

+                case 6: EB->byte[0] = xor8(emu, EB->byte[0], tmp8u); break;

+                case 7:               cmp8(emu, EB->byte[0], tmp8u); break;

+            }

+            pthread_mutex_unlock(&emu->context->mutex_lock);

+#endif

+            break;

         case 0x81:              /* GRP Ed,Id */

         case 0x83:              /* GRP Ed,Ib */

             nextop = F8;