Sum double numbers without FPU?

Is that possible. can you give me any hints about it
Posted on 2005-04-14 13:32:14 by luise.valencia
adc add with carry
I'll leave it up to you to figure how to do it
BUT I will tell you that you will need 2 addtions
I assume you want to do a 64 bit addtion
watch the byte order
Posted on 2005-04-14 23:52:14 by rob.rice
I guess, like this, roughly (not tested, doesn't handle abnormal conditions):
pushad
mov eax,Nbr1+4
mov ecx,Nbr2+4
mov esi,eax
mov edi,ecx
and 0fffffh,esi
or 100000h,esi
and 0fffffh,edi
or 100000h,edi
mov edx,Nbr1
mov ebx,Nbr2
mov ebp,eax
xor ebp,ecx
jns samesign
neg edx
adc esi,0
neg esi
samesign:
shl eax,1
shl ecx,1
shr eax,21
shr ecx,21
sub ecx,eax
jb higher
neg ecx
xchg ebx,edx
xchg esi,edi
higher:
cmp ecx,32
jb b32
cmp ecx,64
jae noadd
sar esi,cl
mov edx,esi
sar esi,31
jmp b64
b32:
shrd edx,esi,cl
sar esi,cl
b64:
add edx,ebx
adc esi,edi
jns nochgsgn
neg edx
adc esi,0
neg esi
or ah,8
nochgsgn:
cmp esi,200000h
jb notl1
shr esi,1
rcr edx,1
inc eax
notl1:
cmp esi,100000h
jae notr1
shl edx,1
rcl esi,1
dec eax
notr1:
shl eax,20
mov ecx,Nbr1+4
and ecx,80000000h
xor eax,ecx
or eax,esi
mov Nbr1,esi
mov Nbr1+4,eax
noadd:
popad
Posted on 2005-04-19 09:36:30 by Sephiroth3