From: notsaying@nospicedham.invalid.org   
      
   "Kerr-Mudd,John" wrote in   
   news:XnsA83A5C873604admin127001@85.214.115.223:   
      
   > aen@nospicedham.spamtrap.com wrote in   
   > news:5a1bc894.38348562@NNTP.AIOE.ORG:   
   >   
   >> 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);   
   >>>...   
   >   
   > We did this a while back; here's my eventual smallest -   
   >   
   > org 0x100 ; FizzBuzz MJ mvY [ 65 ]   
      
   Sorry, that's FizzBuzz, as you may have noticed; but it does perform the   
   counting thing.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|