0

Im trying to add two numbers together but receive an errorhere is a screenshot of it How do I bypass this error? In my input I'm just adding 1+1 (no spaces), is the problem due to the reserved bites for the result variable? The assignment calls for addition between three numbers yet I cannot get past simple addition between two numbers, please help

 section    .data

msg db  'This program will calculate addition and subtration',0xa   
len equ $ - msg         ;length of our dear string

section .bss
num1 resb 1
operation resb 1
num2 resb 1
result resb 1

section .text
    global _start       
_start:                     
    
;print message
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, len
int 0x80

;read first number
mov eax, 3
mov ebx, 0
mov ecx, num1
mov edx, 1
int 0x80


;print first number
mov eax, 4
mov ebx, 1
mov ecx, num1
mov edx, 1
int 0x80

;read first operation
mov eax, 3
mov ebx, 0
mov ecx, operation
mov edx, 1
int 0x80

;print first operation
mov eax, 4
mov ebx, 1
mov ecx, operation
mov edx, 1
int 0x80

;read second number
mov eax, 3
mov ebx, 0
mov ecx, num2
mov edx, 1
int 0x80

;print second number
mov eax, 4
mov ebx, 1
mov ecx, num2
mov edx, 1
int 0x80

mov ax, num1
mov bx, num2
ADD ax, bx
mov ax, result
int 0x80
;move ax to a variable

;print result
mov eax, 4
mov ebx, 1
mov ecx, result
mov edx, 1
int 0x80

mov eax, 1      ;system call number (sys_exit)
int 0x80        ;call kernel
Michael
  • 57,169
  • 9
  • 80
  • 125
jameson
  • 15
  • 4
  • `mov ax, num1` tries to move _the address_ of `num1` into `ax`, where it can't possibly fit since `ax` is a 16-bit register. – Michael Feb 08 '21 at 08:21
  • 1
    Other issues include having a stray `int 0x80` after the addition, and not taking into account that what you have at `num1` and `num2` are characters. – Michael Feb 08 '21 at 08:23

0 Answers0