vjnguyenv 0 Newbie Poster

I have been working on this problem for days. The object is to add two numbers from user input and display the answer in 32bit. So far I've got the messages to display and accept user input, but I'm getting a segmentation fault which happens after "Total Sum is: ", which I dont really understand. I'm a noob at assembly. Any help would be great

;32-bit Add Two Numbers

        global _start

        extern stoi

        extern itos

section .data
message1 db     "Enter first number: ",0x0a,0x00
msglen1  equ    $ - message1

message2 db     "Enter second number: ",0x0a,0x00
msglen2  equ    $ - message2

message3 db     "Total Sum is: ",0x0a,0x00
msglen3  equ    $ - message3

section .bss
number1  resd   2
number2  resd   2
total    resd   3
buffer  resd    20

section .text
_start:                   ; Write a prompt
        mov eax, 4        ; function code for system write
        mov ecx, message1 ; 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, buffer   ; 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 eax, 4        ; function code for system write
        mov ecx, message2 ; 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
        mov ecx, buffer
        mov edx, 18
        mov ebx, 0
        int 80h

	mov eax, number2
        call stoi

        mov eax, number1
        add eax, number2
        mov [total], eax

        mov eax, 4
        mov ecx, message3
        mov edx, msglen3
        mov ebx, 1
        int 80h

        mov eax, buffer
        call itos

	mov eax, 1        ; function code for system exit
        mov ebx, 0        ; exit status
        int 80h
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.