From 0921968934849006f7e0d4d1b93daaed403c9cce Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Thu, 14 Aug 2008 06:21:31 +0000 Subject: [PATCH] From: Atari Ace [mailto:atari_ace@verizon.net] Subject: [patch] Fix i386 bsr implementation Hi mamedev, The i386 cpu emulator will return the wrong result for bsr when the highest bit is set (0 instead of 15 or 31). The attached patch fixes this. ~aa --- src/emu/cpu/i386/i386op16.c | 2 +- src/emu/cpu/i386/i386op32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emu/cpu/i386/i386op16.c b/src/emu/cpu/i386/i386op16.c index 7eb7deffa4a..ecccddf5050 100644 --- a/src/emu/cpu/i386/i386op16.c +++ b/src/emu/cpu/i386/i386op16.c @@ -315,7 +315,7 @@ static void I386OP(bsr_r16_rm16)(void) // Opcode 0x0f bd I.ZF = 1; } else { I.ZF = 0; - temp = 15; + dst = temp = 15; while( (src & (1 << temp)) == 0 ) { temp--; dst = temp; diff --git a/src/emu/cpu/i386/i386op32.c b/src/emu/cpu/i386/i386op32.c index a5eee962959..821401c1f20 100644 --- a/src/emu/cpu/i386/i386op32.c +++ b/src/emu/cpu/i386/i386op32.c @@ -317,7 +317,7 @@ static void I386OP(bsr_r32_rm32)(void) // Opcode 0x0f bd I.ZF = 1; } else { I.ZF = 0; - temp = 31; + dst = temp = 31; while( (src & (1 << temp)) == 0 ) { temp--; dst = temp;