繁体   English   中英

解析器:移动指令预期的指令

[英]parser: instruction expected on move instruction

我正在尝试制作一个简单的汇编程序,即将两个数字相加并显示它们,然后将两个数字相减并显示它们。 但是我遇到了错误:

oppgave3.asm:28: error: parser: instruction expected
oppgave3.asm:29: error: comma, colon, decorator or end of line expected after operand
oppgave3.asm:30: error: symbol `move' redefined
oppgave3.asm:30: error: parser: instruction expected
oppgave3.asm:31: error: comma, colon, decorator or end of line expected after operand
oppgave3.asm:32: error: comma, colon, decorator or end of line expected after operand
oppgave3.asm:33: error: comma, colon, decorator or end of line expected after operand
oppgave3.asm:37: error: symbol `move' redefined
oppgave3.asm:37: error: parser: instruction expected
oppgave3.asm:38: error: comma, colon, decorator or end of line expected after operand
oppgave3.asm:39: error: symbol `move' redefined
oppgave3.asm:39: error: parser: instruction expected
oppgave3.asm:40: error: comma, colon, decorator or end of line expected after operand
oppgave3.asm:41: error: comma, colon, decorator or end of line expected after operand
oppgave3.asm:42: error: comma, colon, decorator or end of line expected after operand

这就是我想要做的:我有两个子程序,一个用于加法,一个用于减法。

section .data
a dw 4
b dw 2


section .bss
c resb 1

section .text
global_start:
_start:

call addition
mov eax,4
mov ebx,1
mov ecx,c
mov edx,1
int 0x80

call subtraction
mov eax,4
mov ebx,1
mov ecx,c
mov edx,1
int 0x80

addition:
move eax,[a]
sub eax '0'
move ebx,[b]
sub ebx '0'
add eax and ebx
add eax '0'
mov [c],eax
ret

subtraction:
move eax,[a]
sub eax '0'
move ebx,[b]
sub ebx '0'
sub eax and ebx
add eax '0'
mov [c],eax
ret

你写的是“move”而不是“mov”

未被识别为指令助记符的标记被视为标签。 就像move nop等价于move: nop 这就是为什么您会在一些后来的用途中symbol 'move' redefined " symbol 'move' redefined的原因。

还有其他各种语法错误,例如sub eax and ebx而不是sub eax, ebxsub ebx '0'缺少逗号

我想你有一个错字。 你有一个“移动”指令,而我的猜测是它应该是“移动”,最后没有额外的 e 。 我不是装配专家,所以我在这里可能是错的。

暂无
暂无

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

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