SECTION .data
msg2:db "Enter 3 the numbers: "
len2:equ $-msg2
msg3:db "Sum= "
len3:equ $-msg3
SECTION .bss
count:resb 2
count1:resb 2
num: resd 200
num1: resd 200
result:resb 8
SECTION .text
mov rax,1
mov rdi,1
mov rsi,msg2
mov rdx,len2
syscall
mov rsi,num
mov byte[count1],3
accept:
mov rax,0
mov rdi,1
mov rdx,17
syscall
call convert
add esi,16
dec byte[count1]
jnz accept
mov rax,1
mov rdi,1
mov rsi,msg3
mov rdx,len3
syscall
mov byte[count],3
mov rsi,num1
;mov rdx,0000000000000000H
add:
add rdx,[rsi]
add rsi,16
dec byte[count]
jnz add
call convert_1
mov rax,1
mov rdi,1
mov rsi,result
mov rdx,17
syscall
convert:
mov eax,esi
mov edi,num1
mov byte[count],16
up:
rol rax,4
mov dl,al
and dl,0FH
cmp dl,09H
jbe sub30
sub dl,7H
sub30:
sub dl,30H
mov [edi],dl
inc edi
dec byte[count]
jnz up
ret
convert_1:
mov rax,num1
mov rdi,result
mov byte[count],16
up1:
rol rax,4
mov dl,al
and dl,0FH
cmp dl,09H
jbe add30
add dl,7H
add30:
add dl,30H
mov [rdi],dl
inc rdi
dec byte[count]
jnz up1
ret
mov rax,60
mov rdi,0
syscall
I have tried writing this program to add 3 64bit numbers ,but I'm getting a Segmentation Fault (core dump). I dont know what is going wrong. Please help.
Thanks in advance.