I am using a nasm compiler (rextester) for assembly. I am trying to divide 300 by 2 to get the quotient. I am able to do this for small numbers like 4/2 and my code works with no problem. When I try to do a big number like 300 I get a floating point exception. Can anyone help me figure out how to get my code to work please?
section .bss
num1 resb 3
num2 resb 1
op resb 1
result resb 3
onedig resb 1
tendig resb 1
hundig resb 1
section .text
global _start
_start:
;first number input
mov eax,3 ; system call (sys_read)
mov ebx,0 ; stdin
mov ecx,num1 ; declared var
mov edx,3 ; byte length
int 80h ; Call the kernel
;operator input
mov eax,3 ; system call (sys_read)
mov ebx,0 ; stdin
mov ecx,op ; declared var
mov edx,1 ; byte length
int 80h ; Call the kernel
;second number input
mov eax,3 ; system call (sys_read)
mov ebx,0 ; stdin
mov ecx,num2 ; declared var
mov edx,1 ; byte length
int 80h ; Call the kernel
;division
mov ax,[num1]
sub ax, '0'
mov bl,[num2]
sub bl, '0'
div bl
mov [result],al
add [result], dword '0'
mov eax,4 ; system call (sys_write)
mov ebx,1 ; stdout
mov ecx,result ; declared var
mov edx,3 ; byte length
int 80h ; Call the kernel
end:
mov eax,1 ; The system call for exit (sys_exit)
mov ebx,0 ; Exit with return code of 0 (no error)
int 80h;