[fpc-pascal]Var parameter passing to asm procedure
Ivan Stamenkovic
stameni at EUnet.yu
Thu Aug 5 16:50:27 CEST 2004
Hi,
I have a problem when trying to pass some variable parameters to a
procedure writen using integrated assembler. I have reduced the
problem to the following code:
program IncrementDemo;
{$R+}
{$asmmode intel}
var
a: dword;
procedure increment(var x: dword); assembler;
asm
push ds { Is DS saved by default? }
lds ebx, x
mov eax, [ebx] { Line with the problem }
inc eax
mov [ebx], eax
pop ds
end;
begin
write('Enter a number: ');
readln(a);
increment(a);
writeln('Result is: ', a, '.')
end.
Line with the problem is marked above. If I tried using
mov eax, [bx]
integrated environment would report that 16-bit references are not
supported. With EBX instead of BX program reports run-time error 216.
I have tried using both DOS and Win32 targets. FPC 1.0.10, Win32.
Another Q: Is it necessary to save the segment registers' contents
when entering an assembler procedure?
Thanks,
Ivan
More information about the fpc-pascal
mailing list