home bbs files messages ]

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,168 of 4,675   
   wolfgang kern to aen@nospicedham.spamtrap.com   
   Re: Palindromic number   
   08 Dec 17 14:26:43   
   
   From: nowhere@never.at   
      
    wrote:   
      
   ...   
   > What I actually wanted to test is which is the highest value in the   
   > range 1-2^64-1 that produces a wrong result with that reciprocal, and   
   > that palindrome was really the worst example.   
      
   > With the 32-bit version of the reciprocal it was easy to find that   
   > value.  I just used a loop with an increasing value to do a   
   > conventional division and a reciproal mul, and left it when the first   
   > mul wasn't the same as the div.   
      
   you found a max.value ?  OK, me once too!   
      
   here is a copy of what I tried for 32 bit after Terje showed me the   
   error with my 0x1999999A reciprocal some years ago.   
   (haven't checked if this can be modified for 64 bit):   
      
   BIN2DEC:   
   .ALIGN 64   
     mov eax,0xffffffff   ;max. num test /others tested as well   
     mov ebx,0xcccccccd   ;2^35/10   
     mov edi,BUFFER+10    ;point to end because stored backwards   
     mov [edi],byte 0     ;Z-terminator   
   .ALIGN 4   
   L1:   
     mov ecx,eax          ;copy initial value or last quotient   
     mul ebx              ;divide   
     dec edi              ;goes backward   
     shr edx,3            ;-> 2^32   
     lea esi,[edx+edx*8]  ; *9  (SUB ecx,edx*10)   
     sub ecx,edx          ;-*1   
     sub ecx,esi          ;-*9   
     mov eax,edx          ;prepare for next   
     or  ecx,+30h         ;   
     test edx,edx         ;only until nothing more   
     mov [edi],cl         ;   
    jnz L1                ;   
    ret                   ;edi points to first character (MSD) yet   
   .ALIGN 64              ;must be at least one cache line away from code   
   BUFFER: dup 11 ?       ;ASCII-Z num w/o leading Zeros   
   -----------   
   and with this test I see: 4294967295   
   I posted a similar copy to CLAX (Nov.07.2015)   
   tested with KESYS004debug (after cached: 4..7 cycles/result digit)   
   __   
   wolfgang   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca