问题描述
我使用的是执行内存复制与Windows嵌入在Cortex-A8处理器Compact 7的ARM汇编。
I am using the NEON memory copy with preload implementation from the ARM website with the Windows Embedded Compact 7 ARM assembler on a Cortex-A8 processor.
我注意到,我得到的数据类型不对例外,当我提供非字对齐值的功能
I notice that I get datatype misalignment exceptions when I provide that function with non word aligned values
例如:
; NEON memory copy with preload
ALIGN
LEAF_ENTRY NEONCopyPLD
PLD [r1, #0xC0]
VLDM r1!,{d0-d7} ;datatype misalignment
VSTM r0!,{d0-d7}
SUBS r2,r2,#0x40
MOV R0, #0
MOV PC, LR
ENTRY_END
size_t size = /* arbitrary */;
size_t offset = 1;
char* src = new char[ size + offset ];
char* dst = new char[ size ];
NEONCopyPLD( dst, src + offset, size );
memcpy( dst, src + offset, size ); /* works perfectly */
这是预期的VLDM命令?文章没有提到这个实现仅限于字对齐值。它是可以解决的?如果是这样,怎么样?
Is this expected for the VLDM command? The article doesn't mention that this implementation is limited to word-aligned values. Is it fixable? If so, how?
推荐答案
即使你没有指定你仍然需要对齐数据元素边界上(即双字边界在这种情况下)明确的对齐要求。也有一些例外情况,但它可能最好不要依赖它们,除非你有一个很好的理由这样做。
Even if you don't specify an explicit alignment requirement you still need to align the data on an element boundary (i.e. on a doubleword boundary in this case). There are some exceptions to this rule, but it's probably best not to rely on them unless you have a really good reason to do so.
有关更多信息,请参见Cortex-A8的技术参考手册(ARM DDI 0344J)。
See the Cortex-A8 technical reference manual (ARM DDI 0344J) for more information.
这篇关于ARM memcpy和校准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!