Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does 8-bit processor have to face endianness problem?

Tags:

c

8051

If I have a int32 type integer in the 8-bit processor's memory, say, 8051, how could I identify the endianess of that integer? Is it compiler specific? I think this is important when sending multybyte data through serial lines etc.

like image 558
Grissiom Avatar asked Nov 30 '22 18:11

Grissiom


2 Answers

With an 8 bit microcontroller that has no native support for wider integers, the endianness of integers stored in memory is indeed up to the compiler writer.

The SDCC compiler, which is widely used on 8051, stores integers in little-endian format (the user guide for that compiler claims that it is more efficient on that architecture, due to the presence of an instruction for incrementing a data pointer but not one for decrementing).

like image 83
caf Avatar answered Jan 29 '23 12:01

caf


If the processor has any operations that act on multi-byte values, or has an multi-byte registers, it has the possibility to have an endian-ness.

http://69.41.174.64/forum/printable.phtml?id=14233&thread=14207 suggests that the 8051 mixes different endian-ness in different places.

like image 32
Douglas Leeder Avatar answered Jan 29 '23 11:01

Douglas Leeder