开发者

Data alignment and zero-bits relation?

开发者 https://www.devze.com 2023-01-30 13:34 出处:网络
Reading through a paper for the ARM Cortex-M3 CPU I found this line confusing: The lowest 2 开发者_如何学JAVAbits of the stack

Reading through a paper for the ARM Cortex-M3 CPU I found this line confusing:

The lowest 2 开发者_如何学JAVAbits of the stack pointers are always 0, which means they are always word aligned

I have seen similar statements elsewhere. What is the logic behind some zero bits => some alignment?


If the 2 LS bits are always zero then addresses can only be multiples of 4, i.e. addresses can only be:

Hex      Binary
xxxxxxx0 bbbbbbbbbbbbbbbbbbbbbbbbbbbb0000
xxxxxxx4 bbbbbbbbbbbbbbbbbbbbbbbbbbbb0100
xxxxxxx8 bbbbbbbbbbbbbbbbbbbbbbbbbbbb1000
xxxxxxxc bbbbbbbbbbbbbbbbbbbbbbbbbbbb1100

(If it helps, think of the equivalent in decimal - any number that ends in 00 is a multiple of 10^2 = 100).

0

精彩评论

暂无评论...
验证码 换一张
取 消