BBC BASIC
« floating point comparison »

Welcome Guest. Please Login or Register.
Feb 18th, 2018, 12:12am


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: floating point comparison  (Read 62 times)
Ric
New Member
Image


member is offline

Avatar




PM


Posts: 27
xx floating point comparison
« Thread started on: Feb 8th, 2018, 9:02pm »

Evening all, can anyone tell me why this code doesn't work? On the face of it, it gives the right result, but if you change the values of [result] and [result+8] it simply fails!

Help, anyone
Code:
      MODE 7
      DIM code% NOTEND AND 2047, code% 2047
      DIM result 27
      |result      = 11.87655
      |(result+8)  = 17.87655
      |(result+16) = 0.1
      FOR opt% = 0 TO 2 STEP 2
        P% = code%
        [
        OPT opt%
        .start
  
        mov                    eax,                       0
        mov              DWORD [result+24],               0
  
        fld              QWORD [result]
        fld              QWORD [result+16]
        faddp                  ST1,                       ST0
        fcomp            QWORD [result+8]
        fstsw                  ax
        wait
        sahf
        ja                     next_calc
        mov              DWORD [result+24],               2
        ret
  
        .next_calc
  
        mov                    eax,                       0
        fld              QWORD [result]
        fld              QWORD [result+16]
        fsubp                  ST1,                       ST0
        fcomp            QWORD [result+8]
        mov                    eax,                       0
        fstsw                  ax
        wait
        sahf
        jb                     end
        mov              DWORD [result+24],               3
        ret
  
        .end
        mov              DWORD [result+24],               1
        ret
        ]
      NEXT

      CALL start
      PRINT !(result+24)
 



Regards Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 727
xx Re: floating point comparison
« Reply #1 on: Feb 8th, 2018, 9:24pm »

on Feb 8th, 2018, 9:02pm, Ric wrote:
Evening all, can anyone tell me why this code doesn't work?

The code requires a *FLOAT 64 but as listed there isn't one. Of course it might simply have been lost in copying the listing into the forum, but it's the first thing I would check.

Richard.
User IP Logged

Ric
New Member
Image


member is offline

Avatar




PM


Posts: 27
xx Re: floating point comparison
« Reply #2 on: Feb 11th, 2018, 08:31am »

Thanks for the swift response Richard, you're right that the *FLOAT command is missing because of transposing into the forum. It turns out as you probably know there is nothing wrong with the code, it was the test on return from the routine that was at fault.

Regards Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls