Electronics Circuits & Tutorials - Electronics Hobby Projects - A Complete Electronic Resource Centre
Electronics Circuits & Tutorials

Home About us Electronic Tutorials Engineering Hobby Projects Online Dictionaries Contact us
Tutorials
  • Basic/Beginners
  • Intermediate/Advance
  • Microcontrollers
  • Microprocessors
  • Electronics Symbols
  • Electronics Formulas
  • Dictionary of Units

     more....

Dictionaries
  • Electronics Terms
  • Abbreviations
  • Computer Terms
  • Physics Glossary
  • Science Glossary
  • Space & Solar Terms
  • Semiconductor Symbols / Abbreviation
  • Radio Terminology Bibliography

     more....

Projects
  • Engineering Projects
Home > Electronics Tutorials > Online Computer Terms Dictionary > D

Online Computer Terms Dictionary - D

Duff's device

The most dramatic use yet seen of fall through in C, invented by Tom Duff when he was at Lucasfilm. Trying to bum all the instructions he could out of an inner loop that copied data serially onto an output port, he decided to unroll it. He then realised that the unrolled version could be implemented by *interlacing* the structures of a switch and a loop:

  register n = (count + 7) / 8;      /* count > 0 assumed */

  switch (count % 8)
  {
  case 0:        do {  *to = *from++;
  case 7:              *to = *from++;
  case 6:              *to = *from++;
  case 5:              *to = *from++;
  case 4:              *to = *from++;
  case 3:              *to = *from++;
  case 2:              *to = *from++;
  case 1:              *to = *from++;
                     } while (--n > 0);
  }

Shocking though it appears to all who encounter it for the first time, the device is actually perfectly valid, legal C. C's default fall through in case statements has long been its most controversial single feature; Duff observed that "This code forms some sort of argument in that debate, but I'm not sure whether it's for or against."

[For maximal obscurity, the outermost pair of braces above could be actually be removed - GLS]

[Jargon File]

(2001-06-22)

 


Nearby terms: Dual Tone Multi Frequency « duck typing « DUEL « Duff's device » dumbed down » dumb terminal » dump
 

Discover
  • C/C++ Language Programming Library
  • Electronic Conversions
  • History of Electronics
  • History of Computers
  • Elec. Power Standards
  • Online Calculator and Conversions
  • Electrical Hazards - Health & Safety
  • Datasheets
  • Quick Reference links
  • Electronics Magazines
  • Career in Electronics
  • EMS Post Tracking

     more......

Home Electronic Tutorials Engineering Hobby Projects Resources Links Sitemap Disclaimer/T&C

Copyright © 1999-2020 www.hobbyprojects.com  (All rights reserved)