Author Topic: floating point arithmetic while assembling: MREAL-macros  (Read 7420 times)

rrr314159

  • Member
  • *****
  • Posts: 1381
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #15 on: October 11, 2015, 06:07:00 AM »
Quote from: dedndave
i think these macros are great
i'm just not working on anything that needs them, at the moment

- me 2. You're the macro whizzzard, qWord!
I am NaN ;)

HSE

  • Member
  • ****
  • Posts: 533
  • <AMD>< 7-32>
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #16 on: April 04, 2016, 05:30:06 AM »
I'm making something wrong, obviously.

Code: [Select]
vv1 = 7 vv2 = 3600
 vv1 * vv2 = 25200
result1   8688.000000
result2   496


Code: [Select]
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include \masm32\include\masm32rt.inc
    include \masm32\macros\real_math.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

comment * -----------------------------------------------------
                     Build this console app with
                  "MAKEIT.BAT" on the PROJECT menu.
        ----------------------------------------------------- *
    .const

    MR_FROM_EXPR32 vv1, 7
MR_FROM_EXPR32 vv2, 3600
MR_MUL r_2, vv1,vv2
      value REAL8 MR_TO_IEEE (<REAL8>, r_2)    ; ---------   Problem here , result1

    .data

      item dd 0

    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc
    LOCAL sz[128]:CHAR

    cls

MR_FROM_EXPR32 vv1, 7
MR_FROM_EXPR32 vv2, 3600
MR_MUL r_2, vv1,vv2

    mov item, MR_TO_INT32(vv1, 0.1)
    mov sz[0],0
    print cat$(ADDR sz," vv1 = ", udword$(item)), 9

    mov item, MR_TO_INT32(vv2, 0.1)
    mov sz[0],0
    print cat$(ADDR sz," vv2 = ", udword$(item)),13,10,10

    mov item, 25200
    mov sz[0],0
    print cat$(ADDR sz," vv1 * vv2 = ", udword$(item)),13,10,10

    print real8$(value),13,10,10
 
    mov item, MR_TO_INT32(r_2, 0.1) ; ----------------  Problem here , result2
    print udword$(item),13,10,10
     
    inkey
    ret

main endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
end start
Thanks. HSE

qWord

  • Member
  • *****
  • Posts: 1454
  • The base type of a type is the type itself
    • SmplMath macros
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #17 on: April 04, 2016, 11:38:01 PM »
You are using jwasm (or one of its forks), where the HIGHWORD-operator is broken. Because this bug is simple to solve, I will not made any attempt to fix this from macro side.

regards,
qWord
MREAL macros - when you need floating point arithmetic while assembling!

HSE

  • Member
  • ****
  • Posts: 533
  • <AMD>< 7-32>
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #18 on: April 04, 2016, 11:49:08 PM »
Fantastic!! (not my error this time  :biggrin:)

Thak you very much. HSE

qWord

  • Member
  • *****
  • Posts: 1454
  • The base type of a type is the type itself
    • SmplMath macros
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #19 on: April 05, 2016, 12:02:53 AM »
BTW: some time back I've upload jwasm version 212pre after fixing some bugs myself:
http://masm32.com/board/index.php?topic=2941.msg30728#msg30728
MREAL macros - when you need floating point arithmetic while assembling!

HSE

  • Member
  • ****
  • Posts: 533
  • <AMD>< 7-32>
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #20 on: April 05, 2016, 12:20:47 AM »
Yes, thank! I found Habran and Johnsa take the corrección in HJWASM.

I am still using a modified JWAsm13. (because the so many macro levels when using ObjAsm and SmplMath)


LATER: I modified HJWASM last version  and now MREAL is working in the real program.

           ⇒ user count ≥ 3  :t
« Last Edit: April 05, 2016, 01:24:34 AM by HSE »

HSE

  • Member
  • ****
  • Posts: 533
  • <AMD>< 7-32>
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #21 on: April 10, 2016, 06:55:55 AM »
Hi qWord!

Perfect:
Code: [Select]
MR_FROM_STR rr1, 2.1E-4

Wrong:
Code: [Select]
MR_FROM_STR rr2, 8.4E-4
Integ01.asm(8) : Error A2114: forced error: sorry - value to large or small for conversion

Only one MR_FROM_STR work. The followings not work. It's a jwasm problem. Do you know what the problem is?

Thanks. HSE

qWord

  • Member
  • *****
  • Posts: 1454
  • The base type of a type is the type itself
    • SmplMath macros
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #22 on: April 10, 2016, 08:17:31 AM »
It's a jwasm problem. Do you know what the problem is?
It is a problem with the function CreateVariable() in equate.c, which does not clear the upper 32 bits of already existing equates.
MREAL macros - when you need floating point arithmetic while assembling!

HSE

  • Member
  • ****
  • Posts: 533
  • <AMD>< 7-32>
Re: floating point arithmetic while assembling: MREAL-macros
« Reply #23 on: April 11, 2016, 12:17:51 AM »
Thanks  :t . My HJWasm work now!