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,096 of 4,675   
   aen@nospicedham.spamtrap.com to terje.mathisen@nospicedham.tmsw.no   
   Re: Easy message box   
   27 Nov 17 08:15:15   
   
   On Mon, 27 Nov 2017 08:11:37 +0100, Terje Mathisen   
    wrote:   
   >...   
   >I have to side with Rick here, simply because using C makes the actual   
   >algorithm easier to visualize, and that is the interesting part here, imho.   
   >...   
   The other reason I use assembly is because it fits the way I'm   
   thinking.  The code below is for me much harder to visualize!   
   >...   
   >I.e. instead of trying to divide by 3 or 5, I would use a pair of   
   >counters initialized to 2 and 4:   
   >   
   >   int cnt3 = 2, cnt5 = 4, num = 0, sum = 0;   
   >   do {   
   >     cnt3--; cnt5--; num++;   
   >     int mask3 = cnt3 >> 31; // Will be -1 after 3 loops   
   >     int mask5 = cnt5 >> 31; // Will be -1 after 5 loops   
   >     cnt3 += mask3 & 3;	    // Return to 2 if it wrapped around   
   >     cnt5 += mask5 & 5;      // Return to 4 if it wrapped around   
   >   
   >     sum += num & (mask3 | mask5); // Add the current num if divisible   
   >   } while (num < 1000);   
   >...   
   --   
   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