[fpc-pascal] inline assembler procedure

Пётр Косаревский ppkk at mail.ru
Thu Jul 20 15:21:19 CEST 2006

How can I write inline assembler procedure?

(FPC accepts the word "inline", but generates "call" instruction etc.)

If there is a way, could anyone point to an example, please?

Or just remember rotating bits in fpc-devel (if I get it right, they were not implemented):

(it's i386, cyclic bitwise longword l shift to the left by c bits; c may be over 32)

function lrol(l: longword; c: byte): longword; assembler; inline; // this thing is not really inline
   movb  %dl,%cl
   roll  %cl,%eax
   end; // calling register conventions: l->eax, c->dl

(it generates
# Temps allocated between ebp-4 and ebp-4
	# Register ebp allocated
	pushl	%ebp
	movl	%esp,%ebp
	subl	$4,%esp
# Var l located in register
# Var c located in register
# Temp -4,4 allocated
# Var $result located at ebp-4
	# Register eax,ecx,edx allocated
# [97] movb  %dl,%cl
	movb	%dl,%cl
# [98] roll  %cl,%eax
	roll	%cl,%eax
	# Register eax,ecx,edx released
# Temp -4,4 released
	# Register ebp released
	# Register eax released


      (moving variables, which could already be in registers)

where it is expected to be inlined)

More information about the fpc-pascal mailing list