{"id":575,"date":"2005-10-08T17:24:22","date_gmt":"2005-10-08T17:24:22","guid":{"rendered":"http:\/\/fatsquirrel.org\/bologs\/vng\/duff\/"},"modified":"2005-10-08T17:24:22","modified_gmt":"2005-10-08T17:24:22","slug":"duff","status":"publish","type":"post","link":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/duff\/","title":{"rendered":"Duff"},"content":{"rendered":"<p>Skip this unless you&#8217;re a C programmer with a strong stomach&#8230;<br \/>\nI&#8217;m sure that the seasoned hackers and computer scientists amongst you will probably already have encountered <a href=\"http:\/\/fringe.davesource.com\/Fringe\/Computers\/Languages\/C\/Duffs-Device.html\" target=\"_new\">Duff&#8217;s Device<\/a>, but it was only after rambling along some overgrown link-paths from a slashdot article that I discovered it. In a nutshell, this is it:<\/p>\n<pre>\nsend(to, from, count)\n\tregister short *to, *from;\n\tregister count;\n\t{\n\t\tregister n=(count+7)\/8;\n\t\tswitch(count%8){\n\t\tcase 0:\tdo{\t*to = *from++;\n\t\tcase 7:\t\t*to = *from++;\n\t\tcase 6:\t\t*to = *from++;\n\t\tcase 5:\t\t*to = *from++;\n\t\tcase 4:\t\t*to = *from++;\n\t\tcase 3:\t\t*to = *from++;\n\t\tcase 2:\t\t*to = *from++;\n\t\tcase 1:\t\t*to = *from++;\n\t\t\t} while(--n>0);\n\t\t}\n\t}\n<\/pre>\n<p>As the man himself said, &#8220;Disgusting, no ?&#8221;. It&#8217;s just so, so, sick and weird, and yet so beautiful. It&#8217;s like one of those sculptures or pictures that your brain just can&#8217;t cope with; one that forces you to either run screaming or just stand there tilting your head and squinting.<br \/>\nIt wasn&#8217;t until I&#8217;d compiled it and filled it with printf&#8217;s that it started to make sense but I&#8217;m still feeling slightly dirty&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Skip this unless you&#8217;re a C programmer with a strong stomach&#8230; I&#8217;m sure that the seasoned hackers and computer scientists amongst you will probably already have encountered Duff&#8217;s Device, but it was only after rambling along some overgrown link-paths from a slashdot article that I discovered it. In a nutshell, this is it: send(to, from, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-575","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/posts\/575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/comments?post=575"}],"version-history":[{"count":0,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/posts\/575\/revisions"}],"wp:attachment":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/media?parent=575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/categories?post=575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/tags?post=575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}