[英]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, ebx
和sub ebx '0'
缺少逗號
我想你有一個錯字。 你有一個“移動”指令,而我的猜測是它應該是“移動”,最后沒有額外的 e 。 我不是裝配專家,所以我在這里可能是錯的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.