News:

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

Merging multiple .asm files

Started by FlySky, April 29, 2012, 12:42:53 PM

Previous topic - Next topic

FlySky

Hey guys,

I always have problems when merging multiple .DATA sections or .CODE section.

I am creating a pretty big project which is a DLL.

The DLL has the section declarations:

.CONST
.DATA
.DATA?
.CODE

Now I am using several .asm files which also have:
.DATA
.CODE

Is it possible to merge them nicely. With that I mean when I include the new .asm file at the end of the .DATA section, it kinda messes up my CODE section
And the second code section is thrown above the first one, while I want it to be at the end of the .code section of the dll?
Is there any compiler settings I need to change to do that?

uosunsetter


dedndave

first thing that comes to mind.....

what do you have in the CONST section  ?

as for controlling placement - you could use ORG - seems a bit messy
the assembler places things in the order they appear, unless it's forced to do otherwise

another way - seperate the data from the code in the "sub-files"
then, you can insert them into the main file where you want to by controlling the placement of the INCLUDE directives
the assembler expands INCLUDE'ed files at the location of the directive

this won't help with library files, though

hutch--

The thing that will cause you problems is the placement of your prototypes. If you observe the discipline of having your own header file that you place the include file lines in BEFORE your code and data sections you will solve most of these problems. It is common in ASM and C files to have multiple source files and with MASM you can also use inserted blocks of .DATA or .DATA?. Something like this.


.data
  item db "12345678",0
.code
  more instructions etc ....


What you are trying to avoid is forward referencing, calling something (code or data) before its prototype has been read by the assembler or calling a data block before it has been read by the assembler.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

data alignment might be an issue, also
i usually put larger types before smaller ones:

dwords
words
bytes

the dwords are aligned by 4, the words by 2, and the byte data, including most strings, are unaligned

if you have to keep aligning dwords, your data area grows   :P

NoCforMe

Quote from: dedndave on April 30, 2012, 01:34:44 AM
data alignment might be an issue, also
i usually put larger types before smaller ones:

dwords
words
bytes

Hey, I do the exact same thing! (Great minds think alike???)