Yes, I can see that you're linking "stoi" and "itos", but from where? If they're from libc (which I don't think they are), you've got the calling convention wrong! I can "invent" some functions, but they may not do what "your" functions do. In particular, I don't know what ecx does in "itos". Maximum length? Right justified in a field of that length? Or what?
From what I can see, you're inputting a string to "number1", converting it to a number and putting it back into "number1", then converting it back to a string and putting it back into "number1" again. Then the same for "number2". Then you're adding the first four characters of the two strings. This is not going to produce a useful result!
This is a WAG at what I think your code should perhaps look like:
;32-bit Add Two Numbers
global _start
extern stoi
extern itos
section .data
prompt1 db "Enter first number: ",0x00
msglen1 equ $ - prompt1 - 1
prompt2 db "Enter second number: ",0x00
msglen2 equ $ - prompt2 - 1
outmsg1 db "You entered ",0x00
msglen3 equ $ - outmsg1 - 1
outmsg2 db " and ",0x00
msglen4 equ $ - outmsg2 - 1
outmsg3 db ", the sum of these is ",0x00
msglen5 equ $ - outmsg3 - 1
section .bss
number1 resb 20
no1 resd 1
number2 resb 20
no2 resd 1
total resb 20
tot resd 1
buffer resb 20
section .text
_start:
nop ; for gdb
; Write a prompt
mov eax, 4 ; function code for system write
mov ecx, prompt1 ; address of string to be written
mov edx, msglen1 ; length of string to be written
mov ebx, 1 ; file descriptor or device (stdout)
int 80h ; generate system call
mov eax, 3 ; function code for system read
mov ecx, number1 ; address of string to be read
mov edx, 18 ; length of buffer (minus a little)
mov ebx, 0 ; file descriptor or device (stdin)
int 80h ; generate system call
mov eax, number1
call stoi
mov [no1], eax
; Write a prompt
mov eax, 4 ; function code for system write
mov ecx, prompt2 ; address of string to be written
mov edx, msglen2 ; length of string to be written
mov ebx, 1 ; file descriptor or device (stdout)
int 80h ; generate system call
mov eax, 3 ; function for system read
mov ecx, number2 ; address of string to be read
mov edx, 18 ; length of buffer (minus a little)
mov ebx, 0 ; file descriptor or device (stdin)
int 80h ; generate system call
mov eax, number2
call stoi
mov [no2], eax
mov eax, 4 ; function code for system write
mov ecx, outmsg1 ; address of string to be written
mov edx, msglen3 ; length of string to be written
mov ebx, 1 ; file descriptor or device (stdout)
int 80h ; generate system call
mov eax, [no1]
mov ecx, 14
mov ebx, number1
call itos
mov eax, 4
mov ecx, number1
mov edx, 19
mov ebx, 1
int 80h
mov eax, 4 ; function code for system write
mov ecx, outmsg2 ; address of string to be written
mov edx, msglen4 ; length of string to be written
mov ebx, 1 ; file descriptor or device (stdout)
int 80h ; generate system call
mov eax, [no2]
mov ecx, 20
mov ebx, number2
call itos
mov eax, 4
mov ecx, number2
mov edx, 19
mov ebx, 1
int 80h
mov eax, [no1]
add eax, [no2]
mov [tot], eax
mov ecx, 20
mov ebx, total
call itos
mov eax, 4 ; function code for system write
mov ecx, outmsg3 ; address of string to be written
mov edx, msglen5 ; length of string to be written
mov ebx, 1 ; file descriptor or device (stdout)
int 80h ; generate system call
mov eax, 4
mov ecx, total
mov edx, 19
mov ebx, 1
int 80h
mov eax, 1 ; function code for system exit
mov ebx, 0 ; exit status
int 80h
This is untested, and probably still has errors! In particular, the length that you're writing probably doesn't match the length of anything meaningful you've got in the buffers (depending on what "itos" does with ecx). It may get you closer...
I'm not able to understand what you're telling me about the "more than one input file" message. After you debug it? Doesn't make any sense! What app is giving you this message? The debugger? Nasm? I'm lost!
I may try to invent plausible "stoi" and "itos" functions to try... later. Better if you tell me what you're using - link or post 'em here. Until then...
Best,
Frank