Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,154 of 4,675    |
|    Terje Mathisen to aen@nospicedham.spamtrap.com    |
|    Re: Palindromic number    |
|    06 Dec 17 16:23:16    |
      From: terje.mathisen@nospicedham.tmsw.no              aen@nospicedham.spamtrap.com wrote:       > Hi!       >       > Have I got this right from Agner Fog's Optimizing subroutines in       > assembly language, pp 148-149? Especially do I assume the maximum       > number correct?              It looks like you want both the decimal number and the check for it       being a palindrome, right?              Otherwise, if you justneed the test for palindromicity, and most inputs       will not be so, then you want a faster test, right?              Start by using the number of set bits to estimate how many digits you       will have, then extract the bottom and top digits with reciprocal muls       (using lookup table reciprocals) and compare them.              If you need both returns then the best you can do is to use a 64-bit       version of the algorithm I first posted maybe 20 (?) years ago which       splits the number into two parts, scales them into n.nnnnnn format and       then extract the digits in parallel starting from the top and using LEA       to multiply by 5 between each digit.              For 32-bit unsigned that algorithm uses about 30 cycles on a 10+ year       old cpu, the 64-bit version, with 3 or 4-way split, should do it in less       than twice that time.              Terje                     --       - |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca