Article 2359 of rec.games.corewar: Path: hellgate.utah.edu!dog.ee.lbl.gov!agate!howland.reston.ans.net!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!jlayland From: jlayland@kilroy.jpl.nasa.gov (James Layland) Newsgroups: rec.games.corewar Subject: Factor6b Date: 15 Dec 1993 23:09:27 GMT Organization: Jet Propulsion Laboratory, Pasadena, CA USA Lines: 70 Message-ID: <2eo5f7$b6o@elroy.jpl.nasa.gov> NNTP-Posting-Host: 128.149.63.2 Well, my entry was too slow to be the fastest, and much too long to be the shortest. My program divided by 2 and all odd numbers. The time for divisions was cut roughly in half by subtracting 2*F until the last iteration. The division loop was shortened to 3 instructions by accumulating the quotient in the A-field. Unfortunately, each of these modifications added substantially to the code length. The worst case execution time is roughly 29k cycles. In more detail, algorithm is: Current factor is F, current number to factor is N 1) add current factor (1,F) to itself to get (2,2F) 2) move N to scratch location test = (0,N) 3) subtract (2,2F) from test until B-value of test <2F 4) subtract (1,F) from test if necessary to make B-value of test