News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Dealing with REAL10 values

Started by Gunther, April 07, 2013, 02:10:07 AM

Previous topic - Next topic

Gunther

Here is the appropriate 32 bit source from the thread inside the 64 Bit Assembler forum. There are no differences in the C++ source, but a few differences inside the assembly language source.

Gunther
You have to know the facts before you can distort them.

MichaelW

I don't have time ATM to examine this further, but on my XP system with a recent MinGW installation the 32-bit LongDouble.exe triggers an access violation exception in libstdc++-6!ZSt4cout. Here are the dependencies as returned by Dependency Walker:

KERNEL32.DLL
LIBGCC_S_DW2-1.DLL
LIBSTDC++-6.DLL
LONGDOUBLE.EXE
MSVCRT.DLL
NTDLL.DLL

Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Michael,

Quote from: MichaelW on April 07, 2013, 02:01:02 AM
I don't have time ATM to examine this further, but on my XP system with a recent MinGW installation the 32-bit LongDouble.exe triggers an access violation exception in libstdc++-6!ZSt4cout. Here are the dependencies as returned by Dependency Walker:

KERNEL32.DLL
LIBGCC_S_DW2-1.DLL
LIBSTDC++-6.DLL
LONGDOUBLE.EXE
MSVCRT.DLL
NTDLL.DLL



I could test the 32 bit exe only with Windows XP Mode under Windows 7. Could you re-compile it from the source?

Gunther
You have to know the facts before you can distort them.

qWord

the program requires libgcc_s_dw2-1.dll and libstdc++-6.dll, which can be found in gcc's bin folder.
You maybe use -static-libgcc for linking.

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

anta40

Gunther's exe also crashes on my laptop, and indeed the cause is libgcc_s_dw2-1.dll not found in my gcc directory.
One possible explanation is Gunther and I are using different distros of mingw.

I'm using this, btw:
http://sourceforge.net/projects/mingwbuilds/files/host-windows/testing/4.8.0/32-bit/threads-win32/sjlj/x32-4.8.0-snapshot-20130315-rev196647-win32-sjlj.7z/download

So I recompile the code, and it works. And actually it's also compilable with MSVC 2012. Attached it for you guys (only dependent on kernel32.dll)  ;)

GCC 4.8 output:
Quote
Layout of data types:
=====================

Long Double (REAL 10)   = 12 Bytes
Double (REAL 8)         =  8 Bytes
Float (REAL 4)          =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = 3.1415926535897932385
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.141593

Press any key to continue ...

MSVC 2012 output:
Quote
Layout of data types:
=====================

Long Double (REAL 10)   = 8 Bytes
Double (REAL 8)         =  8 Bytes
Float (REAL 4)          =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = -8.8796093704934495e+043
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.144531

Press any key to continue ...

jj2007

Quote from: anta40 on April 07, 2013, 03:27:46 AM
Double (REAL 8)         =  8 Bytes

Double looks real cool, but that's a problem of the forum software ;-)

Gunther

Hi anta40,

Quote from: anta40 on April 07, 2013, 03:27:46 AM
Gunther's exe also crashes on my laptop, and indeed the cause is libgcc_s_dw2-1.dll not found in my gcc directory.
One possible explanation is Gunther and I are using different distros of mingw.

I'm using this, btw:
http://sourceforge.net/projects/mingwbuilds/files/host-windows/testing/4.8.0/32-bit/threads-win32/sjlj/x32-4.8.0-snapshot-20130315-rev196647-win32-sjlj.7z/download

thank you for helping. Indeed, I did use gcc 4.6.2 and that behavior is a bit strange, because C++ isn't Visual Basic which needs sometimes this and that DLL. So, I'll upgrade the compiler.

Gunther
You have to know the facts before you can distort them.

Gunther

Hi qWord,

Quote from: qWord on April 07, 2013, 02:59:06 AM
the program requires libgcc_s_dw2-1.dll and libstdc++-6.dll, which can be found in gcc's bin folder.
You maybe use -static-libgcc for linking.

qWord

that was my next idea, too. But it doesn't help.

Gunther
You have to know the facts before you can distort them.

Magnum

I am always finding C code, so I may as well assemble it.

I downloaded yasm.

Where would be a good place to get the header and lib files ?

I have some from my 2003 SDK, can I use them ?

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

MichaelW

I forgot to mention that both of the GCC-specific DLLs are in the MinGW bin directory.

After a recompile, with GNU C++ (GCC) version 4.7.2 (mingw32), the app runs OK and I get:

Layout of data types:
=====================

Long Double (REAL 10)   = 12 Bytes
Double (REAL 8)         =  8 Bytes
Float (REAL 4)          =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = 3.1415926535897932385
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.141593


:t

Also, I attempted qword's suggestion:

:yasm -f win32 LongDouble.asm
g++ -v -c LongDouble.cpp
pause
g++ -v -static-libgcc -o LongDouble.exe LongDouble.o LongDouble.obj
pause


And while I can't see anything in the -v output that looks like a warning or error, and the app still functions correctly, the dependencies do not change.
Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Michael,

thank you for your help. :t

After studying the CERN sources again and again, I've found now the appropriate solution for simple C, too. The new added archive is LongC32.zip and should work fine. Here is the output:


Layout of data types:
=====================

Long Double (REAL10)    = 12 Bytes
Double (REAL8)          =  8 Bytes
Float (REAL4)           =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = 3.1415926535897932385
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.141593

Press any key to continue ...


Please check the batch file, because the command line for compiling the C source is a bit tricky. Unfortunately, it won't compile wit VC. But it should work too with Borland's and Intel's C compiler (but that's not tested). The appropriate 64 bit source is LongC64.zip inside that thread.

Gunther
You have to know the facts before you can distort them.

MichaelW

This time, the supplied EXE worked correctly.

A bit tricky?

I have in the past spent a significant amount of time trying to do this with a C app compiled with GCC, but who could have guessed that it would take an apparently undocumented:

-D__USE_MINGW_ANSI_STDIO

switch?

Interesting, the dependencies this time are:

KERNEL32.DLL
LONGPI.EXE
MSVCRT.DLL
NTDLL.DLL

Well Microsoft, here's another nice mess you've gotten us into.

anta40

Quote from: Gunther on April 07, 2013, 10:22:03 AM
Unfortunately, it won't compile wit VC.

It does  ;)


Layout of data types:
=====================

Long Double (REAL10)    = 8 Bytes
Double (REAL8)          =  8 Bytes
Float (REAL4)           =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = -88796093704934495000000000000000000000000000.0000000000000000000
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.144531

Press any key to continue ...



dedndave

that's a lot of digits for a "long double"   :P

ok - 17 signifigant digits - lol
nowhere near PI

Gunther

Michael and anta40,

Quote from: anta40 on April 07, 2013, 11:41:22 AM
It does  ;)

yes, it'll compile, but the output is garbage.

Quote from: dedndave on April 07, 2013, 12:33:02 PM
that's a lot of digits for a "long double"   :P

ok - 17 signifigant digits - lol
nowhere near PI

There are no long double (REAL10) values in the pure Windows world.

Gunther
You have to know the facts before you can distort them.