Scenario is that, i wanna read 4 bytes of data from a given pointer which is of type char.
Eg: Consider the following -
int a=0;
char* c; // This will have some address
What i wanna do is read 4 bytes starting from c (i.e. the address) and assign them in variable a
which is an integer.
My Solution:
a = *(int*)c; // Assembly is LDR r1, [r6,#0x00]
My Problem:
Above solution works well on some architectures but fails on some.
To be specific, in my case, it fails on Arm CortexM0.
If any one has any portable, highly efficient(with minimum assembly) replacement of my solution please share, it would be a great help to me and I thank you for that in advance ;)
Please ask if more info needed.