boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

00143.c (970B)


      1 /* Disgusting, no?  But it compiles and runs just fine.  I feel a combination of
      2    pride and revulsion at this discovery.  If no one's thought of it before,
      3    I think I'll name it after myself.
      4    It amazes me that after 10 years of writing C there are still
      5    little corners that I haven't explored fully.
      6    - Tom Duff */
      7 
      8 int main()
      9 {
     10     int  count, n;
     11     short *from, *to;
     12     short a[39], b[39];
     13 
     14     for(n = 0; n < 39; n++) {
     15         a[n] = n;
     16         b[n] = 0;
     17     }
     18     from = a;
     19     to = b;
     20     count = 39;
     21     n = (count + 7) / 8;
     22     switch (count % 8) {
     23     case 0: do { *to++ = *from++;
     24     case 7:      *to++ = *from++;
     25     case 6:      *to++ = *from++;
     26     case 5:      *to++ = *from++;
     27     case 4:      *to++ = *from++;
     28     case 3:      *to++ = *from++;
     29     case 2:      *to++ = *from++;
     30     case 1:      *to++ = *from++;
     31             } while (--n > 0);
     32     }
     33     for(n = 0; n < 39; n++)
     34         if(a[n] != b[n])
     35             return 1;
     36     return 0;
     37 }