Multiplication by int64 const truncated
Original Reporter info from Mantis: km
-
Reporter name: Kieran
Original Reporter info from Mantis: km
- Reporter name: Kieran
Description:
When multiplying a variable by a 64-bit constant, the value encoded in the imul instruction is truncated; resulting in an incorrect result.
Steps to reproduce:
sample program:
program MulTest;
const
C1 = 86400000000; //MCS in a day
var
AInput,
Product : Int64;
begin
AInput := 1;
//asm int3 end; //debug trap; `disassemble`
Product := AInput * C1;
WriteLn(AInput, ' * ', C1, ' = ', Product);
end.
Additional information:
A previous stable build (2.6.2) produced the following output for comparison:
0x00000000004001fe <+30>: mov 0x65a4f0,%rdx
0x0000000000400206 <+38>: movabs $0x141dd76000,%rax
0x0000000000400210 <+48>: imul %rax,%rdx
0x0000000000400214 <+52>: mov %rdx,0x65a4f8
Whereas 2.7.1 produces:
0x000000000040021f <+31>: movabs 0x6678f0,%rax
0x0000000000400229 <+41>: imul $0x1dd76000,%rax,%rax
0x0000000000400230 <+48>: movabs %rax,0x667900
Note that GNU assembler throws an error on the imul instruction.
Mantis conversion info:
- Mantis ID: 26230
- OS: Linux
- Build: trunk 27818
- Platform: x86-64
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 27822 (#daf71e6d)
- Target version: 2.7.1