Nested assembly functions return improper results (Delphi mode)
Original Reporter info from Mantis: ChrisF
-
Reporter name:
Original Reporter info from Mantis: ChrisF
- Reporter name:
Description:
In Delphi compatible mode, nested assembly functions are returning wrong results.
Nested assembly functions = Functions with only an asm/end block (so, without the usual begin/end block), and defined only inside others procedures/functions (local scope).
Steps to reproduce:
Hereafter, a very basic test (equivalent to the ROLDWord FPC function):
-Start a new Lazarus/FPC project:
-Set it in Delphi mode (i.e. {$mode delphi})
-Add these 2 basic functions:
function MyROL_OK(Const ValToROL: Longword; Const Times: Byte): Longword;
asm
mov CL , Times
rol ValToROL , CL
end;
function DoesntWork(Const Value: Longword; Const Times: Byte): Longword;
function MyROL_KO(Const ValToROL: Longword; Const Times: Byte): Longword;
asm
mov CL , Times
rol ValToROL , CL
end;
begin
Result:=MyROL_KO(Value,Times);
end;
-Test the results returned by these 2 functions for the same input values. Results from function MyROL_OK are always OK, but results from function DoesntWork (function MyROL_KO, in fact) are always false. The last ones seem to be constant for a given compilation (i.e. returning a pointer value instead ?).
For instance:
MyROL_OK(1,4) = 16 =====> Correct result
DoesntWork(1,4) = 22737756 =====> Wrong result
The same code with Delphi gives always correct results in both cases.
Mantis conversion info:
- Mantis ID: 24061
- OS: Windows
- OS Build: XP
- Platform: win32
- Version: 2.6.2