<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re:Pseudocode inconsistency: shift/rotate instructions missing zero-extension on count=0 path in Mobile and Desktop Processors</title>
    <link>https://community.intel.com/t5/Mobile-and-Desktop-Processors/Pseudocode-inconsistency-shift-rotate-instructions-missing-zero/m-p/1741159#M88054</link>
    <description>&lt;P&gt;Hello rui314,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for joining this Community. Your question is regarding our Intel® Developer zone so we will transfer this to our Programs Support Team and they will contact you back via email as soon as possible.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;CM&lt;/P&gt;&lt;P&gt;Intel Customer Support Technician&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 17 Mar 2026 11:14:15 GMT</pubDate>
    <dc:creator>CM_Intel</dc:creator>
    <dc:date>2026-03-17T11:14:15Z</dc:date>
    <item>
      <title>Pseudocode inconsistency: shift/rotate instructions missing zero-extension on count=0 path</title>
      <link>https://community.intel.com/t5/Mobile-and-Desktop-Processors/Pseudocode-inconsistency-shift-rotate-instructions-missing-zero/m-p/1741137#M88052</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'd like to report an inconsistency in the Intel 64 and IA-32 Architectures Software Developer's Manual between the pseudocode for Group 2 shift/rotate instructions and the general zero-extension rule for 32-bit operands in 64-bit mode.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The general rule (Vol. 1, Section 3.4.1.1, "General-Purpose Registers in 64-Bit Mode"):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;"32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the destination general-purpose register."&lt;/P&gt;&lt;P&gt;The pseudocode (SAL/SAR/SHL/SHR, Vol. 2):&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt;IF OperandSize = 64&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; THEN&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; countMASK := 3FH;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; ELSE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; countMASK := 1FH;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;FI&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;tempCOUNT := (COUNT AND countMASK);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;tempDEST := DEST;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;WHILE (tempCOUNT ≠ 0)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;DO&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; IF instruction is SAL or SHL&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CF := MSB(DEST);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ELSE (* Instruction is SAR or SHR *)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CF := LSB(DEST);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; FI;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; IF instruction is SAL or SHL&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DEST := DEST * 2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ELSE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IF instruction is SAR&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DEST := DEST / 2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ELSE (* Instruction is SHR *)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DEST := DEST / 2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FI;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; FI;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; tempCOUNT := tempCOUNT - 1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;OD;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;(* Determine overflow for the various instructions *)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;IF (COUNT and countMASK) = 1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; THEN ...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; ELSE IF (COUNT AND countMASK) = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; THEN&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; All flags unchanged; &amp;lt;--- (A)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ELSE (* COUNT not 1 or 0 *)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OF := undefined;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;&amp;nbsp; &amp;nbsp; FI;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;FI;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;When COUNT=0, the WHILE loop is never entered, so DEST is never assigned. The pseudocode falls through to (A), "All flags unchanged", and returns — treating this as a complete no-op.&lt;/P&gt;&lt;P&gt;The same pattern appears in the rotate pseudocode (ROL/ROR/RCL/RCR), where the WHILE loop is similarly skipped and DEST is never written when the masked count is zero.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;For SHL r/m32, 0 (or any of the other 7 instructions with r/m32 and count=0) in 64-bit mode, the pseudocode implies no write to DEST occurs. A reader following the pseudocode alone would conclude the upper 32 bits of the 64-bit register are preserved. However, Section 3.4.1.1 states that 32-bit results always zero-extend, and real hardware confirms this — the upper 32 bits are zeroed even when the shift count is 0.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hardware test (x86 64-bit mode):&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt;mov rax, 0xFFFFFFFF_00000001 ; upper 32 bits set&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;shl eax, 0 ; count = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;; Result: RAX = 0x00000000_00000001 (upper 32 bits zeroed)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Suggested fix:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Add an explicit write-back of DEST on the count=0 path (e.g., DEST := tempDEST), or add a note clarifying that the 32-bit zero-extension rule from Section 3.4.1.1 still applies regardless of count.&lt;/P&gt;&lt;P&gt;This affects all eight Group 2 instructions: SAL, SAR, SHL, SHR, ROL, ROR, RCL, and RCR.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2026 06:38:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Mobile-and-Desktop-Processors/Pseudocode-inconsistency-shift-rotate-instructions-missing-zero/m-p/1741137#M88052</guid>
      <dc:creator>rui314</dc:creator>
      <dc:date>2026-03-17T06:38:16Z</dc:date>
    </item>
    <item>
      <title>Re:Pseudocode inconsistency: shift/rotate instructions missing zero-extension on count=0 path</title>
      <link>https://community.intel.com/t5/Mobile-and-Desktop-Processors/Pseudocode-inconsistency-shift-rotate-instructions-missing-zero/m-p/1741159#M88054</link>
      <description>&lt;P&gt;Hello rui314,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for joining this Community. Your question is regarding our Intel® Developer zone so we will transfer this to our Programs Support Team and they will contact you back via email as soon as possible.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;CM&lt;/P&gt;&lt;P&gt;Intel Customer Support Technician&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Mar 2026 11:14:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Mobile-and-Desktop-Processors/Pseudocode-inconsistency-shift-rotate-instructions-missing-zero/m-p/1741159#M88054</guid>
      <dc:creator>CM_Intel</dc:creator>
      <dc:date>2026-03-17T11:14:15Z</dc:date>
    </item>
  </channel>
</rss>

