我试图制作一个简单的汇编程序,即添加两个数字并显示它们,然后减去两个数字并显示它们。但是我遇到了错误:
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
答案 0 :(得分:1)
你写了“move”而不是“mov”
此外: 移动eax,[a] sub eax'0' 移动ebx,[b] sub ebx'0' 添加eax和ebx 添加eax'0' mov [c],eax 保留
减法: 移动eax,[a] sub eax'0' 移动ebx,[b] sub ebx'0' sub eax和ebx 添加eax'0' mov [c],eax 保留
答案 1 :(得分:0)
我认为你有一个错字。你有一个“移动”指令,而我的猜测是它应该是“mov”而不是最后的额外e。我不是装配专家,所以我可能在这里错了。