Purpose of memory alignment

前端 未结 8 1429
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 05:20

Admittedly I don\'t get it. Say you have a memory with a memory word of length of 1 byte. Why can\'t you access a 4 byte long variable in a single memory access on an unalig

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 06:01

    On PowerPC you can load an integer from an odd address with no problems.

    Sparc and I86 and (I think) Itatnium raise hardware exceptions when you try this.

    One 32 bit load vs four 8 bit loads isnt going to make a lot of difference on most modern processors. Whether the data is already in cache or not will have a far greater effect.

提交回复
热议问题