如何修复程序集中的“错误:行尾的垃圾,第一个无法识别的字符 0xe2" [英] How to fix 'Error: junk at end of line, first unrecognized character 0xe2' in Assembly

查看:34
本文介绍了如何修复程序集中的“错误:行尾的垃圾,第一个无法识别的字符 0xe2"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的树莓派 3 上编写一个基本的 arm 程序集文件,该文件可以通过 gcc 编译器访问 printf 和 scanf,但是在编译我的代码时出现一个奇怪的错误.

I am trying to write a basic arm assembly file on my raspberry pi 3 that has access to printf and scanf through the gcc compiler, but upon compiling my code I get a strange error.

这是我用汇编编写的第三个使用 gcc 编译器的应用程序,所以我想做增量测试,所以我设置了提示和字符串,然后尝试干净地退出;但是,这是我抛出错误的代码:

This is my third application written in assembly to use the gcc compiler, so I wanted to do incremental testing so I set up my prompts and strings, and I try and exit cleanly; however, this is my code that throws the error:

.data
    .balign 4
    promptNum1: .asciz "Please enter some number that you want to work with"
    .balign 4
    inputNum1String: .asciz "%d"
    .balign 4
    outputString: .asciz "Your answer is %d"
    .balign 4
    return: .word 0
    .balign 4
    signPrompt: .word "What do you want the numbers to do?
 1)add 
 2)subtract
 3)multiply
 4)divide"
.text
.global main
main: 
    ldr r11, addressOfReturn
    str lr, [r11]
.
.
.
    ldr r11, addressOfReturn
    ldr lr, [r11]
    bx lr

addressOfPromptNum1: .word promptNum1
addressOfInputNum1String: .word inputNum1String
addressOfOutputString: .word outputString
addressOfReturn: .word return

我希望它能够像我之前的代码那样编译,但是,我的错误引用了带有 promptNum1、inputNum1String、outputString、signPrompt 的行上的一个无法识别的字符.但是,无法识别的字符是0xe2,查找后发现编译器无法识别的字符根本不在我的文件中.

I expect this to compile as my previous code did, however, my error references an unrecognized character on the lines with promptNum1, inputNum1String, outputString, signPrompt. However, the character that is unrecognized is 0xe2, and upon looking that up I found that the character that is not recognized by the compiler is not in my file at all.

推荐答案

代码中的引号是智能引号"(utf-8 序列 e2 80 9ce2 80 9d),它不能很好地与汇编器配合使用.将它们更改为常规引号,您应该没问题.

The quotes in your code are "smart quotes" (the utf-8 sequences e2 80 9c and e2 80 9d), which isn't playing well with the assembler. Change them to be regular quotes and you should be fine.

.data
    .balign 4
    promptNum1: .asciz "Please enter some number that you want to work with"
    .balign 4
    inputNum1String: .asciz "%d"
    .balign 4
    outputString: .asciz "Your answer is %d"
    .balign 4
    return: .word 0
    .balign 4
    signPrompt: .word "What do you want the numbers to do?
 1)add 
 2)subtract
 3)multiply
 4)divide"
.text
.global main
main: 
    ldr r11, addressOfReturn
    str lr, [r11]
.
.
.
    ldr r11, addressOfReturn
    ldr lr, [r11]
    bx lr

addressOfPromptNum1: .word promptNum1
addressOfInputNum1String: .word inputNum1String
addressOfOutputString: .word outputString
addressOfReturn: .word return

这篇关于如何修复程序集中的“错误:行尾的垃圾,第一个无法识别的字符 0xe2"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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