错误:行尾垃圾 -as 和 -o ARM 错误 [英] Error: Junk at end of line -as and -o error with ARM

查看:14
本文介绍了错误:行尾垃圾 -as 和 -o ARM 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写我的第一个 ARM 程序并在尝试运行时收到此错误"as -o labl1.o lab1.s"

I am attempting to write my first ARM program and getting this error when I try to run "as -o labl1.o lab1.s"

lab1.s:3: Error: junk at end of line, first unrecognized character is `s'

我非常不确定我在这里做错了什么,因为我唯一一次使用 s 是在我的 2 个字符串中,并且对我在代码中哪里出错感到非常困惑.

I am very unsure about what I am doing wrong here, as the only times I use s is in my 2 strings, and very puzzled on where in the code I went wrong.


@Data
.data
string1: .asciz
string2: .asciz

@Code
.text
.global main
.extern printf

main:

push {ip, lr}

push {r0, r1, r2}
ldr r0, =string1
mov r1, #34
mov r2, #56
bl printf
pop {r0,r1,r2}

push {r0}
ldr r0, =string2
bl printf
pop {r0}

pop {ip, pc}

提供有用文档或帮助调试的链接将不胜感激,谢谢!

Links to helpful documents or help debugging would be greatly appreciated, thank you!

推荐答案

您可能会混淆字符串的地址和要为其分配的值:正如在 GNU 中指定的 documentation.asciz 指令确实需要一个字符串参数 - 一个稍微修改的版本您的代码确实组装正确:

You may be confusing the address of your strings and the values you want to assign them: As specified in GNU as documentation, the .asciz directive does require a string argument - a slightly modified version of your code does assemble correctly:

.data
string1: .asciz "string1"
string2: .asciz "string2"

string1 现在是字节 "string1\x00" 所在地址的标签,string2 是地址的标签其中字节 "string2\x00" 是.

string1 is now the label for the address where bytes "string1\x00" are located, and string2 is the label for the address where bytes "string2\x00" are.

这篇关于错误:行尾垃圾 -as 和 -o ARM 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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