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,244 of 4,675   
   aen@nospicedham.spamtrap.com to Steve   
   Re: Backward LCG   
   19 Jan 18 15:01:09   
   
   On Fri, 19 Jan 2018 12:55:48 GMT, Bogus@Embarq.com (Steve) wrote:   
   >...   
   >   A link or an explaintion of how to determine what the multiplicative   
   >inverse is would be nice to see.   
   >..   
   The code below is the main subroutine of that program.  The Algorithm   
   is from TAOCP.   
      
   input:  EAX = number   
   output: EBX = multiplicative inverse   
      
   minv:   
      mov  ebx,eax   
      xor  eax,eax   
      mov  edx,1   
      mov  esi,eax   
   E1:mov  edi,1   
      xor  ebp,ebp   
      jmp  _2   
   E2:xor  edx,edx   
   _2:div  ebx   
      mov  ecx,eax   
   E3:test edx,edx   
      jnz  E4   
      mov  eax,ebx   
      mov  ebx,edi   
      test ebx,ebx   
      jns  .1   
      add  ebx,esi   
   .1:ret	   
   E4:mov  eax,ebx   
      mov  ebx,edx   
      mov  [temp],ebp   
      mov  ebp,edi   
      mov  edx,ecx   
      imul edx,edi   
      mov  edi,[temp]   
      sub  edi,edx   
      jmp  E2   
   --   
   aen   
      
   --- 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