From f97b4bb8001f1e15031438cb8b562ec7f701a9a9 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Thu, 31 Jul 2003 16:05:16 +0000 Subject: [PATCH] BSR and BSF correctly set zero flag now and 0 source for scan Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1176 --- src/cpu/core_full/op.h | 68 +++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 8243fdaf..99d90f3e 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -479,53 +479,65 @@ switch (inst.code.op) { case O_BSFw: { FILLFLAGS; - if (!inst.op1.w) SETFLAGBIT(ZF,true); - Bitu count=0; - while (count<16) { - if ((inst.op1.w>>count) & 1) break; - count++; + if (!inst.op1.w) { + SETFLAGBIT(ZF,true); + } else { + Bitu count=0; + while (count<16) { + if ((inst.op1.w>>count) & 1) break; + count++; + } + inst.op1.d=count; + SETFLAGBIT(ZF,false); } - inst.op1.d=count; - SETFLAGBIT(ZF,false); } break; case O_BSFd: { FILLFLAGS; - if (!inst.op1.d) SETFLAGBIT(ZF,true); - Bitu count=0; - while (count<32) { - if ((inst.op1.d>>count) & 1) break; - count++; + if (!inst.op1.d) { + SETFLAGBIT(ZF,true); + } else { + Bitu count=0; + while (count<32) { + if ((inst.op1.d>>count) & 1) break; + count++; + } + inst.op1.d=count; + SETFLAGBIT(ZF,false); } - inst.op1.d=count; - SETFLAGBIT(ZF,false); } break; case O_BSRw: { FILLFLAGS; - if (!inst.op1.w) SETFLAGBIT(ZF,true); - Bits count=15; - while (count>0) { - if ((inst.op1.w>>count) & 1) break; - count--; + if (!inst.op1.w) { + SETFLAGBIT(ZF,true); + } else { + Bits count=15; + while (count>0) { + if ((inst.op1.w>>count) & 1) break; + count--; + } + inst.op1.d=count; + SETFLAGBIT(ZF,false); } - inst.op1.d=count; - SETFLAGBIT(ZF,false); } break; case O_BSRd: { FILLFLAGS; - if (!inst.op1.d) SETFLAGBIT(ZF,true); - Bits count=31; - while (count>0) { - if ((inst.op1.d>>count) & 1) break; - count--; + if (!inst.op1.d) { + SETFLAGBIT(ZF,true); + } else { + Bits count=31; + while (count>0) { + if ((inst.op1.d>>count) & 1) break; + count--; + } + inst.op1.d=count; + SETFLAGBIT(ZF,false); } - inst.op1.d=count; - SETFLAGBIT(ZF,false); } break; case O_BTw: