News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

floating point arithmetic while assembling: MREAL-macros

Started by qWord, May 26, 2014, 05:05:17 PM

Previous topic - Next topic

rrr314159

Quote from: dedndavei 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

I'm making something wrong, obviously.

vv1 = 7 vv2 = 3600
vv1 * vv2 = 25200
result1   8688.000000
result2   496


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    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
Equations in Assembly: SmplMath

qWord

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

Fantastic!! (not my error this time  :biggrin:)

Thak you very much. HSE
Equations in Assembly: SmplMath

qWord

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

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
Equations in Assembly: SmplMath

HSE

Hi qWord!

Perfect: MR_FROM_STR rr1, 2.1E-4


Wrong:
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
Equations in Assembly: SmplMath

qWord

Quote from: HSE on April 10, 2016, 06:55:55 AMIt'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

Equations in Assembly: SmplMath