News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Multimodule project...

Started by LordAdef, March 29, 2017, 04:23:35 PM

Previous topic - Next topic

LordAdef

Ok, here it comes a very stupid question........ brace for impact ::)

I swear I looked around but can´t make this thing work. So I gave up and am asking for help.

I feel ridiculous because I´ve done this many times in C.

I created this module and want to use it in my main prog. The secondary asm file has 2 macros.

Main. asm
decomp.inc
decomp.asm

I want to keep it as asm, not a lib.
Many sorries and thanks in advance. Please don´t laugh :eusa_dance:

zip attached.



hutch--

You can do both with no problems, include an asm source file as long as you include it in the .CODE section OR append an object module to the linker command line and link it into the app. A library is just a collection of object modules and it works the same way. Code that has macros in it usually needs to be included as source code as you cannot directly access a macro in compiled code.

jj2007

Attached a version that assembles at least.

In addition to what Hutch wrote above: You need to watch the right order. The include statement says simply "insert the whole file here". Same for a macro call: It inserts code, that's all.

In particular, check if you are in the right section: .code for any macro call and any include that contains a proc.

There is also a template for a "real" static library, see File/New Masm source:
Create a library   demo showing how to create a static library

Btw for small to medium sized projects, splitting them in pieces is not a good idea. I had to invest time to find out where the various bits and pieces are hidden. The RichMasm editor, for example, has a single 18000+ lines source, plus a few bmp files. Horrible for a C/C++ coder, but splitting it would be a nightmare for bug chasing. As a single file, it works just fine: It loads in half a second, it builds in one second. And all symbols (variables, procs, macros) are immediately visible in that little listbox, no need to open a dozen files desperately trying to find MyProc ;)

mineiro

The program 'lotus123' have been coded all in assembly language by using modular project.
An old book from "Peter Norton & John Socha" to ms-dos tells a bit about modular programming. The modular programming are just rules to be followed, like sistematic thinking.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

TWell

#4
using common header file like \masm32\include\masm32rt.inc usually helps.
in decomp.asm extern Decomp :BYTE
in main.asm public Decomp
and then ml.exe main.asm decomp.asm -link -subsystem:windows can use link.exe to link obj-files to target exe.

EDIT:
as jj2007 informed:
in decomp.inc  EXTERNDEF Decomp :BYTE

jj2007

Quote from: TWell on March 29, 2017, 11:39:50 PM
in decomp.asm extern Decomp :BYTE
in main.asm public Decomp

Recommended syntax is ExternDef:BYTE in both files. See MSDN and, more explicitly, AoA:
QuoteWith externdef there really is no need to use the public or extern statements unless you feel somehow compelled to do so

The bigger problem was that Decomp was not defined anywhere, so it assembled but the linker choked.

LordAdef

Thanks everyone, that was helpful.

Now I got a bit intrigued..
I included "include decomp.asm" within my code section. This is fine for what I need.
None of the 3 files needed the "EXTERNDEF Decomp :BYTE"

But it doesn´t run unless I use Johen´s "Decomp db ?". I´m intrigued by the fact it only work with "D", "decomp" fails. In fact I have no idea what the reason for this entire line.

jj2007

Quote from: LordAdef on March 30, 2017, 06:03:06 PMIn fact I have no idea what the reason for this entire line.

Well... you should know, it's your own code:

    LineLenght = 160 ; Lenght of line is fixed to 160
   
      mov   edi, offset Decomp
:biggrin:

Btw it's length, not lenght

LordAdef

wow... it's a new mystery then... this Decomp was discarded in the new file I'm working on. And still, it is complaining, although the code is working... My guess is I forgot to erase that line and am overwriting edi with my alloc. I will check that tomorrow.

Thanks for the Length too! I misspelled and kept repeating it...