I have been trying to debug a little assembly program where I ask for a dividend and a divisor and have to output the quotient and the remainder. For some reason however, my quotient and remainder are not output to the screen. Here is my 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]
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
I would appreciate if someone could help me understand what I am doing wrong.