Hi,actually i need to run big endian code but i don't know how to set endian option in cp15 registers could any suggest me how to set EE bit set
This generally doesn't work unless you write the whole code sequence with "other endianness" in assembler. The compiler will make implicit memory accesses (such as stacking, and literal pool access) and therefore needs to have visibility / control of what the current endianness is; i.e. overriding directly via assembler is only going to work if you change back to "compiler endianness" before returning to C code.
Oh, thanks Harris
Hello Peter,
your comment is true. But I think we can dynamically access the data area by making special functions as following (for example).
Of course, these functions should be executed in the privileged mode.
How do you think about the idea?
/* short GetHalf(long *addr) */ GetHalf: PUSH {r10} MRC p15, 0, r10, c1, c0, 0 ORR r10, r10, (1<<25) MCR p15, 0, r10, c1, c0, 0 LDRH r0, [r0] MRC p15, 0, r10, c1, c0, 0 ORR r10, r10, (1<<25) EOR r10, r10, (1<<25) MCR p15, 0, r10, c1, c0, 0 POP {r10} BX lr /* void PutHalf(long *addr, long data) */ PutHalf: PUSH {r10} MRC p15, 0, r10, c1, c0, 0 ORR r10, r10, (1<<25) MCR p15, 0, r10, c1, c0, 0 STRH r1, [r0] MRC p15, 0, r10, c1, c0, 0 ORR r10, r10, (1<<25) EOR r10, r10, (1<<25) MCR p15, 0, r10, c1, c0, 0 POP {r10} BX lr
Best regards,
Yasuhiko Koumoto.
It's a very expensive way of doing it. If you are going to do functions to load single fields from memory then just use little-endian loads and use the "rev" instruction to reverse the result - it's only one additional instruction and much faster (and small enough to be inlined so you avoid the function overhead too).
It's only worth switching the whole processor data endianness if you are going to load a large block of data, and want to avoid executing hundreds of instructions to reverse the data.
Pete