Okay, I'm at wit's end here trying to multiply double precision floats in x86 Assembly. Our first assignment (to be due on the first day of class before we've even had a single lecture for some screwed up reason) is to write a program that calculates the surface area and volume of a sphere of a given radius. The relevant section looks a bit like this so far:
PI equ 0x400921fb54442d18 ;Represents 8-byte float Pi (NASM Manual)
;rbx = radius
mov qword rax, PI ;Set rax to Pi so we can calculate surface area 4*Pi*r*r
add rax, rax ;Pi + Pi = 2*Pi
add rax, rax ;2*Pi + 2*Pi = 4*Pi
mul rbx ;Multiply 4*Pi by r, result in rdx:rax (most significant in rdx, least significant in rax?)
;Something about storing rax to memory here?
mov qword rcx, rdx ;Save significant part into rcx
;More stuff
Once that's done, I'm going to need to multiply by r again, store that result, then multiply by r and 1/3 to get the volume.
Can I just ditch the least significant digits between multiplications or will that incur noticeable rounding errors?
Best guide I could find was
this, but I'm not really sure what's going on with the saving to and retrieving from [bignum]. Maybe I'd be better off working with the SSE vector registers?
(Edit: It looks like that's for multiplying two 32-bits to make a 64-bit. I only need to multiply two 64-bits to make another 64-bit. Maybe just chopping off the end is fine? It's limited to 15 digits of accuracy with my value for Pi anyways.)