News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ever experienced "code rot"?

Started by tetsu-jp, March 31, 2009, 06:57:44 PM

Previous topic - Next topic

hutch--

tetsu,

The MASM32 Project is 32 bit only, it cannot be used to produce 64 bit modules. If you get the right VC version it has ML64 which can build the 64 bit object modules that will link into a 64 bit C/C++ application. Now interfacing with VB is a different matter, it is not my field but we have members here who have done this type of work.\

The object module format for 64 bit ML64 is not MSIL, it is native 64 bit code that can be linked into other Microsoft native 64 bit code.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

tetsu-jp

as it looks VB can interface to unmanaged DLL.

what you see on the screenshot is wrong code, but generally it can be done that way.


all i need to do is to create a DLL (using MASM32)!
how can i do it? HELP!

also i am downloading the WINDOWS SDK (at 1800kbps).

my idea would be to wrap modules iinto 32-bit DLLs, and let the VB application call them, the CPU will run the code in compatibility mode. it is indeed to use a 64bit CPU in 32bit mode, but for many applications, should be OK.

VB can also be switched from x86 to x64 (advanced compiler options).

I've found this for DLL: http://www.jorgon.freeserve.co.uk/TestbugHelp/Dynamic.htm#dll3
should it be possible to create MASM32 DLL only with this resource?

I'd also be able to use WIN32 ASM via C++ (but that's technology which was available ten years ago).

So i want to use the .NET framework via VB, and link ASM code via DLL.

all what's needed is a way to set pixels! and this can be done via GDI+ (which can be provided by .NET framework to VB).

ToutEnMasm

Quote
all i need to do is to create a DLL (using MASM32)!
how can i do it? HELP!

Not very difficult,but there is some details to know.
Below is a skeletton source file,just add proc in it,that all
Compile it with ml,as others thinks
then link
Quote
\masm32\bin\link /NOLOGO /DEBUG /DLL /DEF:dll.def /SUBSYSTEM:WINDOWS /LIBPATH:\masm32\lib dll.obj
dll.def is a text file that define the name of the dll and the exported function.
sample of contents
LIBRARY skeleton
EXPORTS TestHello

Then you can use the library created by the linker to call the functions or link dynamically (getprocadress) to them.

Quote
.386
.model flat,stdcall
option casemap:none
;--------------------------------------------
;      extrait du .def
;LIBRARY skeleton       new name for the dll
;EXPORTS TestHello      Export of this function
;-------------------------------------------
;Compilation ,assembler normalement,lier une dll    
;--------------------------------------------

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
AppName db "DLL Skeleton",0
HelloMsg db "Function of the dll retrieved by GetProcAddress",0
LoadMsg db "The DLL is loaded",0
UnloadMsg db "The DLL is unloaded",0
ThreadCreated db "A thread is created in this process",0
ThreadDestroyed db "A thread is destroyed in this process",0
.code
         ;le end DllEntry fixe le nom du proc appelé
         ;pour initialiser la dll

DllEntry proc hInstance:HINSTANCE, reason:DWORD, reserved1:DWORD
   .if reason==DLL_PROCESS_ATTACH
      invoke MessageBox,NULL,addr LoadMsg,addr AppName,MB_OK
   .elseif reason==DLL_PROCESS_DETACH
      invoke MessageBox,NULL,addr UnloadMsg,addr AppName,MB_OK
   .elseif reason==DLL_THREAD_ATTACH
      invoke MessageBox,NULL,addr ThreadCreated,addr AppName,MB_OK
   .else        ; DLL_THREAD_DETACH
      invoke MessageBox,NULL,addr ThreadDestroyed,addr AppName,MB_OK
   .endif
   mov  eax,TRUE
   ret
DllEntry Endp
TestHello proc
   invoke MessageBox,NULL,addr HelloMsg,addr AppName,MB_OK
   ret   
TestHello endp
End DllEntry      ;

GregL

Quote from: tetsu-jpI have searched the computer for all instances of ML. there is no such program supplied with VS.
neither any version of MASM.

Which version of Visual Studio are you using?  Visual C++ 2008 SP1 Express Edition, at the link I posted above, includes ml.exe.  The Standard version may not include it, but the Professional and above versions do.  They got so many complaints about Express Edition not including it I would think they would have put it in SP1 for Standard too.


tetsu-jp

there are ML and ML64, in the VC folders.

I have VS2008 Standard Edition, 64bit, with SP1 installed.
Also now i have downloaded the Windows 7 SDK.

I guess the files just did not show up via explorer search.

however, C# and VB directories do not include assemblers.

would the GoASM be a good software to start with 64 bit assembly (eventually use the ML64)?

eventually i want to build for x86, and x64 (the VB program), and then call either 32bit, or 64bit code,
and compare performance.

for now I'd be happy if the 32bit DLL code works!

******************

why the topic "code rot"?

I have lost many projects, over the years, and that's not so good. sometimes I've deleted the stuff myself (and after years, regretted it), sometimes I've lost the computers, and there are cases when I can't maintain the source anymore (for instance, my early RISC ASM sources).

I write differently now, and try to make the sources more readable.

there are certain small C and ASM sources*, for WINUAE emulated machine, better say, I have also lost them,
and after years, ended up with multiple copies of WINUAE at different places, none of them including my source codes!

so it occurs again and again. I am now adding all my sources to SKYDRIVE, and hope they are preserved for the future years.

*years 2004 to 2006.

GregL

Quotehowever, C# and VB directories do not include assemblers.

Nope, it only comes with VC.

Quote from: tetsu-jpwould the GoASM be a good software to start with 64 bit assembly (eventually use the ML64)?

Yes, if you are going the assembly only route.  Otherwise I would say you should use VC and ML64, they are made to work together.

A suggestion, if you are going to use assembly, forget about VB and C#.


Vortex

tetsu-jp,

If you have the Masm32 package installed, you will find there a DLL tutorial :

\masm32\tutorial\dlltute

tetsu-jp

Quote from: Greg on April 01, 2009, 06:53:28 PM
A suggestion, if you are going to use assembly, forget about VB and C#.

1. inline ASM is not supported on x64 platform (only when switching to x86 via compiler option).

forget about VB?

It can call just any DLL, and i could write the DLL in COBOL, FORTRAN, BCPL*, LOGO, etc.

I've read somewhere you are 50 years, and i am the younger person, so i must only write friendly text.

Just, I do not get the content of your statement.

I have successfully used inline assembly in C++, but that's not what i want (to use MFC technology).

Also i do not think you experienced problems like me, loosig source codes, so I really don't get it.

*not sure if it can create DLL, it's a hard language

tetsu-jp

Quote from: Vortex on April 01, 2009, 07:06:11 PM
tetsu-jp,

If you have the Masm32 package installed, you will find there a DLL tutorial :

\masm32\tutorial\dlltute

yes i have found this today, thanks.

5 years ago i managed to write a small program in MASM32, without any guidance...
however it looks some guidance can be helpful.

also I have created the skeletion DLL from the source shown above, and will now try to call it from VB.

GregL

tetsu-jp,

It was just a suggestion, you can do whatever you'd like.


tetsu-jp

Yes, since it is twenty years that i am involved with programming,
I ask how you found such a statement, or why this won't be any good.

One time or the other I'd have my thoughts about OOP and C++ as well.

If i write the subjects that i want to implement, will you write a similar statement?
maybe that it would not make sense, or, "Godd Luck"?
I've got many good-luck wishes for my projects (over the years),
but this never was very productive (for instance, in terms of features).

last not least, do you use modern VB at all?