The code below is to add two numbers that are in memory, defined in section of data,but also the result is in memory without a specific value. So at the end of the proccess of sum, the code call sys_write first to print the message and then again with sys_write print the result. But in terminal I got this :
La suma es
1234567890
1098765432
2333333322
2333333322
�U
The code is :
section .data
sum_msg: db "La suma es", 10
num1: db "1234567890",10
num2: db "1098765432",10
sum: db " ", 10
lenmsg: equ $-sum_msg
lensum: equ $-num1
section .text
global _start
_start:
mov esi, 9
mov ecx, 10
clc
add_loop:
mov al, [num1+esi]
adc al, [num2+esi]
aaa
pushf
or al, 30h
popf
mov [sum+esi], al
dec esi
loop add_loop
mov ecx, sum_msg
mov edx, lenmsg
mov ebx, 1
mov eax, 4
int 0x80 ; call kernel
mov ecx, sum
mov edx, lensum
mov ebx, 1
mov eax, 4
int 0x80 ; call kernel
mov eax, 1
int 0x80
Thanks and I hope someone could help me to understand why this is happening.