![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
sci.crypt archiveRe: 63/64 bit version of Delphi's function random( aRange : integer ) : integer; ?
From: Skybuck Flying <spam@hotmail.com>
Date: Fri Apr 28 2006 - 08:21:29 CEST
Ok,
I am close to producing a working pure delphi code only version of the
The only problem so far is that one instruction line is producing an integer
So far I don't understand that.
I tried to fix it by simply using another variable but that doesn't seem to
So now I must dig into understanding integer overfow problems related to
However I would like to share the code (routines and test code) up to this
*** Begin of Code ***
program Project1;
{$APPTYPE CONSOLE}
uses
// version 0.01, problem integer overflow.
with vCombinedRegisters do
// EAX is probably initialized with the parameter of the function.
// PUSH EBX
// XOR EBX, EBX
// IMUL EDX,[EBX].RandSeed,08088405H
// INC EDX
// MOV [EBX].RandSeed,EDX
// MUL EDX
// *** problem code, integer overflow ***
// MOV EAX,EDX
// POP EBX
// version 0.02, problem still integer overflow.
with vCombinedRegisters1 do
// EAX is probably initialized with the parameter of the function.
// PUSH EBX
// XOR EBX, EBX
// IMUL EDX,[EBX].RandSeed,08088405H
// INC EDX
// MOV [EBX].RandSeed,EDX
// MUL EDX
// *** problem code, still integer overflow ***
// MOV EAX,EDX
// POP EBX
var
CopyOfRandSeed := 0;
for I := 1 to 10 do
// call to flawed version
// call to still flawed version
end;
writeln( 'press enter to continue' );
*** End of Code ***
How to fix the problem ? :)
Bye,
|