2014-10-15 3 views
-1

두 개의 숫자를 더하고 표시 한 다음 두 숫자를 빼서 표시하는 간단한 어셈블리 프로그램을 만들려고합니다. 그러나 나는이 오류를 받고 있어요 :단순한 어셈블리 코드가 더하기/빼기를 ​​시도하지 않음

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 

이 내가 할 노력하고있어입니다 : 나는 두 개의 서브 루틴을 추가하기위한 하나 빼기 하나 있습니다. 대신 "MOV"

첨가 "이동"쓴

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 
+1

'add eax and ebx'가 무엇을 기대합니까? 아마도'add eax, ebx'를 의미할까요? 쉼표가 누락 된 다른 많은 지침이 있습니다 (예 : 'sub eax '0 ''은'sub eax,'0'이어야합니다. 또한 오류 메시지는 매우 도움이됩니다 - 문제가 무엇인지 정확하게 알려주는 것처럼 보입니다 - 더 자세히 연구 해보십시오. –

+1

sub ebx '0'은 'sub ebx', '0'은 아니어야합니까? – Brandon

답변

1

: 이동 EAX, [A] 서브 EAX 0 이동 EBX, [B] 서브 EBX에 '0' EAX와 EBX 은 EAX에 '0' MOV [C], EAX RET

감산 추가 : 이동 EAX, [A] 서브 EAX 0 이동 EBX를, [B] 하위 EBX '0' 서브 EAX와 EBX EAX를 추가 '0' MOV [C], EAX RET

+0

D' oh! 하지만 여전히 쉼표, 콜론, 장식 자 또는 뺄셈과 덧셈에 대한 피연산자 뒤에 오는 행 끝이 필요하다는 오류가 발생합니다. – user1784297

+2

당신은'sub eax and ebx'를 가지고 있습니다. 당신이 그렇게 할 수 있을지 확신하지 못합니다. – Brandon

0

은 당신이 오타를 생각한다. 당신은 "이동"명령을 가지고 있지만, 추측 할 때 마지막에 여분의 전자가 없으면 "mov"가되어야한다는 것입니다. 나는 조립 전문가가 아니므로 여기서 틀릴 수도 있습니다.

관련 문제