diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2023-11-11 18:01:02 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2023-11-11 18:01:02 +0100 |
| commit | 7e0e61822271d88f1bd7c8eb8e1fd3d8a08c0249 (patch) | |
| tree | bd560215b28094107df2b00df6255bb977baecc5 | |
| parent | cf6f01390912f1cbc0af8769fff16347971889ae (diff) | |
| download | box64-7e0e61822271d88f1bd7c8eb8e1fd3d8a08c0249.tar.gz box64-7e0e61822271d88f1bd7c8eb8e1fd3d8a08c0249.zip | |
[ARM64_DYNAREC] Added emit_sar8c
| -rw-r--r-- | src/dynarec/arm64/dynarec_arm64_00.c | 32 | ||||
| -rw-r--r-- | src/dynarec/arm64/dynarec_arm64_emit_shift.c | 39 | ||||
| -rw-r--r-- | src/dynarec/arm64/dynarec_arm64_helper.h | 2 |
3 files changed, 50 insertions, 23 deletions
diff --git a/src/dynarec/arm64/dynarec_arm64_00.c b/src/dynarec/arm64/dynarec_arm64_00.c index cd312108..9e33e7f6 100644 --- a/src/dynarec/arm64/dynarec_arm64_00.c +++ b/src/dynarec/arm64/dynarec_arm64_00.c @@ -1796,22 +1796,12 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin break; case 7: INST_NAME("SAR Eb, Ib"); - GETSEB(x1, 1); - u8 = (F8)&0x1f; - if(u8) { - SETFLAGS(X_ALL, SF_PENDING); - UFLAG_IF{ - MOV32w(x4, u8); UFLAG_OP2(x4); - }; - UFLAG_OP1(ed); - if(u8) { - ASRw(ed, ed, u8); - EBBACK; - } - UFLAG_RES(ed); - UFLAG_DF(x3, d_sar8); - } else { - NOP; + if(geted_ib(dyn, addr, ninst, nextop)&0x1f) { + SETFLAGS(X_ALL, SF_SET_PENDING); + GETEB(x1, 1); + u8 = (F8)&0x1f; + emit_sar8c(dyn, ninst, ed, u8, x3, x4); + EBBACK; } break; } @@ -2132,14 +2122,10 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin break; case 7: INST_NAME("SAR Eb, 1"); - MOV32w(x2, 1); - SETFLAGS(X_ALL, SF_PENDING); - GETSEB(x1, 0); - UFLAG_OP12(ed, x2) - ASRw_REG(ed, ed, x2); + SETFLAGS(X_ALL, SF_SET_PENDING); // some flags are left undefined + GETEB(x1, 0); + emit_sar8c(dyn, ninst, ed, 1, x3, x4); EBBACK; - UFLAG_RES(ed); - UFLAG_DF(x3, d_sar8); break; } break; diff --git a/src/dynarec/arm64/dynarec_arm64_emit_shift.c b/src/dynarec/arm64/dynarec_arm64_emit_shift.c index 4e1a5b09..b625604d 100644 --- a/src/dynarec/arm64/dynarec_arm64_emit_shift.c +++ b/src/dynarec/arm64/dynarec_arm64_emit_shift.c @@ -440,6 +440,45 @@ void emit_shr8c(dynarec_arm_t* dyn, int ninst, int s1, uint32_t c, int s3, int s } } +// emit SAR8 instruction, from s1 , constant c, store result in s1 using s3 and s4 as scratch +void emit_sar8c(dynarec_arm_t* dyn, int ninst, int s1, uint32_t c, int s3, int s4) +{ + if(!c) + return; + IFX(X_PEND) { + MOV32w(s3, c); + STRB_U12(s1, xEmu, offsetof(x64emu_t, op1)); + STRB_U12(s3, xEmu, offsetof(x64emu_t, op2)); + SET_DF(s4, d_sar8); + } else IFX(X_ALL) { + SET_DFNONE(s4); + } + IFX(X_CF) { + ASRx(s3, s1, c-1); + BFIw(xFlags, s3, 0, 1); + } + ASRw(s1, s1, c); + IFX(X_PEND) { + STRB_U12(s1, xEmu, offsetof(x64emu_t, res)); + } + IFX(X_ZF) { + TSTw_mask(s1, 0, 7); + CSETw(s4, cEQ); + BFIw(xFlags, s4, F_ZF, 1); + } + IFX(X_SF) { + LSRw(s4, s1, 7); + BFIw(xFlags, s4, F_SF, 1); + } + IFX(X_OF) + if(c==1) { + BFCw(xFlags, F_OF, 1); + } + IFX(X_PF) { + emit_pf(dyn, ninst, s1, s3, s4); + } +} + // emit ROL32 instruction, from s1 , constant c, store result in s1 using s3 and s4 as scratch void emit_rol32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, uint32_t c, int s3, int s4) { diff --git a/src/dynarec/arm64/dynarec_arm64_helper.h b/src/dynarec/arm64/dynarec_arm64_helper.h index 2a420571..afb22e8a 100644 --- a/src/dynarec/arm64/dynarec_arm64_helper.h +++ b/src/dynarec/arm64/dynarec_arm64_helper.h @@ -1027,6 +1027,7 @@ void* arm64_next(x64emu_t* emu, uintptr_t addr); #define emit_shl8c STEPNAME(emit_shl8c) #define emit_shr8 STEPNAME(emit_shr8) #define emit_shr8c STEPNAME(emit_shr8c) +#define emit_sar8c STEPNAME(emit_sar8c) #define emit_rol32c STEPNAME(emit_rol32c) #define emit_ror32c STEPNAME(emit_ror32c) #define emit_rol8c STEPNAME(emit_rol8c) @@ -1164,6 +1165,7 @@ void emit_shl8(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3, int s4); void emit_shl8c(dynarec_arm_t* dyn, int ninst, int s1, uint32_t c, int s3, int s4); void emit_shr8(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3, int s4); void emit_shr8c(dynarec_arm_t* dyn, int ninst, int s1, uint32_t c, int s3, int s4); +void emit_sar8c(dynarec_arm_t* dyn, int ninst, int s1, uint32_t c, int s3, int s4); void emit_rol32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, uint32_t c, int s3, int s4); void emit_ror32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, uint32_t c, int s3, int s4); void emit_rol8c(dynarec_arm_t* dyn, int ninst, int s1, uint32_t c, int s3, int s4); |