best size for integer maths

Posted:
Wed Feb 12, 2014 10:01 am
by richardb
on some of the windows compilers I've used it is generally recommended that you use native integer sizes as smaller sizes can be lower Performance.
What's the case with firewing ignoring any ram usage issues.
Is it faster doing 8 bit calculations with 32bit vars? or no difference? is the code size any different?
Richard
Re: best size for integer maths

Posted:
Wed Feb 12, 2014 10:33 am
by David John Barker
The underlying core of 16 and 32 bit Microchip devices are very different (32 being a MIPS core) . However, sticking to native sizes will do no harm - a 16 bit MCU will have good support for 16 bit integer maths and a 32 bit MCU will have good support for 32 bit integer. It's impossible to say if code will be larger or smaller, it depends on what you are doing. 16 and 32 bit variables must be word aligned on 16 bit devices and 16 and 32 bit variables must be long word aligned on 32 bit devices so you will see differences in RAM usage but obviously they are aligned for optimal access for any given core. Personally, I don't really thing about it to much - I tend to use the variable I feel the program needs, rather than the core. I suspect you wouldn't really see much difference when using 8 or 16 bit variables on 32 core devices, but I'm no MIPS expert...