Purpose of memory alignment

前端 未结 8 1436
伪装坚强ぢ
伪装坚强ぢ 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 05:54

    It's a limitation of many underlying processors. It can usually be worked around by doing 4 inefficient single byte fetches rather than one efficient word fetch, but many language specifiers decided it would be easier just to outlaw them and force everything to be aligned.

    There is much more information in this link that the OP discovered.

提交回复
热议问题