Reputation: 668
I'm trying to divide in assembly language
I can't find a good example online on how to divide in 64 bit.
So far I have 2 values in two variabbles
input
input2
which where read in
I'm able to multiply fine, but i'm stuck on the division
so if i wan't to divide the two integers, i'm doing
mov rcx, [input]
mov rdi, [input2]
idiv rcx, rdi
that automatically give sme an error, because the division is suppose to be only one register, so i'm assuming that when using idiv
, it automatically divides some register, by the one you specify, so i tried
idiv rcx
but i'm getting "floating point error"
ideas?
Upvotes: 0
Views: 6670
Reputation: 224904
A quick look in the documentation shows two possibilities for division involving 64-bit numbers:
IDIV r/m32
Signed divide EDX:EAX by r/m32, with result stored in EAX ← Quotient, EDX ← Remainder.
IDIV r/m64
Signed divide RDX:RAX by r/m64, with result stored in RAX ← Quotient, RDX ← Remainder.
It's going to be integer division though. Your question is tagged floating point - if you want floating point division, you'll need one of the variants of the FDIV
instruction.
Upvotes: 4