title: ASCII to decimal and vice versa for more than one character in NASM
body: <p>I am writing this little program where you input a dividend and a divisor and the program will output the quotient and the remainder.  Here is the code:</p>
  
  <pre><code>segment .data
  
  prompt db "Please enter a number: ", 10
  promptLen equ $-prompt
  prompt2 db "Please enter the divisor: ", 10
  prompt2Len equ $-prompt2
  prompt3 db "Your quotient is: ",10
  prompt3Len equ $-prompt3
  prompt4 db "Your remainder is: ",10
  prompt4Len equ $-prompt4
  
  segment .bss
  
  inputNum resb 2
  inputDiv resb 2
  quotient resb 2
  remainder resb 2
  
  segment .text
  
  global _start
  
  _start:
  
  mov eax, 4
  mov ebx, 1
  mov ecx, prompt
  mov edx, promptLen
  int 80h
  
  mov eax, 3
  mov ebx, 0
  mov ecx, inputNum
  mov edx, 2
  int 80h
  
  mov eax, 4
  mov ebx, 1
  mov ecx, prompt2
  mov edx, prompt2Len
  int 80h
  
  mov eax, 3
  mov ebx, 0
  mov ecx, inputDiv
  mov edx, 2
  int 80h
  
  xor edx, edx
  mov ax, [inputNum]
  mov bx, [inputDiv]
  and ax, 0xff
  and bx, 0xff
  sub ax, '0'
  sub bx, '0'
  
  div bx
  
  add ax, '0'
  add dx, '0'
  mov [quotient], ax
  mov [remainder], dx
  
  mov eax, 4
  mov ebx, 1
  mov ecx, prompt3
  mov edx, prompt3Len
  int 80h
  
  mov eax, 4
  mov ebx, 1
  mov ecx, quotient
  mov edx, 2
  int 80h
  
  mov eax, 4
  mov ebx, 1
  mov ecx, prompt4
  mov edx, prompt4Len
  int 80h
  
  mov eax, 4
  mov ebx, 1
  mov ecx, remainder
  mov edx, 2
  int 80h
  jmp exit
  
  exit:
  
  mov eax, 1
  xor ebx, ebx
  int 80h
  </code></pre>
  
  <p>The way the code is right now, I could only handle one-character numbers; by subtracting '0' and adding it back on for the output.
  Can anyone please help me use a more efficient way of doing this conversion, so that I won't be restricted to only one-character numbers?</p>