I want to subtract 2 64 bit numbers with borrow and looking for a way to do this using least possible instructions.

The number I want to subtract from is stored in EDX:EAX and the number to subtract with is a QWORD in memory.

So I want:

result = EDX:EAX - 8 byte memory

I was thinking to use MMX for this because I need later to do 64 bit compares aswell but I guess I need to put the values on stack first to load them with movq.
The result could be either in one of the mmx registers or just back in EDX:EAX.

Maybe some of you got some suggestions which is the fastest way to do this?

Thanks in advance.

// CyberHeg
Posted on 2002-10-17 03:13:29 by CyberHeg
You can't use MMX for this since MMX can't subtract numbers larger than 32-bit. However, there is a simple way to do this anyway:

sub eax, LODWORD
sbb edx, HIDWORD

I leave to you to figure out why this works since I don't have time to explain that right now.
Posted on 2002-10-17 05:38:24 by gliptic