; Return in registers RDX:RAX the absolute value (module) of the difference ; between the signed double words in registers RCX:RDX and RSI:RDI. option prologue:none, epilogue:none .code absd128 proc _absd128 proc SUB RDX,RDI ; Subtract the low SBB RCX,RSI ; and the high words .if (less?) NEG RDX ; O = 0, S = 1 or O = 1, S = 0: module < 0 ADC RCX,0 ; - negate NEG RCX .endif XCHG RAX,RDX MOV RDX,RCX ; Return the absolute value in RDX:RAX RET ; Canonical solution: ; CMP RCX,RSI ; Compare the high words ; .if (less? || equal? && RDX < RDI) ; XCHG RCX,RSI ; Minuend < subtrahend: exchange the high ; XCHG RDX,RDI ; and the low words of the numbers ; .endif ; SUB RDX,RDI ; Subtract the low ; SBB RCX,RSI ; and the high words ; XCHG RAX,RDX ; MOV RDX,RCX ; Return the absolute value in RDX:RAX ; RET _absd128 endp absd128 endp end