hi,
i am just starting to learn assembly and the current project i am trying right now is a dll for mandelbrot set. I have written a program in vb that does the mandelbrot picture which includes zooming and all that. now i watn to translate the calculation of the mandelbrot set itself into asm and then call the procedure from vb (just to start with). i have the high-level algorithm which i understand fully and i know how to create simple dlls in asm (masm32 in this case) as well as how to pass parameters to that dll using masm32's sintax

ProcName proc Var1:DWORD, Var2:DWORD etc.

now the first problem among many is how to pass values other than dword. for this particular case i need to pass two real numbers and two dwords. the real numbers would be double precision floating point number ie. 8 byte. for now i have tried just to use single precion number (4 byte) which are the same size a dword. i made a little procedure that simply returns the one parameter that it was given:

mov eax, TheParamter
ret

if i set the parameter to be a DWORD or a REAL4 and i pass an integer (VB's Long) to the procedure, it returns the same integer which is good. if i pass a single precision number (VB's Single) to the same procedure it returns something completely different. so the first question is how to pass real numbers to my dll, and more precisely how to pass double precision reals.

secondly the procedure for the mandlebrot has to calculate a number of things inside a loop. i can construct a loop using masm32's higher level sintax and even learned how to use proper assembly to construct loops. inside the loop there are several calculations involving real numbers. so far i've been using the FpuLib.lib that came with masm32 v8. as soon as the first line of calculation is encountered the dll throus up a general protection fault. obviously something is wrong with my code. as far as i can see i need to convert the numbers passed to the dll procedure to the REAL10 numbers used by this fpulib and the fpu itself. there is a procedure in the library that allows the conversion however i still can't seem to do it (it always gives me a gpf). i can probably workout how to get that library to work with my algorithm although any advise would certainly be helpful.

is there a debugger that would allow me to just dissassemble the dll code while the program is running (by the way vb only links to the dll at run time )?
Posted on 2003-04-28 06:26:16 by Dimitrius
if i set the parameter to be a DWORD or a REAL4 and i pass an integer (VB's Long) to the procedure, it returns the same integer which is good. if i pass a single precision number (VB's Single) to the same procedure it returns something completely different. so the first question is how to pass real numbers to my dll, and more precisely how to pass double precision reals.
The first thing i would suggest is to pass your numbers to the dll ByRef, this means your asm dll will receive a *pointer* to the number (which is a DWORD). Once in the asm dll you can work out what to do with the number being pointed to. Also, by using ByRef it means you do not have to explicitly return a value, because the value(s) you passed in are altered directly. However, i am not an expert on how the numbers are represented in memory, or on the various uses of the FPU, so someone else can answer that part of the question.


is there a debugger that would allow me to just dissassemble the dll code while the program is running
Yes, but be aware that you will have to run the VB app as an exe to do this, if you run it from the IDE then a debugger is already attached to the process.


)?
No, it is called "dynamic linking" :) You are probably being confused by the terms "early binding" and "late binding", these terms relate to how you declare and use your COM objects.
Posted on 2003-04-28 06:42:28 by sluggy