在带有GCC或as的x86 PC上组装ARM asm的错误 [英] Errors on assembling ARM asm on an x86 PC with GCC or `as`

查看:142
本文介绍了在带有GCC或as的x86 PC上组装ARM asm的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在做汇编教程,一开始就陷入困境.

So I have been doing an assembly tutorial, and I got stuck in the very beginning.

项目名称:asmtut.s

Project name: asmtut.s

代码:

.text

.global _start

start:
  MOV R0, #65
  MOV R7, #1

SWI 0

马上开始,尝试以下行后,我会受到3条错误消息的欢迎:

as -o asmtut.o asmtut.s

asmtut.s:6:错误:期望在','之后的操作数;一无所有
asmtut.s:7:错误:期望在','之后的操作数;一无所有
asmtut.s:9:错误:没有这样的指令:'swi 0'

Right off the beginning I'm welcomed by 3 error messages after I try this line:

as -o asmtut.o asmtut.s

asmtut.s:6: Error: expecting operand after ','; got nothing
asmtut.s:7: Error: expecting operand after ','; got nothing
asmtut.s:9: Error: no such instruction: 'swi 0'

我很困惑,因为这是本教程中的确切代码,并且在这里完全可以正常工作.

I'm confused, because this is the exact code in the tutorial, and there it works completely fine.

任何人都可以帮我造成这个问题的原因吗?

Can anyone help me what could cause this?

推荐答案

您正试图使用​​x86汇编器来汇编ARM代码.他们使用不同的指令集和语法.

You're trying to use an x86 assembler to assemble ARM code. They use different instruction sets and syntax.

x86 Linux系统上的本机gccas工具会阻塞,就像您尝试使用Java编译器编译C ++一样,反之亦然.例如,#是GAS x86语法中的注释字符,因此mov r0,是语法错误,甚至还没有引起人们注意r0不是有效的x86寄存器名称.

The native gcc and as tools on your x86 Linux system will choke, just like if you tried to compile C++ with a Java compiler or vice versa. For example, # is the comment character in GAS x86 syntax, so mov r0, is a syntax error before it even gets to the point of noticing that r0 isn't a valid x86 register name.

您正在关注基于x86的PC上的Raspberry Pi(一种ARM体系结构)上的Assembly教程. 要么在Raspberry Pi上运行as,要么为Rasperry Pi/ARM安装交叉编译工具链.

You're following a tutorial for Assembly on Raspberry Pi (an ARM architecture) on a x86-based PC. Either run as on the Raspberry Pi, or install a cross-compile toolchain for Rasperry Pi/ARM.

某些Linux发行版具有提供arm-linux-gnueabi-as...-gcc的软件包.例如, https://www.acmesystems.it/arm9_toolchain 包含有关Ubuntu的详细信息.

Some Linux distros have packages that provide arm-linux-gnueabi-as and ...-gcc. For example, https://www.acmesystems.it/arm9_toolchain has details for Ubuntu.

要实际运行生成的二进制文件,您可以在ARM系统上运行它们,或者需要像qemu-arm这样的ARM仿真器. 如何在QEMU上的GDB中单步进行ARM组装?/a>和如何运行单个汇编行,然后查看[R1]和条件标志具有执行此操作的演练.

To actually run the resulting binaries, you'd either run them on your ARM system, or you'd need an ARM emulator like qemu-arm. How to single step ARM assembly in GDB on QEMU? and How to run a single line of assembly, then see [R1] and condition flags have walkthroughs of doing that.

这篇关于在带有GCC或as的x86 PC上组装ARM asm的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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