The MASM Forum

General => The Campus => Topic started by: shaikkareem on June 22, 2014, 01:40:14 PM

Title: help to create a .inc file
Post by: shaikkareem on June 22, 2014, 01:40:14 PM
hi every one......,

i need some help over here to create an include file that will includes standard declarations or code. i also need all information about creation of a .inc file that either contains declaration or masm code.
Title: Re: help to create a .inc file
Post by: dedndave on June 22, 2014, 01:47:26 PM
include files are plain text files
you can create one with NotePad

whatever you place in the include file will be "expanded" at the location
where the INCLUDE directive is located in the source file
Title: Re: help to create a .inc file
Post by: shaikkareem on June 22, 2014, 02:09:30 PM
Quote from: dedndave on June 22, 2014, 01:47:26 PM
include files are plain text files
you can create one with NotePad

whatever you place in the include file will be "expanded" at the location
where the INCLUDE directive is located in the source file

well i need to know the inner structure of .inc file and what i must obey to make it happened(restrictions, using opcodes etc) , i know that i can't simply place the declaration or code inside it (actually i tried but errors got). so i think i need an example...
Title: Re: help to create a .inc file
Post by: dedndave on June 22, 2014, 02:20:18 PM
the same restrictions apply as to the source file

let me guess what happened
you tried to put some code (a PROC maybe) in an INC file
and you got an error message about "blocks" or illegal segments or something of that nature

to use the code instruction set, it must lie inside a .CODE section
and, before that, you should declare the processor, model, and (for win32) OPTION CaseMap:None

here is one example

        INCLUDE    \masm32\include\masm32rt.inc       ;examine this file to see what gets expanded

        .CODE

Start:
        print   chr$('Hello World'),13,10
        inkey
        exit

        END     Start


there are many INC files in the masm32\examples folder to look at
Title: Re: help to create a .inc file
Post by: Vortex on June 22, 2014, 06:56:26 PM
Hi shaikkareem,

A similar thread :

http://masm32.com/board/index.php?topic=3304.0
Title: Re: help to create a .inc file
Post by: Gunther on June 22, 2014, 07:10:49 PM
Quote from: shaikkareem on June 22, 2014, 02:09:30 PM
well i need to know the inner structure of .inc file ...

You can use any file from masm32\include as a pattern.

Gunther
Title: Re: help to create a .inc file
Post by: nidud on June 22, 2014, 09:15:29 PM
deleted
Title: Re: help to create a .inc file
Post by: dedndave on June 22, 2014, 11:48:07 PM
i generally use project INC files for constants (EQUates), structure definitions, and macro definitions only
however, for larger projects, i have used them for data and code, as well

Hutch likes to break up his code with INC files, even for small projects
so, there are a number of programs written that way in the examples folder
Title: Re: help to create a .inc file
Post by: nidud on June 23, 2014, 01:18:30 AM
deleted
Title: Re: help to create a .inc file
Post by: jj2007 on June 23, 2014, 02:11:21 AM
Quote from: nidud on June 23, 2014, 01:18:30 AM
There are few (if any) using modules with a common include file.

Splitting our typical tiny projects into modules is hilarious in 99% of all cases. If noobs attach a hello world proggie distributed over a dozen "project" files, the archive goes straight to the recycle bin.

Splitting becomes an option if
- the modules are REALLY meant for reuse in other projects (rarely seen...)
- and you are well beyond, say, ten thousand lines of code, and your editor becomes a bit sluggish.

In all other cases, you are just complicating your life by having to manage more than one file. Simple example: Try changing the name of MyReal4 to MyReal8 over several modules.
Title: Re: help to create a .inc file
Post by: Gunther on June 23, 2014, 03:12:06 AM
Jochen,

Quote from: jj2007 on June 23, 2014, 02:11:21 AM
[Splitting becomes an option if
- the modules are REALLY meant for reuse in other projects (rarely seen...)
- and you are well beyond, say, ten thousand lines of code, and your editor becomes a bit sluggish.

That's my approach, too.

Quote from: jj2007 on June 23, 2014, 02:11:21 AM
Simple example: Try changing the name of MyReal4 to MyReal8 over several modules.

That's not complicated with search and replace.

Gunther
Title: Re: help to create a .inc file
Post by: jj2007 on June 23, 2014, 03:19:59 AM
Quote from: Gunther on June 23, 2014, 03:12:06 AMThat's not complicated with search and replace.

In VB maybe, but in QE I can't see the option "replace in all modules"...
Title: Re: help to create a .inc file
Post by: Gunther on June 23, 2014, 03:51:08 AM
Jochen,

Quote from: jj2007 on June 23, 2014, 03:19:59 AM
In VB maybe, but in QE I can't see the option "replace in all modules"...

You should indeed work with a good editor. I can recommend TEA (http://tea-editor.sourceforge.net/), which is available under several operating systems. The work is very convenient.

Gunther
Title: Re: help to create a .inc file
Post by: RuiLoureiro on June 23, 2014, 04:34:55 AM
help to create an inc file ?

;--------------------------------------
; write here files to include
;--------------------------------------
           include     \...\...\thisFile.???
           ...
;--------------------------------------
; write here your EQU/MACROS
;--------------------------------------
NEWEQU       =25

.data
;--------------------------------------
; write here some data def
;--------------------------------------
thisstring        db "this string",0
.code
;-------------------------------------
; write here some procedures
;-------------------------------------
ProcX              proc
                      ...
                       ret
ProcX              endp
;------------------------------------
; save it like ThisInc.inc
; and put this into your .asm
;
; include       ThisInc.inc
;------------------------------------

To solve the problem "replace in all ..." i wrote
an .exe that do this, but i rarely use it now.
:t

Title: Re: help to create a .inc file
Post by: nidud on June 23, 2014, 04:47:46 AM
deleted
Title: Re: help to create a .inc file
Post by: jj2007 on June 23, 2014, 07:33:35 AM
Quote from: nidud on June 23, 2014, 04:47:46 AM
All source code made by Microsoft are module based.
All programs made by Microsoft are module based.
All .DLL files in Windows are module based.

You are absolutely right - that is why we use include \masm32\include\masm32rt.inc on top of a source. Or, even better, include \masm32\MasmBasic\MasmBasic.inc

But libraries have nothing to do with the strange habit to post "projects" with a dozen tiny little include files that often consist of a single line with a PROTO. That is just silly. Why do I have to open a dozen files to understand where my fellow forum member has hidden the bug??
Title: Re: help to create a .inc file
Post by: nidud on June 23, 2014, 11:12:41 AM
deleted