From: Erik W. <om...@te...> - 2002-08-12 02:44:40
|
Now that a few things are more settled in both my mind and SDCC, I'm going to try to write as much of my 'OS' as possible in C. That means I'll be sending more reports and questions ;-) 1) How can I set the base offset of a function? I.e. with the serial bootloader I'm using, 0x0003 has to be a goto to the main() routine, and of course 0x0004 has to be the interrupt handler. 2) When setting up the serial port, it seems the best thing to do is flush the Rx buffers with MOVF RCREG,W three times in a row. This has been the most problematic of all the stuff I've tried: a) If I write it in C, it gets *completely* optimized out. b) If I write it in inline asm, the peephole optimizer removes 2 of the 3 c) If I write it in inline asm, RCREG becomes horribly confused: _TXREG EQU 0x0019 _RCREG EQU 0x001a _CCPR2L EQU 0x001b . . . cblock 0X0020 ; Bank 0 r0x53 RCREG endc . . . _PORTC EQU 0x007 RCREG EQU 0x021 _TXREG EQU 0x019 . . . ;; peep 4 - Removed redundant move ;; peep 4 - Removed redundant move MOVF RCREG,W It seems to me that possibly both a #pragma optimize-off, #pragma optimize-on pair is needed, and _asm statements should be flagged implicitely as *not* fodder for the peephole optimizer. With chips like this, there are many cases where carefully-crafted delay loops or other insanities are necessary, it could get real annoying to have the C compiler repeatedly optimize them out... ;-) 3) Something that got fixed recently was the loop: while (TXIF == 1) ; It used to result in about 6 or 7 instructions with a couple registers used and so on. Now it's the expected BTFSC,GOTO pair ;-) However, it does use a temporary register for some reason: MOVWF r0x53 _00105_DS_ BTFSC (_TXIF >> 3), (_TXIF & 7) GOTO _00105_DS_ MOVF r0x53,w MOVWF _TXREG RETURN AFAIK BTFSC doesn't muck with W, so there's no need to save it. Erik Walthinsen <om...@te...> - System Administrator __ / \ GStreamer - The only way to stream! | | M E G A ***** http://gstreamer.net/ ***** _\ /_ |