Hi All,<div><br></div><div> anyone know the x86/IA32 really well? If so, read on. Otherwise save yourself the yawn.</div><div><br></div><div>I just tried to save an instruction in Cog;s generated bitShift: primitive. It seems to me that SARL (shift arithmetic right long) should set the sign flag based on the result, in fact it says as much in the manual; I quote fro<span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;">m </span></span><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;">IA-32 Intel® Architecture</span></span><span style="font: 12.0px Helvetica"><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"> </span></span><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;">Software Developer'</span></span><span style="font: 18.0px Times"><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;">s Manual Volume 2B: Instruction Set Reference, N-Z p 4-192</span></span></span></span></div>
<div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Helvetica"><span class="Apple-style-span" style="font-size: small;">Flags Affected</span><span style="font: 12.0px Helvetica"><span class="Apple-style-span" style="font-size: small;"> </span></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><span class="Apple-style-span" style="font-size: small;">The CF flag contains the value of the last bit shifted out of the destination operand; it is unde- </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><span class="Apple-style-span" style="font-size: small;">fined for SHL and SHR instructions where the count is greater than or equal to the size (in bits) </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><span class="Apple-style-span" style="font-size: small;">of the destination operand. The OF flag is affected only for 1-bit shifts (see "Description"</span><span style="font: 12.0px Helvetica"><span class="Apple-style-span" style="font-size: small;"> </span></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><span class="Apple-style-span" style="font-size: small;">above); otherwise, it is undefined. <span class="Apple-style-span" style="font-weight: bold;">The SF, ZF, and PF flags are set according to the result.</span> If the </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><span class="Apple-style-span" style="font-size: small;">count is 0, the flags are not affected. For a non-zero count, the AF flag is undefined.</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times">
<span class="Apple-style-span" style="font-size: 13px;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;"><br></span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times">
<span class="Apple-style-span" style="font-size: 13px;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif;">(my emphasis added). But neither the Bochs simulator nor my Intel Core Duo set the flags when doing sarl $1, %eax when %eax contains -1. Have I misread, or is the manual wrong?</span></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><br></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><span class="Apple-style-span" style="font-family: arial; font-size: 13px;">TIA</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times"><span class="Apple-style-span" style="font-family: arial; font-size: 13px;">Eliot</span></p></div>