Item: 768 by jurjen at cwi.nl Author: [Jurjen NE Bos] Subj: Modulo computations on 48SX Keyw: Number theory Date: Tue Sep 18 1990 16:46 Lines: 45 This article is meant for factorization and number theory freaks. I wrote a machine code program that does modulo multiplication for binaries. The program is equivalent to the RPL \<< ROT ROT * SWAP DUP2 / * - \>>, except that the latter program only works if the intermediate product is smaller than 2^64. This machine code version does not have this problem. Usage: enter #a #b #m MULMOD to get (#a*#b) MOD #m All arguments must be binaries. #a must be < #m to make sure that the result is < #m. #b and #m are unrestricted. All arguments are checked, so that you don't have to be afraid for mistakes. You'll get a nice "Too Few Arguments" or "Bad Argument Type" if applicable. Remark: it is only tested on a version D. If you have another version, you're probably safe. To be sure, check out memory location 53F8D. It should contain 174E773DF1C4143 for the program to work. A nice example of the use of MULMOD is the "Random imitator". The random generator uses internally a seed of 15 digits, and can be imitated using the program: \<< #2851130928467d R #1000000000000000 MULMOD DUP 'R' STO B->R 1E15 / \>> Seed the random generator by replacing .xxxxxxxxxxxxEyy RDZ by #xxxxxxxxxxxxyy1 'R' STO You can also produce the reverse of the random sequence replacing the factor 2851130928467 by 953992389123803. Have fun! -- | | "Never imagine yourself not to be otherwise than what | | Jurjen N.E. Bos | it might appear to others that what you were or might | | | have been was not otherwise than what you had been | | jurjen@cwi.nl | would have appeared to them to be otherwise." |