Assembly 解析器:移动指令上需要的指令

Assembly 解析器:移动指令上需要的指令,assembly,x86,nasm,Assembly,X86,Nasm,我正在尝试制作一个简单的汇编程序,就是将两个数字相加并显示,然后减去两个数字并显示。但我有一些错误: 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

我正在尝试制作一个简单的汇编程序,就是将两个数字相加并显示,然后减去两个数字并显示。但我有一些错误:

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
你写的是“移动”而不是“移动”

未被识别为指令助记符的标记将被视为标签。Like
move-nop
相当于
move:nop
。这就是为什么在以后的一些使用中会重新定义“
符号“move”


还有其他各种语法错误,比如
sub-eax和ebx
而不是
sub-eax,ebx
,以及
sub-ebx'0'中缺少一个逗号。
我认为您有输入错误。您有一个“move”指令,而我猜它应该是“mov”“最后没有额外的e。我不是组装专家,所以我可能错了。

您希望
添加eax和ebx
做什么-您可能是指
添加eax,ebx
?还有许多其他指令也缺少逗号,例如
sub-eax'0'
,它应该是
sub-eax'0'
。还要注意的是,错误消息非常有用-它们似乎确实在告诉您问题是什么-请尝试更仔细地研究它们。sub ebx“0”应该是
sub ebx,“0”
no?噢!但我仍然得到一个错误,它需要一个逗号、冒号、修饰符或在减法和加法操作数之后的行尾。您有
子eax和ebx
。我不确定你能做到。