flat assembler
Message board for the users of flat assembler.

Index > Main > FPU expertise/fprem1 anyone?

Author
Thread Post new topic Reply to topic
Posetf



Joined: 01 Mar 2004
Posts: 35
Location: London
Posetf 15 Jun 2004, 13:07
Can anyone tell me why the following code gives me a remainder of -0.4655 not +0.4655?

Code:
include 'macro.inc'      ; that's mine, based on win32ax.inc
.data
_Const4 dq 1.2
_Const5 dq 0.7345
FltWrk          dd ?
.code
start:
 fninit                                          ;; initialise FPU
   fnstcw word[FltWrk]
 or word[FltWrk],0x0C00          ;; set rounding mode as truncate towards zero (for floor())
 fldcw word[FltWrk]

;if rmdr(1.2,0.7345)!=0.4655 then puts(1,"rmdr(1.2,0.7345)!=0.4655\n") abort(1) end if
 fld [_Const4]
       fld [_Const5]
  @@:
  fprem1
      fstsw ax
    and ah,1
    jnz @b
      fstp ST1

        invoke ExitProcess,0
.end start    


Update: I now think I was a bit infatuated with "IEEE754" and the docs saying "all new softare should use fprem1, not fprem". I managed to get the expected result by changing to fprem and swapping the flds.
Post 15 Jun 2004, 13:07
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.