For IAR and GCC, that has been achieved. My goal is to achieve that for ImageCraft and CVAVR as well.
This one confuses me a bit.
#if __CODEVISIONAVR__ >= 2
#if __CODEVISIONAVR__ >= 2
I haven't used the version number this way, but I think >= 2 will always be true. For example, v. 1.24.3 gives 1243 as the value.
(according to the revision history, 1.24.3 is the version that added the io.h functionality)
You can put lipstick on a pig, but it is still a pig.
I've never met a pig I didn't like, as long as you have some salt and pepper.
With Lee's mention of a work-around for emitting #asm and also my writing of an ISR macro for CVAVR, there are now only two #ifdef's for CVAVR in serial_lcd.c file.
Edit: maybe Lee's work-around for #asm will also work for emitting #pragma which would then eliminate the need for the _Pragma operator. Still, I think there is merit in supporting standards so maybe Pavel will add _Pragma().
Are you talking about #pragma regalloc-/+ ? If so, then you might want to just try unchecking the Automatic Register Allocation in the project options, or edit the .PRJ
and change to 0. I usually use manual, but I think you can change Automatic to 0 and leave Smart at 1 and still get decent results.
[I thought #pragma WAS the way to do things like compiler options.]
[[As time goes on, I find myself using the #pragmas more and more in apps that need to "push the envelope" in some way. For example, I've got a tight timing app that I want "Speed" code generation. But there is a space crunch as well, so I jump into "Size" for non-time-critical sections that have repeated sequences.]]
Thanks for the info, Lee. I had already done that experimentation with automatic register allocation and it is working fine.
#pragma is the intended way to do compiler options. _Pragma() is just a standardized work-around for the inability to emit the sharp character from the C preprocessor.
So now, CVAVR has only one #ifdef and that is about related to inline functions. I don't expect that to get changed at anytime in the near future. So, the CVAVR port of serial_lcd is in great shape. I'm make a new release today or tomorrow.
Thanks for your help with it, Lee!
I'm make a new release today or tomorrow.
Very good, Lee. I'd be glad to see you efforts with the code. Eric spent time working on the code to see if he could make the GCC output smaller to reduce the difference between GCC and the small size of the IAR code -- but he was unable to shrink the GCC output size.
The inline functions are only single bit changes so it reasonable to have them as C macros. OTOH, for IAR and GCC I use inline functions as both a test of those compilers and my compatibility layer to correctly optimize those inline functions.
Lee: I posted version 20080320 -- I'd welcome any improvements that you can make for CV's code size.
A first pass doesn't see much fat. I'll have to examine the impressive IAR results to see where the >10% comes from.
1) CV won't work correctly with your code under Size optimizations, since the repeated watchdog setup work gets turned into subroutines and won't meet the cycle limit. In practice, CV users would surround those sequences with #pragmas as is shown by a Wizard-generated template. Luckily there are so few bytes saved (9 words total) that going for Speed doesn't make a significant difference.
2) There is a typo in "#define BACKLIGHT_OFF() GPIOR1 &=~ ~0x01" that should probably be "#define BACKLIGHT_OFF() GPIOR1 &= ~0x01" ? That saves 4 words.
3) There are no LDS or STS in the whole program, and many registers available for global register variables in CV are unused. [That's why it doesn't make any difference how we set Automatic Register.] In practice if this came up, and ESPECIALLY if ISRs need to be as lean as possible, I'd hoist out to global register variables. This saves 7 words. Same could be said for other local variables; can skinny up those functions a hair.
4) Coding style comment, not really related to the size battle: For any real work, including a serial backpack, you've gotta check the status in the Rx ISR and discard or otherwise handle "bad" characters.
1) CV won't work correctly with your code under Size optimizations, since the repeated watchdog setup work gets turned into subroutines
2) There is a typo in "#define BACKLIGHT_OFF() GPIOR1 &=~ ~0x01"
3) There are no LDS or STS in the whole program, and many registers available for global register variables in CV are unused.
I added a line of code to ignore RX bytes with framing errors.
Lee, it's a good idea to put a stub in their for data overrun to remind users they may wish to handle that error in some way.
I've released a new version on http://www.avrcode.com/serial_lcd/ with your previous suggestions.
© 2020 Microchip Technology Inc.