<!--[if (gte mso 9)|(IE)]><style type="text/css">.main-style-b594c20a87177a930f76 { font-family: sans-serif; font-size: 11pt; /* inherit */ }</style><![endif]--><div style="/* inherit */" class="main-style-b594c20a87177a930f76"><div>After 35 years of Pascal experience I would urgently recommend NOT to trust any automatic type conversion in the case of shift operators. Alteady Turbo Pascal failed here on x386 architectures. Force input and output variables to a certain data type before you use the shift operator. </div><div><br /></div><div>Just my 5 cents </div><div>Markus Greim</div><div><br /></div><div></div><br><div class="front-signature"><font size="+1"><span style="font-size: 13px;">Mit freundlichen Grüßen</span><br /><br /><span style="font-size: 13px;">Markus Greim</span><br /><br /><span style="font-size: 13px;">Schleibinger Geräte</span><br /><span style="font-size: 13px;">Teubert u. Greim GmbH</span><br /><span style="font-size: 13px;">Gewerbestrasse 4</span><br /><span style="font-size: 13px;">84428 Buchbach</span><br /><span style="font-size: 13px;">Germany</span><br /><br /><span style="font-size: 13px;">Tel. +49 8086 94731-10</span><br /><span style="font-size: 13px;">Fax. +49 8086 94731-14</span><br /><span style="font-size: 13px;">Mobil +49 172 8 999 196</span><br /><span style="font-size: 13px;"><a href="http://www.schleibinger.com/" target="_blank" rel="noopener noreferrer">http://www.schleibinger.com</a></span><br /><br /><br /><span style="font-size: 13px;">Amtsgericht Traunstein HRB 9646</span><br /><span style="font-size: 13px;">Geschäftsführer:</span><br /><span style="font-size: 13px;">Dipl.-Ing. (FH) Oliver Teubert</span><br /><span style="font-size: 13px;">Dipl.-Ing. (Univ.) Markus Greim</span><br /><span style="font-size: 13px;">UST-ID. DE 174 175 046</span><br /></font><div><font size="+1"><span style="font-size: 13px;"><br /></span></font></div></div></div><img src="https://app.frontapp.com/api/1/noauth/companies/schleibinger_geraete_gmbh/seen/msg_axzb3uq/han_9pzu6a/cfd218bb.gif" alt="Sent from Front" aria-hidden="true" style="width: 1px; height: 1px"><br><blockquote type="cite" class="front-blockquote">On September 3, 2021 at 2:36 PM GMT+2 <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noopener noreferrer">fpc-pascal@lists.freepascal.org</a> wrote:<br /><br /><div id="fae_axzb3uq-n3fbw7">I made a few tests on Ubuntu 64 bits (arch x86_64) with variations on a small test program:<br />var<br />   E2: Byte= 3;<br />   E1: LongWord= 1;<br />   E: QWord;<br />begin<br />     E:= (1000*E1) shl E2;<br />     writeln( 'E2', E2);<br />     writeln( 'E1', E1);<br />     writeln( 'E', E);<br />end.<br /><br />In the assembly window, shl is computed on 64 bits %rax, I get :<br /><br />project1.lpr:132 E:= (1000*E1) shl E2;<br />00000000004011B2 8b05d8f50c00             mov 0xcf5d8(%rip),%eax        # 0x4d0790 <TC_$P$PROJECT1_$$_E1><br />00000000004011B8 4869c0e8030000           imul $0x3e8,%rax,%rax<br />00000000004011BF 0fb60dbaf50c00           movzbl 0xcf5ba(%rip),%ecx        # 0x4d0780 <TC_$P$PROJECT1_$$_E2><br />00000000004011C6 48d3e0                   shl    %cl,%rax<br />00000000004011C9 48890580b51000           mov %rax,0x10b580(%rip)        # 0x50c750 <U_$P$PROJECT1_$$_E><br /><br />Changing the formula to E:= E1 shl E2, shl computed on 32 bits %edx, (I don't understand the "and    %edx,%edx", may be just to clear the carry ?)<br />I get :<br /><br />project1.lpr:132 E:= E1 shl E2;<br />00000000004011B2 0fb605c7f50c00           movzbl 0xcf5c7(%rip),%eax        # 0x4d0780 <TC_$P$PROJECT1_$$_E2><br />00000000004011B9 8b15d1f50c00             mov 0xcf5d1(%rip),%edx        # 0x4d0790 <TC_$P$PROJECT1_$$_E1><br />00000000004011BF 89c1                     mov    %eax,%ecx<br />00000000004011C1 d3e2                     shl    %cl,%edx<br />00000000004011C3 21d2                     and    %edx,%edx<br />00000000004011C5 48891584b51000           mov %rdx,0x10b584(%rip)        # 0x50c750 <U_$P$PROJECT1_$$_E><br /><br />Changing  E1 to QWord ( E1: QWord= 1; ), shl is computed on 64 bits %rax, I get :<br /><br />project1.lpr:132 E:= E1 shl E2;<br />00000000004011B2 0fb605c7f50c00           movzbl 0xcf5c7(%rip),%eax        # 0x4d0780 <TC_$P$PROJECT1_$$_E2><br />00000000004011B9 488b15d0f50c00           mov 0xcf5d0(%rip),%rdx        # 0x4d0790 <TC_$P$PROJECT1_$$_E1><br />00000000004011C0 4889c1                   mov    %rax,%rcx<br />00000000004011C3 48d3e2                   shl    %cl,%rdx<br />00000000004011C6 48891583b51000           mov %rdx,0x10b583(%rip)        # 0x50c750 <U_$P$PROJECT1_$$_E><br /><br />_______________________________________________<br />fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noopener noreferrer">fpc-pascal@lists.freepascal.org</a><br /><a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" target="_blank" rel="noopener noreferrer">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br /></div></blockquote><img src="https://u8034135.ct.sendgrid.net/wf/open?upn=liJK2x9lrhmoNbCyBS0MpxjIPwWmvAfUM4RgDSjskX7nFcRXYX2fLyQoEx3O9ue95UqCxFIA9QZrrCKGcQQC2kBTdrWioJPlJmwrNkQhl2GGaOk8T5Rox8pMbkXXxQTYwMOFOwG6Nwc-2FqGstqwEqVu-2FkjQ7crJJID7Kg9M6VrsHMdp8q-2BbQ6rSm-2BBAQNBoHNBYe-2BudgjC4XXNFeJqdHbqy9-2BfQhC2Qq5-2FDYw4HCMWwznQfo0DenPzkJdBaG8MoYbLDLuev0V2ZVvGXKavIZEtRNZD1SHGfVSUtVqvWqUuwDsCTdVDVTUP5ohKeDvMDVDqNaI-2FKIEPsZJVNnDoXy3l8KUn9GQ9IPk0BoGlWn-2Byh5NwJGQnCExhSIGe6AsA07BJ8vxT75GCS-2B0aigaM1MJ59MYSLHDUi1bIYwJ9THjBlNSgWYqCYLCXUnIobJbN0a9" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>