I am relatively new to embedded systems, so please forgive me if this is a stupid question.
I am currently programming an 8 bit microcontroller, model MC9S08JM60, and I just want to know how 32 bit numbers are handled on an 8 bit microcontroller.
On this processor UINT32 is a typedef of unsigned long...which is 32 bit.
How is a 32 bit integer stored in memory?
My assumption is that is is stored as follows:
ADDR DATA(8 bits wide)
Can I do bitshifts such as:
UINT8 var1 = 5;
UINT32 var2 = 0;
var2 = (UINT32)(var1 << 18); //and any other arithmetic on UINT32's as long as it does not overflow beyond 32 bits?
I am creating a simple protocol over USB and I need to be able to send in 32 bit values(for large delays etc...)
The 32 bit value is recieved into a 64 bit buffer which I have access to as a char array.
Can I simply cast the value to a UINT32 by doing the following(assume Buffer contains the most significant byte of the integer value):
UINT32 var = *((UINT32*)&Buffer)