diff options
| author | xctan <xctan@cirno.icu> | 2024-06-07 17:37:29 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-07 11:37:29 +0200 |
| commit | d4b02e6a3fa74a73f42e230d920e91543a3b832b (patch) | |
| tree | 6a54a029cf9164f1ebfabf854b1952c13b73d011 | |
| parent | 537cb65f26afd07cbc2332f0a60c181f5c75c0d7 (diff) | |
| download | box64-d4b02e6a3fa74a73f42e230d920e91543a3b832b.tar.gz box64-d4b02e6a3fa74a73f42e230d920e91543a3b832b.zip | |
[RV64_DYNAREC] Fixed sign extension of 8-bit immediate in 66 opcodes (#1568)
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_66.c | 16 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_66f0.c | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_66.c b/src/dynarec/rv64/dynarec_rv64_66.c index 18474468..ba57b57d 100644 --- a/src/dynarec/rv64/dynarec_rv64_66.c +++ b/src/dynarec/rv64/dynarec_rv64_66.c @@ -455,7 +455,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni if(opcode==0x81) {INST_NAME("ADD Ew, Iw");} else {INST_NAME("ADD Ew, Ib");} SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; MOV64x(x5, u64); emit_add16(dyn, ninst, ed, x5, x2, x4, x6); EWBACK; @@ -464,7 +464,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni if(opcode==0x81) {INST_NAME("OR Ew, Iw");} else {INST_NAME("OR Ew, Ib");} SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; MOV64x(x5, u64); emit_or16(dyn, ninst, x1, x5, x2, x4); EWBACK; @@ -474,7 +474,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni READFLAGS(X_CF); SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; MOV64x(x5, u64); emit_adc16(dyn, ninst, x1, x5, x2, x4, x6); EWBACK; @@ -484,7 +484,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni READFLAGS(X_CF); SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; MOV64x(x5, u64); emit_sbb16(dyn, ninst, x1, x5, x2, x4, x6); EWBACK; @@ -493,7 +493,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni if(opcode==0x81) {INST_NAME("AND Ew, Iw");} else {INST_NAME("AND Ew, Ib");} SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; MOV64x(x5, u64); emit_and16(dyn, ninst, x1, x5, x2, x4); EWBACK; @@ -502,7 +502,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni if(opcode==0x81) {INST_NAME("SUB Ew, Iw");} else {INST_NAME("SUB Ew, Ib");} SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; MOV64x(x5, u64); emit_sub16(dyn, ninst, x1, x5, x2, x4, x6); EWBACK; @@ -511,7 +511,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni if(opcode==0x81) {INST_NAME("XOR Ew, Iw");} else {INST_NAME("XOR Ew, Ib");} SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; MOV64x(x5, u64); emit_xor16(dyn, ninst, x1, x5, x2, x4, x6); EWBACK; @@ -520,7 +520,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni if(opcode==0x81) {INST_NAME("CMP Ew, Iw");} else {INST_NAME("CMP Ew, Ib");} SETFLAGS(X_ALL, SF_SET_PENDING); GETEW(x1, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else u64 = (uint16_t)(int16_t)F8S; if(u64) { MOV64x(x2, u64); emit_cmp16(dyn, ninst, x1, x2, x3, x4, x5, x6); diff --git a/src/dynarec/rv64/dynarec_rv64_66f0.c b/src/dynarec/rv64/dynarec_rv64_66f0.c index 6e51ebc9..02fdae40 100644 --- a/src/dynarec/rv64/dynarec_rv64_66f0.c +++ b/src/dynarec/rv64/dynarec_rv64_66f0.c @@ -128,7 +128,7 @@ uintptr_t dynarec64_66F0(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } SETFLAGS(X_ALL, SF_SET_PENDING); if(MODREG) { - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else (uint16_t)(int16_t)F8S; ed = xRAX+(nextop&7)+(rex.b<<3); MOV64x(x5, u64); ZEXTH(x6, ed); @@ -138,7 +138,7 @@ uintptr_t dynarec64_66F0(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int OR(ed, ed, x6); } else { addr = geted(dyn, addr, ninst, nextop, &wback, x2, x1, &fixedaddress, rex, LOCK_LOCK, 0, (opcode==0x81)?2:1); - if(opcode==0x81) u64 = F16; else u64 = F8; + if(opcode==0x81) u64 = F16; else (uint16_t)(int16_t)F8S; MOV64x(x5, u64); ANDI(x3, wback, 0b10); |