0

*I'm trying to compare a real number with a number but it doesn't work, what are the correct instructions for the following?

number_check:

     mov esi, input("Enter number (",60,"10): ");

     INVOKE StrToFloat, esi, ADDR num

     cmp num,10

     jge number_check
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
TCNJK
  • 1
  • 1
  • Integer `cmp` is certainly not what you want; FP uses different instructions, like `comiss` (and they don't take immediate operands). https://www.felixcloutier.com/x86/comiss. (Or for legacy x87, fcomi on P6-compatible CPUs). You haven't said what your `StrToFloat` function does, but I assume stores a 32-bit float into memory at the address passed in the last arg? Instead of returning a return value. Maybe the return value is for an error status? – Peter Cordes Mar 19 '22 at 05:39
  • [How to compare 2 float in assembly](https://stackoverflow.com/q/5944185) shows how to use `fcom` + `fstsw ax` / `sahf`. If you don't want to use obsolete stuff, `comiss` sets EFLAGS in an equivalent way. – Peter Cordes Mar 19 '22 at 05:42

0 Answers0