News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Comparing a qword (unsigned) to real8

Started by JK, June 16, 2022, 09:32:48 PM

Previous topic - Next topic

daydreamer

Quote from: raymond on June 23, 2022, 06:44:24 AM
-Whenever you load an integer onto the fpu, it automatically ALWAYS considers it as a SIGNED integer. Trying to load the qword 264-1 (i.e. FFFFFFFFFFFFFFFF), the fpu would consider it as the value of -1.
so in .data section use signed versions of WORD DWORD etc SWORD SDWORD is useless,but is it only works for .IF macro comparisions ?
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jj2007

For the record, here the essentials of an optimised version:

MyR10 REAL10 9223372036854775808.0 ; 2^63
MyQW QWORD 9223372036854775806 ; 2^63-2
...
  fld MyR10
  xor esi, esi
  .Repeat
fild MyQW
test byte ptr MyQW[7], 128
.if !Zero?
fadd FP4(18446744073709551616.0)  ; translate a negative number to its unsigned equivalent
.endif
fcomi ST, ST(1) ; could be fcomip, but we want to print the value
.if Zero?
PrintLine "equal"
.elseif Carry?
PrintLine Str$("ST=%i is smaller than ST(1)", ST(0))
.else
PrintLine Str$("ST=%i is bigger than ST(1)", ST(0))
.endif
fstp st
add dword ptr MyQW, 1
adc dword ptr MyQW[4], 0
inc esi
  .Until esi>=5


Output:
ST=9223372036854775806 is smaller than ST(1)
ST=9223372036854775807 is smaller than ST(1)
equal
ST=9223372036854775809 is bigger than ST(1)
ST=9223372036854775810 is bigger than ST(1)