<div dir="ltr"><div><div><div>Hello to all assembler experts,<br><br></div>I would greatly appreciate if some people could help me prepare some asm code for FreePascal for Win32, Win64, Linux x86, Linux x64 (and maybe some ARM32bit + AARCH64)<br></div><div>I am using Lazarus 1.6, FPC 3.0.0 SVN revision 51630 x86_64-win64-win32/win64<br></div><div><br>function BitsetGet(const Bits; Index: UInt32): Boolean; assembler;<br>asm<br>    {$IFDEF WIN64} // Win64 IN: rcx = Bits, edx = Index  OUT: rax = Result<br>      bt (%rcx), %edx // -> Error asm: [bt reg32,mem32]<br>//      bt (%rcx), %rdx // -> Error asm: [bt reg64,mem64]<br>      sbb %eax, %eax<br>      and %eax, $1<br>    {$ELSE} // Linux IN: rdi = Bits, esi = Index  OUT: rax = Result<br>      bt (%rdi), %esi<br>      sbb %rax, %rax<br>      and %rax, $1<br>    {$ENDIF}<br>end;<br><br></div>for reference the x86 DCC code which is working :<br><br>function BitsetGet(const Bits; Index: UInt32): Boolean;<br>asm<br>  bt [eax], edx<br>  sbb eax, eax<br>  and eax, 1<br>end;<br><br>and the x64 DCC code which should be working :<br><br>function BitsetGet(const Bits; Index: UInt32): Boolean;<br>asm<br>      bt [rcx], edx<br>      sbb eax, eax<br>      and eax, 1<br>end;<br><br>--------------------------------------------------------<br>procedure BitsetSet(var Bits; Index: UInt32); assembler;<br>asm<br>    {$IFDEF WIN64} // Win64 IN: rcx = Bits, edx = Index  OUT: eax = Result<br>      bts (%rcx), %edx // -> Error asm: [bt reg32,mem32]<br>      sbb %eax, %eax<br>      and %eax, $1<br>    {$ELSE} // Linux IN: rdi = Bits, esi = Index  OUT: eax = Result<br>      bts (%rdi), %esi<br>      sbb %eax, %eax<br>      and %eax, $1<br>    {$ENDIF}<br>end;<br><br></div>for reference the x86 DCC code which is working :<br><br>procedure BitsetSet(var Bits; Index: UInt32);<br>asm<br>  bts [eax], edx<br>end;<br><br><div>and the x64 DCC code which should be working :<br><br>function BitsetGet(const Bits; Index: UInt32): Boolean;<br>asm<br>      bt [rcx], edx<br>      sbb eax, eax<br>      and eax, 1<br>end;<br><br><br>--------------------------------------------------------<br>procedure BitsetReset(var Bits; Index: UInt32); assembler;<br>asm<br>    {$IFDEF WIN64} // Win64 IN: rcx = Bits, edx = Index  OUT: eax = Result<br>      btr (%rcx), %edx // -> Error asm: [bt reg32,mem32]<br>      sbb %eax, %eax<br>      and %eax, $1<br>    {$ELSE} // Linux IN: rdi = Bits, esi = Index  OUT: eax = Result<br>      btr (%rdi), %esi<br>      sbb %eax, %eax<br>      and %eax, $1<br>    {$ENDIF}<br>end;<br><br>for reference the x86 DCC code which is working :<br><br>procedure BitsetReset(var Bits; Index: UInt32);<br>asm<br>  btr [eax],edx<br>end;<br><br>and the x64 DCC code which should be working :<br><br>procedure BitsetReset(var Bits; Index: UInt32);<br>asm<br>      btr [rcx], edx<br>      sbb eax, eax<br>      and eax, 1<br>end;<br><br></div><div>Thank you for any help.<br></div><div><br></div><div><br></div><div><br><br></div></div>