[fpc-devel] Bitset assembler
Jy V
jyv110 at gmail.com
Thu Sep 8 11:02:39 CEST 2016
Hello to all assembler experts,
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)
I am using Lazarus 1.6, FPC 3.0.0 SVN revision 51630
x86_64-win64-win32/win64
function BitsetGet(const Bits; Index: UInt32): Boolean; assembler;
asm
{$IFDEF WIN64} // Win64 IN: rcx = Bits, edx = Index OUT: rax = Result
bt (%rcx), %edx // -> Error asm: [bt reg32,mem32]
// bt (%rcx), %rdx // -> Error asm: [bt reg64,mem64]
sbb %eax, %eax
and %eax, $1
{$ELSE} // Linux IN: rdi = Bits, esi = Index OUT: rax = Result
bt (%rdi), %esi
sbb %rax, %rax
and %rax, $1
{$ENDIF}
end;
for reference the x86 DCC code which is working :
function BitsetGet(const Bits; Index: UInt32): Boolean;
asm
bt [eax], edx
sbb eax, eax
and eax, 1
end;
and the x64 DCC code which should be working :
function BitsetGet(const Bits; Index: UInt32): Boolean;
asm
bt [rcx], edx
sbb eax, eax
and eax, 1
end;
--------------------------------------------------------
procedure BitsetSet(var Bits; Index: UInt32); assembler;
asm
{$IFDEF WIN64} // Win64 IN: rcx = Bits, edx = Index OUT: eax = Result
bts (%rcx), %edx // -> Error asm: [bt reg32,mem32]
sbb %eax, %eax
and %eax, $1
{$ELSE} // Linux IN: rdi = Bits, esi = Index OUT: eax = Result
bts (%rdi), %esi
sbb %eax, %eax
and %eax, $1
{$ENDIF}
end;
for reference the x86 DCC code which is working :
procedure BitsetSet(var Bits; Index: UInt32);
asm
bts [eax], edx
end;
and the x64 DCC code which should be working :
function BitsetGet(const Bits; Index: UInt32): Boolean;
asm
bt [rcx], edx
sbb eax, eax
and eax, 1
end;
--------------------------------------------------------
procedure BitsetReset(var Bits; Index: UInt32); assembler;
asm
{$IFDEF WIN64} // Win64 IN: rcx = Bits, edx = Index OUT: eax = Result
btr (%rcx), %edx // -> Error asm: [bt reg32,mem32]
sbb %eax, %eax
and %eax, $1
{$ELSE} // Linux IN: rdi = Bits, esi = Index OUT: eax = Result
btr (%rdi), %esi
sbb %eax, %eax
and %eax, $1
{$ENDIF}
end;
for reference the x86 DCC code which is working :
procedure BitsetReset(var Bits; Index: UInt32);
asm
btr [eax],edx
end;
and the x64 DCC code which should be working :
procedure BitsetReset(var Bits; Index: UInt32);
asm
btr [rcx], edx
sbb eax, eax
and eax, 1
end;
Thank you for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160908/49b3e541/attachment.html>
More information about the fpc-devel
mailing list