;print out division message
mov rcx, 0 ;zero out register
mov rax, [input]
mov rcx, [input2]
idiv rcx ;divide rax by rcx
mov rdi, rax ;for printing purposes
call print_int
I can’t seem to figure out why this isn’t dividing, I’m getting a enrror “Floating Point Exception” I’m using a 64bit machine and the values are integers not floating point…. ideas?
I know after the division takes place the quotient should be in rax, and the remainder should be in rdx i believe, but as of right now i’m just trying to get my hands on the quotient.
Your function looks a little bit complicated to me.
idivworks as expected for me here with this function:Translated into NASM syntax and to the windows ABI, I think that would be something like:
Are you maybe stomping on your parameters and confusing something along the way?
Edit: looking at your code, it occurs to me that it might not be written as a proper function at all. The important steps are:
idiv rcx.You should pay particular attention to step 1 – make sure that RDX:RAX has sane contents! Why you’re getting a floating point exception I can’t guess from the code you’ve shown.