什么是不结盟的访问? (ARM /凯尔) [英] What is non-aligned access? (ARM/Keil)

查看:342
本文介绍了什么是不结盟的访问? (ARM /凯尔)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Keil编写大会ARM 7。

I'm using Keil to write Assembly for ARM 7.

我有以下运行时错误:

Non-aligned Access: ARM Instruction at 000000F8H, Memory Access at 7F7F7F7FH
Data Abort: ARM Instruction at 000000F8H, Memory Access at 7F7F7F7FH

这并不能真正帮助我,因为我不知道什么'不结盟访问'是,(较明显等,但我真的不了解的这是什么意思)我的上午的试图访问(店)为 0x7F7F7F7F ,有什么问题?

This doesn't really help me, because I don't know what 'non-aligned access' is, (other than the obvious, but I don't really understand what it means) and I am trying to access (store) to 0x7F7F7F7F, what's the issue?

搜索我只找到了几个类似的问题,无论是使用C,并解决一些非常具体到他们的code和装置,它没有涉及到这个问题。

Searching I only found a couple of similar issues, both using C, and resolved by some means very specific to their code and which didn't relate to this issue.

我做的:

LDR R0, =0x7F7F7F7F
LDR R1, LABEL
STR R1, [R0]

然后我做类似的事情有不同的标签, R0 的偏移量,但先在这里失败。

I then do a similar thing with a different label, and offsets of R0, but it fails here first.

推荐答案

的问题是,你使用的是32位(4字节)内存操作的地址必须对齐到4字节边界。这意味着地址必须是4的倍数,或者如果你preFER,地址的底部有两个位必须为零。

The issue is that the address you use for a 32-bit (4-byte) memory operation must be aligned to a 4-byte boundary. This means the address must be a multiple of 4, or if you prefer, the bottom two bits of the address must be zero.

在这种情况下,最接近的4字节对齐的地址将是 0x7F7F7F7C 0x7F7F7F80

In this case, the closest 4-byte aligned addresses would be 0x7F7F7F7C or 0x7F7F7F80.

同样, LDRH / STRH 需要2字节对齐,而<​​code> LDRB / STRB 可在任何地方工作(1字节对齐==未对齐)。

Similarly, LDRH/STRH require 2-byte alignment, whereas LDRB/STRB can operate anywhere (1-byte alignment == unaligned).

在一般的编译器/汇编需要确保你的变量是正确对齐因为他们的规模护理 - 你应该只,如果你自己生成的地址(按问题)碰上这种

In general the compiler/assembler takes care of making sure your variables are aligned correctly for the size they are - you should only run into this if you're generating addresses yourself (as per the question).

这篇关于什么是不结盟的访问? (ARM /凯尔)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆