0

I have the following variables (x,y) that I read user provided data into and then attempt to add them and finally outputting the result to the terminal

section .bss

        ; first number
        x resb 5

        ; second number
        y resb 5

        ; sum 
        z resb 10

this is out I am trying to add them

    ; sum the two numbers
    mov eax, x      ; moves the value of x into eax register
    add eax, y      ; adds value of y to what ever value is in eax 
  


    ; Output value of z
    mov eax, 4  ; system call (sys_write)
    mov ebx, 1  ; file descriptor (stdout)
    mov ecx, z  ; 
    mov edx, 10 ;
    int 0x80    ; kernel call

this is the output of my program

welcome please enter two numbers 
Enter first number 
123
Enter second number 
23
                    

why am i getting an empty line for the value of z

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
  • Adding addresses (pointers) doesn't give you anything useful, and you don't even use your EAX result from `add`. `mov eax, [y]` / `add eax, [y]` would add ASCII digits to each other without doing decimal carry-propagation so that's not useful either, so normally you'd convert string->integer, add, then convert int->string. Semi-related: [Adding 2 inputted numbers in Assembly using NASM](https://stackoverflow.com/q/49289253) for two single-digit numbers, producing a 1 or 2-digit sum. – Peter Cordes May 03 '22 at 05:32

0 Answers0