The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: redskull on May 30, 2006, 01:08:23 AM

Title: Linking VS Including
Post by: redskull on May 30, 2006, 01:08:23 AM
I know the 'official' old-school style of modularizing code involes seperatly assembling them, defining procedures and variables global with EXTERN and whatnot, using make files, linking them together; the whole three ring circus.  But lately, i've gotten into a bad habit of just INCLUDING seperate files with the procedures written in them, saving me the hassle of determining scope and assembling everything a la carte.  Other than longer assembly times (not that it's much of a factor these days) and a bad chastizing from old programming teachers, is there any specifically wrong with doing it this way?  It just makes everything SO much easier

alan
Title: Re: Linking VS Including
Post by: Synfire on May 30, 2006, 03:01:41 AM
I generally see no problem with this. One exception is if you don't use PROC/ENDP and you define a named label, then that label is global and can cause errors if you use that label name again. This also goes for variables, etc. Also a good reason not to use this method is in the case of custom equates, if both sources use a different value for the equates, then you are either going to get an error (in the case of most assemblers) or it will be redefined at a possibly invalid time (in the case of assemblers like MPASM which allows equate redefinitions). Other than that, I can't think of any other reason it shouldn't be done. I personally use LIB's for routines and MACRO's for snipplets, both held in their own includes.
Title: Re: Linking VS Including
Post by: hutch-- on May 30, 2006, 03:18:19 AM
Red,

It has a bit to do with the size of the project, on small to medium sized projects it does not matter much but if you are building something large and complex, the modular approach starts to make things a lot easier and you can easily build complete modules into your own library. It also helps if you write reusable code so you can use that library in another project.
Title: Re: Linking VS Including
Post by: zcoder on May 30, 2006, 08:36:21 PM
The modular approach is alot better to use, you can create larger programs and still keep
your app managable. the problem is with assembling all those files into OBJ's then linking.

I made a IDE to do all this with one click to assemble a project, I made it mimic VC++
but for assembly.

You can give it a try at: www.masmwizard.com/about.php

otherwise you can make bat files to do this for you, for each project.

Zcoder....