Author Topic: GNU Scientific Library  (Read 3284 times)

jj2007

  • Member
  • *****
  • Posts: 7641
  • Assembler is fun ;-)
    • MasmBasic
GNU Scientific Library
« on: October 10, 2015, 02:43:39 PM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 4875
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GNU Scientific Library
« Reply #1 on: October 10, 2015, 04:47:58 PM »
Same result here, could not find the lib, downloaded in from Sourceforge.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

TWell

  • Member
  • ****
  • Posts: 748
Re: GNU Scientific Library
« Reply #2 on: October 10, 2015, 06:03:36 PM »
gsl-1.15-dev-win32 here
gsl-1.15-dev-win64 here
« Last Edit: October 11, 2015, 09:58:53 PM by TWell »

jj2007

  • Member
  • *****
  • Posts: 7641
  • Assembler is fun ;-)
    • MasmBasic
Re: GNU Scientific Library
« Reply #3 on: October 10, 2015, 07:36:46 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?
« Last Edit: October 10, 2015, 09:02:12 PM by jj2007 »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4875
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GNU Scientific Library
« Reply #4 on: October 10, 2015, 07:55:35 PM »
JJ,

Clive's "dumppe".

Command line.
Code: [Select]
\masm32\bin\dumppe -disasm yourdll.dll > lst.txt
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

GoneFishing

  • Member
  • ****
  • Posts: 958
  • Gone fishing
Re: GNU Scientific Library
« Reply #5 on: October 10, 2015, 08:04:18 PM »
or you may try this
Quote
LINK /DUMP /EXPORTS YOUR.DLL
or this
Quote
DUMPBIN /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

  • Member
  • *****
  • Posts: 7641
  • Assembler is fun ;-)
    • MasmBasic
Re: GNU Scientific Library
« Reply #6 on: October 10, 2015, 08:55:46 PM »
@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)

P.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--

  • Administrator
  • Member
  • ******
  • Posts: 4875
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GNU Scientific Library
« Reply #7 on: October 10, 2015, 10:42:26 PM »
JJ,

Just open the file in a text editor, you get the PE header then all imports and exports.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 7641
  • Assembler is fun ;-)
    • MasmBasic
Re: GNU Scientific Library
« Reply #8 on: October 11, 2015, 01:23:29 AM »
Just 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):
Code: [Select]
_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):
Code: [Select]
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

  • Member
  • ****
  • Posts: 748
Re: GNU Scientific Library
« Reply #9 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.

dedndave

  • Member
  • *****
  • Posts: 8741
  • Still using Abacus 2.0
    • DednDave
Re: GNU Scientific Library
« Reply #10 on: October 11, 2015, 05:31:50 AM »
we appreciate your vote of confidence, Tim - lol

although, it makes me wonder why you are here

rrr314159

  • Member
  • *****
  • Posts: 1382
Re: GNU Scientific Library
« Reply #11 on: October 11, 2015, 06:32:52 AM »
Quote from: TWell
In 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

  • Member
  • ****
  • Posts: 748
Re: GNU Scientific Library
« Reply #12 on: October 11, 2015, 06:33:20 AM »
To learn something from experts, like you.
And what's wrong to use program like this: http://vortex.masmcode.com/files/dll2defV11.zip

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4875
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GNU Scientific Library
« Reply #13 on: October 11, 2015, 08:46:24 AM »
 :biggrin:

JJ,

If you don't want the disassembly, don't add the command line option "-disasm".
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 7641
  • Assembler is fun ;-)
    • MasmBasic
Re: GNU Scientific Library
« Reply #14 on: October 11, 2015, 10:15:02 AM »
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.

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)

Code: [Select]
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
« Last Edit: October 11, 2015, 12:34:25 PM by jj2007 »