On Mar 27, 2010, at 9:29 AM, Walter Banks wrote: >> >> It's also pretty expensive (20 to 50 times slower than >> direct manipulation of constant register bits > > Arduino would optimize quite well for well written compilers > and still keep the abstractions that would make applications > portable. It's not a compiler inefficiency, but one of the model used. Both "pin number" and "value" are variables, which pretty much prevents the use of the nice bit set instructions, or even the IO register instructions. Instead you have to do an explicit index- register-based read of mapped pin-to-address, modify the mapped pin-to- mask as appropriate for the desired value, and write the value back... I doubt that it would be much smaller than 20 instructions in hand-written assembler, on AVR or PIC. Someone did write a macro that detects the use of constants and uses more direct code. One of the ugliest macros I've ever seen! BillW -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist