News:

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

Main Menu

GNU Scientific Library

Started by jj2007, October 10, 2015, 02:43:39 PM

Previous topic - Next topic

jj2007

I am testing if there is a n00b-friendly way of installing & using the GSL. The attached proggie will show a MsgBox saying gsl_INIT error, and if you click OK, shortly after you should see another box Success: Bessel function etc...

Grateful for some tests - AV problems etc 8)

hutch--

Same result here, could not find the lib, downloaded in from Sourceforge.

TWell

#2
gsl-1.15-dev-win32 here
gsl-1.15-dev-win64 here

jj2007

#3
Quote from: hutch-- on October 10, 2015, 04:47:58 PM
Same result here, could not find the lib, downloaded in from Sourceforge.

And it worked then and showed the Bessel value, I hope?

@Tim: Thanks for the link, looks like the latest version. Much bigger, of course, and I wonder what kind of setup problems that means - XP compatible, for example? ::)

Btw what was the name of the tool in \Masm32\bin\*.exe that allowed to extract all exports from a DLL?

hutch--

JJ,

Clive's "dumppe".

Command line.

\masm32\bin\dumppe -disasm yourdll.dll > lst.txt

GoneFishing

or you may try this
QuoteLINK /DUMP /EXPORTS YOUR.DLL
or this
QuoteDUMPBIN /EXPORTS YOUR.DLL

There's one excellent  tool set : http://www.ntcore.com/exsuite.php

P.S.: GSL is well documented : GNU Scientific Library – Reference Manual

jj2007

@Hutch: That produces a 25 MB listing, not a list of exports

@GoneFishing: Both commands work fine, and produce practically the same output

In the meantime, I found my own routine, see attachment, which produces a plain listing.
Usage: GetDllExports YourDll.dll
With e.g. getdllexports C:\Windows\System32\msvcr*.dll you can get an idea what the differences between these DLLs are.

Re GSL, the *blas versions are identical but the main lib has been somewhat expanded:
1.8 -> 6.7 MB
3695 -> 4173 functions

Will reflect whether to switch to the new one or not... fight the bloat  8)

Quote from: GoneFishing on October 10, 2015, 08:04:18 PMP.S.: GSL is well documented : GNU Scientific Library – Reference Manual

Indeed :t

Currently, in the MasmBasic manual I point to another site:

include \masm32\MasmBasic\MasmBasic.inc      ; download
; libgsl.dll download: open Binaries zip, and extract libgsl.dll and libgslcblas.dll to \masm32\MasmBasic\GnuScLib\DLL
; define the gsl function(s) you want to use with the syntax of the
GNU Scientific Library Reference
gslvar      int gsl_rng_default()
gsl      double gsl_stats_mean (const double data[], size_t stride, size_t n)
gsl      double gsl_stats_variance (const double data[], size_t stride, size_t n)
gsl      double gsl_stats_sd (const double data[], size_t stride, size_t n)
... etc ...


The two pages look almost identical (one has a horizontal line, the other doesn't ::)). Again I will have to test which version works better.

hutch--

JJ,

Just open the file in a text editor, you get the PE header then all imports and exports.

jj2007

Quote from: hutch-- on October 10, 2015, 10:42:26 PMJust open the file in a text editor, you get the PE header then all imports and exports.

Sure. This is what I wanted (my tool, 108kB):
_gsl_sf_bessel_amp_phase_bm0_cs
_gsl_sf_bessel_amp_phase_bm1_cs
_gsl_sf_bessel_amp_phase_bth0_cs
_gsl_sf_bessel_amp_phase_bth1_cs
gsl_acosh
gsl_asinh
gsl_atanh
...


This is what you get from dumppe (50MB, scroll down a little bit to find gsl_acosh):
libgsl-0.dll                       (hex)           (dec)

.EXE size (bytes)                    490            1168
Minimum load size (bytes)            450            1104
Overlay number                         0               0
Initial CS:IP                  0000:0000
Initial SS:SP                  0000:00B8             184
Minimum allocation (para)              0               0
Maximum allocation (para)           FFFF           65535
Header size (para)                     4               4
Relocation table offset               40              64
Relocation entries                     0               0

Portable Executable starts at                 80
Signature                               00004550 (PE)
Machine                                     014C (Intel 386)
Sections                                    0014
Time Date Stamp                         4EAECA7E Mon Oct 31 17:19:10 2011
Symbol Table                            005EAC00
Number of Symbols                       00004D99
Optional header size                        00E0
Characteristics                             2106
Executable Image
Line numbers stripped
32 bit word machine
DLL
Magic                                       010B
Linker Version                              2.21
Size of Code                            00147A00
Size of Initialized Data                001F6200
Size of Uninitialized Data              00000400
Address of Entry Point                  00001058
Base of Code                            00001000
Base of Data                            00149000
Image Base                              6EEC0000
Section Alignment                       00001000
File Alignment                          00000200
Operating System Version                    4.00
Image Version                               1.00
Subsystem Version                           4.00
reserved                                00000000
Image Size                              005F5000
Header Size                             00000600
Checksum                                00667AC8
Subsystem                                   0003 (Console)
DLL Characteristics                         0000
Size Of Stack Reserve                   00200000
Size Of Stack Commit                    00001000
Size Of Heap Reserve                    00100000
Size Of Heap Commit                     00001000
Loader Flags                            00000000
Number of Directories                   00000010

Directory Name                          VirtAddr  VirtSize
--------------------------------------  --------  --------
Export                                  001CA000  00023C72
Import                                  001EE000  0000117C
Resource                                00000000  00000000
Exception                               00000000  00000000
Security                                00000000  00000000
Base Relocation                         001F2000  0000A238
Debug                                   00000000  00000000
Decription/Architecture                 00000000  00000000
Machine Value (MIPS GP)                 00000000  00000000
Thread Storage                          001F1000  00000018
Load Configuration                      00000000  00000000
Bound Import                            00000000  00000000
Import Address Table                    001EE300  0000029C
Delay Import                            00000000  00000000
COM Runtime Descriptor                  00000000  00000000
(reserved)                              00000000  00000000

Section Table
-------------
01  .text    Virtual Address         00001000
Virtual Size            00147840
Raw Data Offset         00000600
Raw Data Size           00147A00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         60300060
Code
Initialized Data
4    Byte Align
Executable
Readable

02  .data    Virtual Address         00149000
Virtual Size            0000CA80
Raw Data Offset         00148000
Raw Data Size           0000CC00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0600040
Initialized Data
32   Byte Align
Readable
Writeable

03  .rdata  Virtual Address         00156000
Virtual Size            0002E8E0
Raw Data Offset         00154C00
Raw Data Size           0002EA00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         40600040
Initialized Data
32   Byte Align
Readable

04  /4      Virtual Address         00185000
Virtual Size            00043A00
Raw Data Offset         00183600
Raw Data Size           00043A00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         40300040
Initialized Data
4    Byte Align
Readable

05  .bss    Virtual Address         001C9000
Virtual Size            00000220
Raw Data Offset         00000000
Raw Data Size           00000000
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0600080
Uninitialized Data
32   Byte Align
Readable
Writeable

06  .edata  Virtual Address         001CA000
Virtual Size            00023C72
Raw Data Offset         001C7000
Raw Data Size           00023E00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         40300040
Initialized Data
4    Byte Align
Readable

07  .idata  Virtual Address         001EE000
Virtual Size            0000117C
Raw Data Offset         001EAE00
Raw Data Size           00001200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0300040
Initialized Data
4    Byte Align
Readable
Writeable

08  .CRT    Virtual Address         001F0000
Virtual Size            00000018
Raw Data Offset         001EC000
Raw Data Size           00000200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0300040
Initialized Data
4    Byte Align
Readable
Writeable

09  .tls    Virtual Address         001F1000
Virtual Size            00000020
Raw Data Offset         001EC200
Raw Data Size           00000200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0300040
Initialized Data
4    Byte Align
Readable
Writeable

0A  .reloc  Virtual Address         001F2000
Virtual Size            0000A238
Raw Data Offset         001EC400
Raw Data Size           0000A400
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42300040
Initialized Data
4    Byte Align
Discardable
Readable

0B  /14      Virtual Address         001FD000
Virtual Size            00003F50
Raw Data Offset         001F6800
Raw Data Size           00004000
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0C  /29      Virtual Address         00201000
Virtual Size            0000033C
Raw Data Offset         001FA800
Raw Data Size           00000400
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0D  /45      Virtual Address         00202000
Virtual Size            00000452
Raw Data Offset         001FAC00
Raw Data Size           00000600
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0E  /61      Virtual Address         00203000
Virtual Size            001A86FA
Raw Data Offset         001FB200
Raw Data Size           001A8800
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0F  /73      Virtual Address         003AC000
Virtual Size            0002FE92
Raw Data Offset         003A3A00
Raw Data Size           00030000
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

10  /87      Virtual Address         003DC000
Virtual Size            00059C5E
Raw Data Offset         003D3A00
Raw Data Size           00059E00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

11  /99      Virtual Address         00436000
Virtual Size            00000450
Raw Data Offset         0042D800
Raw Data Size           00000600
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42300040
Initialized Data
4    Byte Align
Discardable
Readable

12  /112    Virtual Address         00437000
Virtual Size            000036FD
Raw Data Offset         0042DE00
Raw Data Size           00003800
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

13  /123    Virtual Address         0043B000
Virtual Size            0019E76C
Raw Data Offset         00431600
Raw Data Size           0019E800
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

14  /134    Virtual Address         005DA000
Virtual Size            0001AD08
Raw Data Offset         005CFE00
Raw Data Size           0001AE00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable


Exp Addr Hint   Ord Export Name by libgsl-0.dll - Mon Oct 31 17:19:09 2011
-------- ---- ----- ---------------------------------------------------------
0012B04C    0     1 GSL_MAX_DBL
0012B02C    1     2 GSL_MAX_INT
0012B084    2     3 GSL_MAX_LDBL
0012B068    3     4 GSL_MIN_DBL
0012B03C    4     5 GSL_MIN_INT
0012B0A0    5     6 GSL_MIN_LDBL
0012B0F4    6     7 GSL_MODE_PREC
00177E40    7     8 _gsl_sf_bessel_amp_phase_bm0_cs
00177E00    8     9 _gsl_sf_bessel_amp_phase_bm1_cs
00177E20    9    10 _gsl_sf_bessel_amp_phase_bth0_cs
00177DE0    A    11 _gsl_sf_bessel_amp_phase_bth1_cs
0012B338    B    12 gsl_acosh
0012B438    C    13 gsl_asinh
0012B59C    D    14 gsl_atanh

;)

TWell

In this forum many things are done in hard way (stupid).
I have seen easy way to do things in PellesC forum.

dedndave

we appreciate your vote of confidence, Tim - lol

although, it makes me wonder why you are here

rrr314159

Quote from: TWellIn this forum many things are done in hard way (stupid).

- reminds me of my favorite (slightly risque) bumper sticker,

"Assembly programmers do it the hard way"

Perhaps it should have a coda, "... because they're stupid!" That's a good idea, women (I've noticed) find stupidity very attractive :biggrin:
I am NaN ;)

TWell

To learn something from experts, like you.
And what's wrong to use program like this: http://vortex.masmcode.com/files/dll2defV11.zip

hutch--

 :biggrin:

JJ,

If you don't want the disassembly, don't add the command line option "-disasm".

jj2007

#14
Quote from: TWell on October 10, 2015, 06:03:36 PM
gsl-1.15-dev-win32 here

Thanks for the hint, Tim. I've made it the new default in MasmBasic version 11 October. You can override it with gsl_OldVersion=1.

Quote from: TWell on October 11, 2015, 02:24:26 AM
In this forum many things are done in hard way (stupid).
I have seen easy way to do things in PellesC forum.

That is an interesting observation. Of course, we are struggling to make things easier:
2.1 An Example Program (from the GSL manual)

The following short program demonstrates the use of the library by computing the value of the Bessel function J_0(x) for x=5,

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int
main (void)
{
  double x = 5.0;
  double y = gsl_sf_bessel_J0 (x);
  printf ("J0(%g) = %.18e\n", x, y);
  return 0;
}

The output is shown below, and should be correct to double-precision accuracy,2

J0(5) = -1.775967713143382920e-01

The steps needed to compile this program are described in the following sections.

( etc etc ... there it gets complicated ...)


Now the MasmBasic equivalent:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  gsl double gsl_sf_bessel_J0 (double x)     ; double x means a pointer to a REAL8 is required
  Init
  Print Str$("Bessel function for a value of 5 = %Jf\n", gsl_sf_bessel_J0(FP8(5.0)))
EndOfCode


Output:
Bessel function for a value of 5 = -0.1775967713143382920

Compiling instructions see Masm32: What you absolutely must know to get started, including step 6

So what would you suggest to make it less hard?

Just for fun, another example - a graphical representation of a Bessel function:

GuiParas equ "Bessel function", x20, y20, w1200, h700
include \masm32\MasmBasic\Res\MbGui.asm
  gsl double gsl_sf_bessel_J0(double x)   ; see GSL manual
  SetGlobals fct:REAL8
  gsl_INIT
  Dim Bessel1() As REAL8
  xor ecx, ecx            ; array index
  For_ fct=-10.0 To 40.0 Step 0.05
      SetFloat Bessel1(ecx)=gsl_sf_bessel_J0(fct)
      inc ecx
  Next
Event Paint
  ArrayPlot hWnd, RgbCol(20, 255, 240)      ; define canvas and background colour
  ArrayPlot Bessel1()
  ArrayPlot exit, "GSL: Regular cylindrical Bessel function of zeroth order"
GuiEnd