0

this is for masm assembly.

here it reads from file. file contents is put into buffer

        mov edx, OFFSET buffer
        mov ecx, SIZEOF buffer
        call ReadFromFile

        mov buffer[eax],0                     
        mov edx, offset displayMssg
        call WriteString
        call  Crlf
        mov edx,OFFSET buffer 
        call WriteString
        call Crlf

the comparison is not working

        mov ecx, buffer 
        cmp ecx, num1    ; num1 DWORD 4.5
        jge DISPLAY1
        cmp ecx, num2   ;num2 DWORD 3.5
        jge DISPLAY2
        jle QUIT
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Skyb
  • 11
  • 5
  • 2
    Does your buffer just hold ASCII text? If you want an IEEE754 single-precision float, you have to convert from string to text (e.g. `call atof`), or call an input function that does that if Irvine32 has one. Check what integer value is in `ecx` when `cmp` runs. (Use hex so ASCII codes for digits will be more easy to notice.) – Peter Cordes Mar 21 '21 at 19:33
  • 2
    Also note that `cmp` is an integer compare. That's fine for exact equality (as long as you don't care about NaNs or +0.0 == -0.0 IEEE semantics), but you'll have an easier time using `movss xmm0, buffer` / `ucomiss xmm0, num1` for conditions like `jae` >=. (Although you actually *can* use signed-integer compares on FP bit patterns as long as they're not both negative; that's due to how IEEE754 biases the exponent so monotonically increasing magnitude leads to increasing integer bit patterns.) – Peter Cordes Mar 21 '21 at 19:35
  • @PeterCordes Thank you, Peter!! It did not work earlier due to hex comparing with integer. But after changing both to hex, it works now :-) – Skyb Mar 22 '21 at 13:26

0 Answers0