🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.asm
Article #1916

Re: Visual Studio 2008 (C++ oraz DLL w asmie) Interpolacja

#1916
From: MrokU
Date: Mon, 25 May 2009 15:23
121 lines
4235 bytes
To może tak:
wkleję tutaj kod, który mi działa, ale zapewne wiele rzeczy jest
nieoptymalnie, niefajnie, etc.
Czy ktoś może rzucić na to okiem i powiedzieć co i jak robić lepiej?
pozdrawiam.


-----------------------------------------------------------------------------------------------------------------
KOD DLL:
.586
.387

.MODEL FLAT, STDCALL

OPTION CASEMAP:NONE

INCLUDE    .\masm32\include\windows.inc;
INCLUDE    .\masm32\include\user32.inc
INCLUDE    .\masm32\include\kernel32.inc
INCLUDELIB .\masm32\lib\user32.lib
INCLUDELIB .\masm32\lib\kernel32.lib

.DATA
.CODE

DllEntry PROC hInstance:HINSTANCE, reason:DWORD, reserved1:DWORD
    mov  eax, TRUE
    ret
DllEntry ENDP

;***************************************************************
;******	Procedura testowa ***** dodawanie

sumuj PROC a: DWORD , b: DWORD
	pushad
	mov eax, a
	add b, eax
	popad
	mov eax, b
	ret            ;koniec funkcji
sumuj ENDP

;***************************************************************
;******	Procedura testowa ***** odejmowanie

odejmuj PROC a: DWORD , b: DWORD
	pushad
	mov eax, a
	sub b, eax
	popad
	mov eax, b
	ret            ;koniec funkcji
odejmuj ENDP

;***************************************************************
;******	Procedura testowa ***** HARDCORE - sinus()

sinus PROC kat:DQ;, wynik:PTR
	pushad
	finit
	fld	kat			; wczytanie zmiennej do rejestru st0
	fsin
	fst kat
	popad
	mov eax, kat
	ret            ;koniec funkcji
sinus ENDP

END DllEntry


-----------------------------------------------------------------------------------------------------------------
KOD C++:

#include <windows.h>
#include <stdio.h>
#include <iostream>

#define PI
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
//---------------------------------------------------------------------------

typedef int (__stdcall *MYPROC)(int, int);
typedef float (__stdcall *MYPROC2)(float);

MYPROC ProcAdd, ProcSub;
MYPROC2 ProcSin;
HINSTANCE hinstLib;
int a, b;
float d;

int main(int argc, char* argv[])
{
	hinstLib = LoadLibrary ("DLLint.dll");							//ladowanie biblioteki
	if (hinstLib == NULL)												//sprawdzenie, czy moduł faktycznie
został załadowany
		return 1;

	ProcAdd = (MYPROC) GetProcAddress(hinstLib, "sumuj");
	if (NULL != ProcAdd)
		a = (ProcAdd)(9,2);

	ProcSub = (MYPROC) GetProcAddress(hinstLib, "odejmuj");
	if (NULL != ProcAdd)
		b = (ProcSub)(2,9);

	ProcSin = (MYPROC2) GetProcAddress(hinstLib, "sinus");
	if (NULL != ProcAdd)
		d = (ProcSin)(PI / 6);	// sinus 30 stopni

	FreeLibrary(hinstLib);
	std::cout << a << std::endl;
	std::cout << b << std::endl;
	std::cout << d << std::endl;

	system("PAUSE");
	return 0;
}

-----------------------------------------------------------------------------------------------------------------
pozdrawiam.
Technical Details
Message-ID: <1c78221a-e9ea-4795-ac7b-2b3d014f556b@r33g2000yqn.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!feed.news.interia.pl!news.nask.pl!news.nask.org.pl!goblin1!goblin.stu.neva.ru!postnews.google.com!r33g2000yqn.googlegroups.com!not-for-mail
References: <29a4a4e4-9913-4afa-ba78-63b3168b1c91@r34g2000vbi.googlegroups.com> <gvb3au$aha$1@inews.gazeta.pl> <gvcsv7$9li$1@inews.gazeta.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!feed.news.interia.pl!news.nask.pl!news.nask.org.pl!goblin1!goblin.stu.neva.ru!postnews.google.com!r33g2000yqn.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: Mon, 25 May 2009 08:23:00 -0700 (PDT)
Organization: http://groups.google.com
Lines: 127
Message-ID: <1c78221a-e9ea-4795-ac7b-2b3d014f556b@r33g2000yqn.googlegroups.com>
References: <29a4a4e4-9913-4afa-ba78-63b3168b1c91@r34g2000vbi.googlegroups.com>  <gvb3au$aha$1@inews.gazeta.pl> <gvcsv7$9li$1@inews.gazeta.pl>
NNTP-Posting-Host: 83.230.1.175
Mime-Version: 1.0
X-Trace: posting.google.com 1243264981 24897 127.0.0.1 (25 May 2009 15:23:01 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 25 May 2009 15:23:01 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: r33g2000yqn.googlegroups.com; posting-host=83.230.1.175;  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