I'm using Assembly x86 in NASM and what I want it to do is divide 2 numbers by 10, but it throws a floating point exception (core dumped).
section .data
mensaje db "Ingrese el primer numero: ", 0xA
longitud equ $ - mensaje
mensaje2 db "Ingrese el segundo numero: ", 0xA
longitud2 equ $ - mensaje2
invalido db "Algun caracter ingresado es invalido", 0xA
longitud1 equ $ - invalido
numeros db "0123456789", 0xA
section .bss
num1 resb 100
num2 resb 100
section .text
_inicio:
mov rax, 1
mov rdi, 1
mov rsi, mensaje
mov rdx, longitud
syscall
mov rax, 0
mov rdi, 0
mov rsi, num1
mov rdx, 100
syscall
mov rax, 1
mov rdi, 1
mov rsi, mensaje2
mov rdx, longitud2
syscall
mov rax, 0
mov rdi, 0
mov rsi, num2
mov rdx, 100
syscall
mov rcx, 0
;mov rdx, num1
jmp toInt
volver1:
mov rdx, rax
jmp toAscii
volver2:
mov rax, 1
mov rdi, 1
mov rsi, rdx
mov rdx, 100
syscall
jmp end
toInt:
mov bl, byte[num1+rcx]
cmp bl, 0xA
je volver1
cmp bl, '0'
jl error
cmp bl, '9'
jg error
sub bl, 35H
add rax, rbx
inc rcx
mov rsi, 10
or rax, rax
mul rax
xor rbx, rbx
jmp toInt
toAscii:
mov rcx, 10
mov rax, rdx
div rax
cmp rax, 0
je volver2
mov dl, byte[numeros+cl]
shl rdx, 8
jmp toAscii
end:
mov rax, 60
xor rdi, rdi
syscall
error:
mov rax, 1
mov rdi, 1
mov rsi, invalido
mov rdx, longitud1
syscall
jmp end
How it is written right now it should just ask me for two numbers, then it should turn the characters into integers and then back into characters. However, it just gives me a Floating point error.