about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-11-16 11:24:12 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-11-16 11:24:12 +0100
commitd76ea27c54878fb3880ca691fff14bb1b207f65e (patch)
treeb6c322b7d2e51416f6648353d562fe2606d25edb /src
parent90b606584da7f20f1b8c34c1a8a5cfe78ae5545c (diff)
downloadbox64-d76ea27c54878fb3880ca691fff14bb1b207f65e.tar.gz
box64-d76ea27c54878fb3880ca691fff14bb1b207f65e.zip
[INTERPRETER] Fixed OF flags for shld opcodes
Diffstat (limited to 'src')
-rw-r--r--src/emu/x64primop.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/emu/x64primop.c b/src/emu/x64primop.c
index 6e64d7a2..a914eb05 100644
--- a/src/emu/x64primop.c
+++ b/src/emu/x64primop.c
@@ -975,8 +975,7 @@ uint16_t shld16 (x64emu_t *emu, uint16_t d, uint16_t fill, uint8_t s)
 			res = d;
 		}
 		if (cnt == 1) {
-			CONDITIONAL_SET_FLAG((((res & 0x8000) == 0x8000) ^
-								  (ACCESS_FLAG(F_CF) != 0)), F_OF);
+			CONDITIONAL_SET_FLAG(((res ^ d) >> 15)&1, F_OF);
 		} else {
 			CLEAR_FLAG(F_OF);
 		}
@@ -1013,8 +1012,7 @@ uint32_t shld32 (x64emu_t *emu, uint32_t d, uint32_t fill, uint8_t s)
 		res = d;
 	}
 	if (cnt == 1) {
-		CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^
-								(ACCESS_FLAG(F_CF) != 0)), F_OF);
+		CONDITIONAL_SET_FLAG(((res ^ d) >> 31)&1, F_OF);
 	} else {
 		CLEAR_FLAG(F_OF);
 	}
@@ -1039,8 +1037,7 @@ uint64_t shld64 (x64emu_t *emu, uint64_t d, uint64_t fill, uint8_t s)
 		res = d;
 	}
 	if (cnt == 1) {
-		CONDITIONAL_SET_FLAG((((res & 0x8000000000000000L) == 0x8000000000000000L) ^
-								(ACCESS_FLAG(F_CF) != 0)), F_OF);
+		CONDITIONAL_SET_FLAG(((res ^ d) >> 63)&1, F_OF);
 	} else {
 		CLEAR_FLAG(F_OF);
 	}