Article View: pl.comp.lang.asm
Article #1935Re: Visual Studio 2008 (C++ oraz DLL w asmie) Interpolacja
From: MrokU
Date: Sat, 30 May 2009 15:59
Date: Sat, 30 May 2009 15:59
93 lines
3803 bytes
3803 bytes
cały kod w C++ wygląda tak:
Przy czym jest mało czytelny, bo chodzi tylko o wywołanie funkcji i
sprawdzenie jej działania...
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <math.h>
#define PI
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
//---------------------------------------------------------------------------
struct Element
{
double x;
double f_x;
double g_x;
double blad;
};
typedef int (__stdcall *MYPROC)(int, int);
typedef double* (__stdcall *MYPROC2)(double*);
typedef void (__stdcall *MYPROC3)(int, int, double*);
typedef void (__stdcall *MYPROC4)(int, int, double*, Element*,
double* );
MYPROC ProcAdd, ProcSub;
MYPROC2 ProcSin;
MYPROC3 ProcBeta;
MYPROC4 ProcU;
HINSTANCE hinstLib;
Element *tab;
double *c, *e, d, f;
double U (int n, int k, double beta, Element *tab) //obliczanie
wspolczynnika U - wzór 28
{
if ( k > n )
return (0.0);
else {
double fx = tab[k-1].f_x;
double cosbet = cos(beta);
double wynik = (fx + (2.0) * ( U(n, k+1, beta, tab) * cosbet ) - U
(n, k+2, beta, tab));
std::cout << "f(x) = " << fx << "\n cos(beta) = " << cosbet << "\n
wynik: " << wynik << std::endl;
return wynik;
}
}
int main(int argc, char* argv[])
{
hinstLib = LoadLibrary ("sss.dll"); //ladowanie biblioteki
if (hinstLib == NULL) //sprawdzenie, czy moduł faktycznie
został załadowany
return 1;
ProcU = (MYPROC4) GetProcAddress(hinstLib, "wspU");
if (NULL != ProcU) {
e = new (double);
tab = new Element [7];
d = PI/2;
c = &d;
tab[0].f_x = 2.0;
tab[1].f_x = 6.0;
tab[2].f_x = 10.0;
tab[3].f_x = 14.0;
tab[4].f_x = 18.0;
tab[5].f_x = 22.0;
tab[6].f_x = 24.0;
f = U (6, 1, d, tab);
(ProcU)(6, 1, c, tab, e);
}
FreeLibrary(hinstLib);
std::cout << *e << std::endl;
std::cout << f << std::endl;
system("PAUSE");
return 0;
}
Technical Details
Message-ID:
<fff60de0-8de1-4f54-bae0-960e47e1bfd3@o14g2000vbo.googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!opal.futuro.pl!news.internetia.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!o14g2000vbo.googlegroups.com!not-for-mailReferences:
<29a4a4e4-9913-4afa-ba78-63b3168b1c91@r34g2000vbi.googlegroups.com> <1800926.ER7XFjMh0G@meehow.homeip.net> <6a3c09a9-6a40-491a-8d0b-aebe884ddeb9@k38g2000yqh.googlegroups.com> <gvh3mf$a3r$1@inews.gazeta.pl> <0350c547-38dd-4ffd-9348-994f087be99e@21g2000vbk.googlegroups.com> <gvhacl$b4v$1@inews.gazeta.pl> <4cd17bbe-78cb-4b0c-8dcf-d71287d4f307@x3g2000yqa.googlegroups.com> <f5c0cab0-caff-4858-bfad-4106556e0597@r13g2000vbr.googlegroups.com> <gvrei4$l9v$1@inews.gazeta.pl> <168f208a-9218-484f-82cd-2c3dc452d48f@v4g2000vba.googlegroups.com> <gvriog$c4n$1@inews.gazeta.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!opal.futuro.pl!news.internetia.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!o14g2000vbo.googlegroups.com!not-for-mail From: MrokU <arkosmc@gmail.com> Newsgroups: pl.comp.lang.asm Subject: Re: Visual Studio 2008 (C++ oraz DLL w asmie) Interpolacja Date: Sat, 30 May 2009 08:59:30 -0700 (PDT) Organization: http://groups.google.com Lines: 95 Message-ID: <fff60de0-8de1-4f54-bae0-960e47e1bfd3@o14g2000vbo.googlegroups.com> References: <29a4a4e4-9913-4afa-ba78-63b3168b1c91@r34g2000vbi.googlegroups.com> <1800926.ER7XFjMh0G@meehow.homeip.net> <6a3c09a9-6a40-491a-8d0b-aebe884ddeb9@k38g2000yqh.googlegroups.com> <gvh3mf$a3r$1@inews.gazeta.pl> <0350c547-38dd-4ffd-9348-994f087be99e@21g2000vbk.googlegroups.com> <gvhacl$b4v$1@inews.gazeta.pl> <4cd17bbe-78cb-4b0c-8dcf-d71287d4f307@x3g2000yqa.googlegroups.com> <f5c0cab0-caff-4858-bfad-4106556e0597@r13g2000vbr.googlegroups.com> <gvrei4$l9v$1@inews.gazeta.pl> <168f208a-9218-484f-82cd-2c3dc452d48f@v4g2000vba.googlegroups.com> <gvriog$c4n$1@inews.gazeta.pl> NNTP-Posting-Host: 83.28.193.77 Mime-Version: 1.0 X-Trace: posting.google.com 1243699170 24754 127.0.0.1 (30 May 2009 15:59:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 30 May 2009 15:59:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o14g2000vbo.googlegroups.com; posting-host=83.28.193.77; posting-account=M89B8goAAADtNGu6YLcVvvVDLG2z3LY8 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; pl; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit