; Return in register RAX the integer part of the square root of the number ; in registers RSI:RDI, which integer part is equal to the number of the ; consecutive odd numbers that can be subtracted from that number. option prologue:none, epilogue:none .code sqrt128 proc _sqrt128 proc MOV RAX,-1 ; Initialise the 65-bit subtrahend with -1 MOV RDX,RAX ; in RDX:RAX .repeat ADD RAX,2 ; Get the next odd number ADC RDX,0 SUB RDI,RAX ; Subtract the low words SBB RSI,RDX ; Subtract the high words .until (carry?) ; No carry yet? Continue the loop! SHRD RAX,RDX,1;Divide the subtrahend to 2 RET ; RAX = the number of the subtracted odd numbers _sqrt128 endp sqrt128 endp end