On Wed, 1 Mar 2006, Wouter van Ooijen wrote: >>> But how else would you write a bit-banged UART in a HLL without >>> using timers? >> >> Inline assembly ... C can do it. > > In-line assembly is a way to combine HLL and assembly that is often more > convenient than using separate C and asm files. But it is not HLL. If > you disagree I'll rephrase: how do you do it in a portable way (one > source for PIC and an as-yet-undifined chip, but one that is supported > by the HLL)? // setup (can include setup file) // define ONE #define PIC_IMPLEMENTATION_A // #define PIC_IMPLEMENTATION_B // ****** Implementation start // Function foo() does something void foo(void) { unsigned char a, b = 2, c = 3; // ****** PIC IMPLEMENTATION #ifdef __PIC # ifdef PIC_IMPLEMENTATION_A # define _SECTION_FOO_SEEN --c; // C _asm movf _b addwf _c,w movwf a _endasm; # endif # ifdef PIC_IMPLEMENTATION_B # define _SECTION_FOO_SEEN _asm movf _c addwf _b,w movwf a _endasm; # endif #endif // ****** MCS51 implementation #ifdef _MCS51 #define _SECTION_FOO_SEEN ++b; // C _asm mov A, _c add _b mov _a, A _endasm; #endif // ****** PORTABLE C IMPLEMENTATION #ifdef _POSIX #define _SECTION_FOO_SEEN a = b * c; // pure C #endif } // foo() ... #ifndef _SECTION_FOO_SEEN # error "Could not compile foo (_SECTION_FOO_SEEN undefined)" #endif Peter -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist