arm是支持大端存储的,但是系统复位时默认执行小端代码,因此需要在开始的几条语句中完成大小端的转换,在2440的启动代码中有下面一段:
__ENTRY
ResetEntry
;1)The code, which converts to Big-endian, should be in little endian code.
;2)The following little endian code will be compiled in Big-Endian mode.
; The code byte order should be changed as the memory bus width.
;3)The pseudo instruction,DCD can not be used here because the linker generates error.
ASSERT :DEF:ENDIAN_CHANGE
[ ENDIAN_CHANGE
ASSERT :DEF:ENTRY_BUS_WIDTH
[ ENTRY_BUS_WIDTH=32
b ChangeBigEndian ;DCD 0xea000007
]
[ ENTRY_BUS_WIDTH=16
andeq r14,r7,r0,lsl #20 ;DCD 0x0007ea00
]
[ ENTRY_BUS_WIDTH=8
streq r0,[r0,-r10,ror #1] ;DCD 0x070000ea
]
|
b ResetHandler
]
根据注释来看,如果用大端模式来编译代码,这段代码也必须是机器在复位时所能认识的小端模式的代码
b ChangeBigEndian这句代码被大端模式编译以后也能在小端模式下运行吗?难道大端小端模式编译出来的机器码都是0xea000007吗?
还有为何ENTRY_BUS_WIDTH不同,代码也会不同呢?
望高手回答~谢谢 |