简体   繁体   English

行尾出现意外字符

[英]Unexpected characters at end of line

I Writing a code that loops 1000 times in assembly language, although I keep getting these errors:我用汇编语言编写了一个循环 1000 次的代码,尽管我不断收到这些错误:

main.s(48): error: A1137E: Unexpected characters at end of line
main.s(53): error: A1137E: Unexpected characters at end of line
main.s(55): error: A1163E: Unknown opcode endloop , expecting opcode or Macro
".\SimpleProject.axf" - 3 Error(s), 0 Warning(s).

Here is an Example of my code:这是我的代码示例:

MOV R0, #1, i = 1;
startloop   
    cmp R0, #1000
    BGT endloop
        ADD R1, R1, R0
        ADD R0, R0, #1, i++;
        B startloop
endloop

line (48) refers to:第 (48) 行是指:

MOV R0, #1, i = 1;

Try changing the erroneous line to:尝试将错误的行更改为:

MOV R0, #1

Clearly i = 1;显然i = 1; was supposed to be a comment, but you accidentally typed a comma instead of whatever comment character is supported by your assembler.应该是注释,但您不小心输入了逗号,而不是汇编程序支持的任何注释字符。 Read the documentation of your assembler to learn comment syntax.阅读汇编器的文档以了解注释语法。

The move instruction (MOV) takes two parameters: either two registers, or a register and an immediate value.移动指令 (MOV) 采用两个参数:两个寄存器,或一个寄存器和一个立即数。 Thus, (MOV R0, #1, i = 1;) is invalid.因此, (MOV R0, #1, i = 1;)无效。 Also, you don't need semi-colon at the end of each instruction.此外,您不需要在每条指令的末尾使用分号。 A comment can be made with double forward slashes.可以使用双斜杠进行注释。 So, try this:所以,试试这个:

MOV R0, #1 //i = 1;

You can learn more from the ARM Compiler toolchain Assembler Reference, and/or watching some tutorials on YT such as ARM instructions tutorial , or sample loop program in assembly您可以从 ARM 编译器工具链汇编器参考中了解更多信息,和/或观看 YT 上的一些教程,例如ARM 指令教程,或汇编中的示例循环程序

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM