William \"Chops\" Westfield wrote: > 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! I think we as seeing the same thing from different points of view. The ugly macros and detailed data and control flow once buried into a code generator can do a lot to make the resultant code effective. The second point that may be more important is the need to abstract embedded systems in general. This over time will to improve portability and more important will ultimately reduce application development time. Standards have the effect of focusing tools and in the long term instruct sets. You raised a good point that very few processors support variable accessed pin addresses and only a few support variable pin values. Walter.. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist