Hi everyone, i comeback with a post from @monsterhunter445,
im with the same practice but my output give me only the num1...
sorry for my english ^^, i only speak spaƱish.... ^^
you can see that it is a simple add, num1+num2=resul (strings); intn1+intn2=iresul (integers)... :3 then the output give me always num1.
***************************************************************
;nasm -f elf suma.asm
;ld -s -o suma suma.o
;./suma
SECTION .data
msg1: db "Este programa realiza la suma de 2 numeros",10
len1: equ $-msg1
msg2: db "introduzca el primer numero: ",10
len2: equ $-msg2
msg3: db "introduzca el segundo numero: ",10
len3: equ $-msg3
msg4: db "El resultado de la suma es: ",10
len4: equ $-msg3
SECTION .bss
num1: resb 255
num2: resb 255
intn1: resb 255
intn2: resb 255
iresul: resb 255
resul: resb 255
SECTION .text
global _start
_start:
;msj1
mov edx,len1 ; arg3, length of string to print
mov ecx,msg1 ; arg2, pointer to string
mov ebx,1 ; arg1, where to write, screen
mov eax,4 ; write sysout command to int 80 hex
int 0x80 ; interrupt 80 hex, call kernel
;msj2
mov edx,len2 ; arg3, length of string to print
mov ecx,msg2 ; arg2, pointer to string
mov ebx,1 ; arg1, where to write, screen
mov eax,4 ; write sysout command to int 80 hex
int 0x80 ; interrupt 80 hex, call kernel
;introducir num1
mov edx,255
mov ecx,num1
mov ebx,0
mov eax,3
int 80h
;msj3
mov edx,len3 ; arg3, length of string to print
mov ecx,msg3 ; arg2, pointer to string
mov ebx,1 ; arg1, where to write, screen
mov eax,4 ; write sysout command to int 80 hex
int 0x80 ; interrupt 80 hex, call kernel
;introducir num2
mov edx,255
mov ecx,num2
mov ebx,0
mov eax,3
int 80h
;msj4
mov edx,len4 ; arg3, length of string to print
mov ecx,msg4 ; arg2, pointer to string
mov ebx,1 ; arg1, where to write, screen
mov eax,4 ; write sysout command to int 80 hex
int 0x80
;convertir num1 a entero
mov ebx, [num1]
sub ebx, 48 ;can someone say me why sub 48 to the num1 value? i know that is to convert but
mov [intn1], ebx why subtract 48?
;convertir num2 a entero
mov ebx, [num2]
sub ebx, 48
mov [intn2], ebx
;sumar enteros
mov eax, [intn1]
add eax, [intn2]
mov [iresul], eax
;convertir iresul en string i dont know completely this conversion...
mov edx,10
xor edx,edx
div ebx
add dl, '0'
mov [resul],dl
;resultado
mov edx,255
mov ecx,[iresul]
mov bx,1
mov eax,4
int 80h
;terminar
mov ebx,0 ; exit code, 0=normal
mov eax,1 ; exit command to kernel
int 0x80 ; interrupt 80 hex, call kernel
Edit: Please use Code Blocks and don't Double Post questions.