在 C 中使用 ASM 命令 [英] Using ASM command in C

查看:31
本文介绍了在 C 中使用 ASM 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于在 c 中使用 ASM 的小问题.我要执行指令:

I have a small question about using ASM in c. I want to execute the instruction:

LDR PC,=0x123456

这给了我错误操作数中的意外标记".

This gives me the error "unexpected token in operand".

asm("LDR PC,=0x123456");

这给出了无效约束".

asm("LDR PC," : "m" (0x123456));

这样做的正确方法是什么?

What's the right way to do this?

推荐答案

您正在使用这个:

asm("LDR PC,=0x123456");

这不是标准的 ARM 汇编指令,而是作为编译器扩展提供的伪指令.编译时,此伪指令将转换为其他汇编指令.似乎 clang 不支持这个编译器扩展(见这个 thread).您应该自己转换为汇编指令,请参阅 ARM 文档以了解 LDR伪指令被转换.

This is not a standard ARM assembly instruction, but a pseudo-instruction provided as a compiler extension. This pseudo-instruction is converted to other assembly instructions when you compile it. It seems clang doesn't support this compiler extension (see this thread). You should do the conversion to assembly instructions yourself, see the ARM documentation for how the LDR pseudo-instruction is converted.

这篇关于在 C 中使用 ASM 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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