I have problem with code size. When I check the map file it shows LIB CODE size 631h as follows
CODE 0076H 0631H UNIT ?C?LIB_CODE
why LIB CODE size such big? what could be the reason?. FYI: Below are MAP file information for library routine inclusion. I
C:\KEIL\C51\LIB\C51FPC.LIB (?C?FPADD) C:\KEIL\C51\LIB\C51FPC.LIB (?C?FPMUL) C:\KEIL\C51\LIB\C51FPC.LIB (?C?FPDIV) C:\KEIL\C51\LIB\C51FPC.LIB (?C?FPCMP) C:\KEIL\C51\LIB\C51FPC.LIB (?C?FCAST) C:\KEIL\C51\LIB\C51FPC.LIB (?C?CASTF) C:\KEIL\C51\LIB\C51FPC.LIB (?C?FPGETOPN) C:\KEIL\C51\LIB\C51C.LIB (?C_STARTUP) C:\KEIL\C51\LIB\C51C.LIB (?C?COPY) C:\KEIL\C51\LIB\C51C.LIB (?C?CLDPTR) C:\KEIL\C51\LIB\C51C.LIB (?C?CLDOPTR) C:\KEIL\C51\LIB\C51C.LIB (?C?CSTPTR) C:\KEIL\C51\LIB\C51C.LIB (?C?IMUL) C:\KEIL\C51\LIB\C51C.LIB (?C?UIDIV) C:\KEIL\C51\LIB\C51C.LIB (?C?LNEG) C:\KEIL\C51\LIB\C51C.LIB (?C?LLDIDATA) C:\KEIL\C51\LIB\C51C.LIB (?C?LLDIDATA0) C:\KEIL\C51\LIB\C51C.LIB (?C?LSTIDATA) C:\KEIL\C51\LIB\C51C.LIB (?C?CCASE) C:\KEIL\C51\LIB\C51C.LIB (?C?ICASE) C:\KEIL\C51\LIB\C51C.LIB (?C?MEMSET) C:\KEIL\C51\LIB\C51C.LIB (?C_INIT)
Thanks in advance
I need division arithmetic in which the numerator is less than denominator(decimal 255 fixed) example 3/255, in that case what can I do to avoid using floating point variables. Only in 2 places I have instructions like that.
Just to check coding size I change the variable to unsigned long and compiled again and CODE size reduced by almost 1 KB. But as you knew I could not get the correct result out that division arithmetic instructions.
Any further advice? please reply. Thanks
3/255 = 0.0117647.
(3*10) / 255 = 0 (3*100) / 255 = 1 (3*1000) / 255 = 11 (3*10000) / 255 = 117
using unsigned long (3*100000ul) / 255 = 1176 (3*1000000ul) / 255 = 11764 ...
But as you knew I could not get the correct result out that division arithmetic instructions.
Interesting you should say that, since you're using floating-point arithmetics. That won't give you "the correct" result very often, either.
Before you can qualify correctness of a result, you have to decide how this result should be represented. Fixed-point is often preferable over floating-point, particularly on a '51. Fractions may be even better. E.g. the simplest representation in this case would be in units of 1/255.