Optimization on constant value (or typical value)

Post your requests and ideas on the future development of mikroC PRO for PIC.
Post Reply
Author
Message
tycoeur
Posts: 1
Joined: 21 Mar 2011 23:07

Optimization on constant value (or typical value)

#1 Post by tycoeur » 07 Apr 2011 19:36

I'm working on small device (something like 12F683) with software UART:

If I check the library example:
Soft_UART_Init(&PORTC, 7, 6, 14400, 0);

I don't understand why Soft_UART_Init needs:
* Get_Fosc_kHz (8 bytes)
* Mul_32x32_U (55 bytes)
* Div_32x32_S (180 bytes) :?
* SDIV3232L (300 bytes) :shock:
* COMFREM (12 bytes)

Why? Because 14400 is a constante like FOSC!
MUL, DIV... can be resolved at compilation time!
You know: memory is precious in small sized device.


Maybe some #define can be used for some well know case like:
#define Soft_UART_Init_14400_8MHz(port, rx, tx, inverted)
or simply:
#define Soft_UART_Init_14400(port, rx, tx, inverted)
and one for 9600, 56000... (all generally used bauds).

Or a better solution: follow constant/literal value and evaluate it at compilation time!! :D

The same optimization/problem happens in other library.

Post Reply

Return to “mikroC PRO for PIC Wish List”