I have the following code:
push rbp
mov rbp, rsp
push rax
push rcx
push rdx
push rsi
push rdi
mov rax, QWORD[indiceVector]
mov rcx, 10
div rcx
mov rsi, rax
mov rdi, rdx
... and in the "div rcx" instruction it tells me "Floating point exception (generated 'core')" and it is not a division by 0, since debugging it gives me 23 divided by 10. The funny thing is that in some other function I have almost identical code and it doesn't give me the exception. Does anyone know why it gives this error? I have another question: To divide by 10, is the way I have done it correct or is there a better one?
Looking at the NASM Assembly Quick Reference I see something interesting regarding
div
:That is, you should initialize the register that receives the rest of the division to 0,
mov rdx, 0
to avoid the error.