[fpc-pascal] IFDEF usage in x86_64's SwapEndian() implementation

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Wed Mar 30 13:15:29 CEST 2016


On 2016-03-30 11:58, Michael Van Canneyt wrote:
> The code is there to differentiate between the windows ABI and other ABIS,
> which specify in what register the AValue parameter is passed.

Ah okay. One could possibly write it in a less ambiguous way, as
follows? No IFDEF's needed.

function SwapEndian(const AValue: DWord): DWord; assembler; nostackframe;
asm
  movl AValue, %eax
  bswap %eax
end;


The generated assembler seems to be identical to the original code (at
least on my FreeBSD system).

.Lc1:
# Var AValue located in register edi
# Var $result located in register eax
# [project1.lpr]
# [10] asm
# [11] movl AValue, %eax
	movl	%edi,%eax
# [12] bswap %eax
	bswapl	%eax
# [13] end;
	ret
.Lc2:


Regards,
  - Graeme -




More information about the fpc-pascal mailing list