(unknown charset) RE: Windows in-line CODE procedure.

From: (unknown charset) Los, Vladimir <"Los,>
Date: Tue, 27 Jun 2000 12:14:04 +0300

if you need sign int mult and div replace these lines
066H, 0F7H, 0E2H, (* mul edx ; edx:eax = eax * edx = a * b *)
066H, 0F7H, 0F1H, (* div ecx ; eax = edx:eax/ecx = (a*b)/m, edx =
edx:eax%ecx = (a*b)%m *)
to
066H, 0F7H, 0EAH, (* mul edx ; edx:eax = eax * edx = a * b *)
066H, 0F7H, 0F9H, (* div ecx ; eax = edx:eax/ecx = (a*b)/m, edx =
edx:eax%ecx = (a*b)%m *)

Good luck!

> -----Original Message-----
> From: robert.d.campbell{([at]})nowhere.xy
> [mailto:robert.d.campbell{([at]})nowhere.xy
> Sent: Tuesday, June 27, 2000 12:22 PM
> To: blackbox{([at]})nowhere.xy
> Subject: Windows in-line CODE procedure.
>
>
>
>
> I have a series of algorithms that depend heavily on the
> following formula
>
> VAR
> a, b, m, x : INTEGER;
> BEGIN
> ...
> x := a * b MOD m;
>
>
> For my applications a and b are non-negative, ie in the range
> [0 ... 2^31 - 1].
> and m is positive, ie in the range [1 ... 2^31 - 1].
>
> The code as written is incorrect as a * b can cause INTEGER overflow.
>
> If I write
>
> x := SHORT (LONG (a) * LONG (b) MOD LONG (m));
>
> it is correct, but I suspect inefficient because the LONGINT * and MOD
> operations are defined over a larger ranger than I need.
>
> The formula can be coded in 2 68020 assembly instructions (eg
> - roughly!)
>
> MULS.L D0, D1:D2 ! D1:D2 <- D0 * D1
> DIVS.L D3, D1:D2 ! D1 <- D1:D2 MOD D3
>
> but I am totally ignorant of the Intel instruction set.
>
>
> Can anyone help me write a procedure with the signature
>
> PROCEDURE [code] ModMult (a, b, m : INTEGER) : INTEGER ?
>
>
> Thanks
>
>
> Robert Campbell
> robert.d.campbell{([at]})nowhere.xy
>
>
>
> --------------------------------------------
>
> To unsubscribe from this mailing list, send a message
> containing the word "unsubscribe" to:
> blackbox-request{([at]})nowhere.xy
>
> To get a list of valid e-mail commands and instructions on
> their usage, send a message containing the word "help" to the
> above address.
>
> Send any problem reports or questions related to this email
> list to the list owner at
> owner-blackbox{([at]})nowhere.xy
>

--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy
Received on Tue Jun 27 2000 - 09:14:04 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:45 UTC