64-bit assembly code to add 2 numbers
<p>I have written this program in 64-bit assembly to add two numbers. It works for 1-digit numbers, but not for 2-digit numbers.</p>

<p>What is wrong with my code?</p>

<pre><code>segment .data
  msg1 db "Enter a digit", 0xA, 0xD
  len1 equ $- msg1
  msg2 db "Please enter the second digit", 0xA, 0xD
  len2 equ $- msg2
  msg3 db "The sum is :"
  len3 equ $- msg3

segment .bss
  num1 resb 2
  num2 resb 2
  res resb 2

segment .text
global _start
_start:
  call _text1
  call _getName1
  call _text2
  call _getName2
  call _text3

  mov rax, [num1]
  sub rax, '0'

  mov rbx, [num2]
  sub rbx, '0'

  add rax, rbx
  add rax, '0'
  mov [res], rax
  mov rax, 1
  mov rdi, 1
  mov rsi, res
  mov rdx, 2
  syscall

  mov rax, 60
  mov rdi, 0
  syscall
_text1:
  mov rax, 1
  mov rdi, 1
  mov rsi, msg1
  mov rdx, len1
  syscall
  ret

_getName1:
  mov rax, 0
  mov rdi, 0
  mov rsi, num1
  mov rdx, 2
  syscall
  ret

_text2:
  mov rax, 1
  mov rdi, 1
  mov rsi, msg2
  mov rdx, len2
  syscall
  ret

_getName2:
  mov rax, 0
  mov rdi, 0
  mov rsi, num2
  mov rdx, 2
  syscall
  ret

_text3:
  mov rax, 1
  mov rdi, 1
  mov rsi, msg3
  mov rdx, len3
  syscall
  ret
</code></pre>