Hi,

Dunno how to explain it exactly... I'm finding that my code became too big to be readable, so i'm trying to do "modular programming" for the first time. Here's what i'm doing:

I have a main Asm file with the main part of the code, but each time i have a proc (other than winmain) i have tryed to do another asm file (so each proc will be in a different asm file). Here's a snippet of my main asm.



.elseif ax==IDC_ADDPATH
invoke OpenFileProc,hWin


So, my OpenFIleProc will be in OpenFile.asm. Here's the code of OpenFileProc.asm



OpenFileProc Proc hWin:HWND

mov ofn.lStructSize,SIZEOF ofn
push hWin
pop ofn.hwndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrFilter, OFFSET FilterString
mov ofn.lpstrFile, OFFSET buffer
mov ofn.nMaxFile,MAXSIZE
mov ofn.Flags, OFN_FILEMUSTEXIST or \
OFN_PATHMUSTEXIST or OFN_LONGNAMES or\
OFN_EXPLORER or OFN_HIDEREADONLY
mov ofn.lpstrTitle, OFFSET OurTitle
invoke GetOpenFileName, addr ofn

ret

OpenFileProc endp


I'm doing this just to have a more readable code. So, i've got an error at "invoke GetOpenFIleName"

Here's the error:

openfile.asm(15) : error A2107: cannot have implicit far jump or call to near label

Well, i dunno how to solve it... If you have an idea on how to solve it.

Is there another way to have a more readable code with different Asm File ? (link or tutorial are welcome).

Thank you very much.
Posted on 2003-12-17 04:46:09 by Neitsa
Neitsa,

The slickest way to do that, and the way I use is to have one file that is called by the assembler. That one file contains most of the basic definitions of the program, and has INCLUDE directives at the end to bring in other files needed to complete the program. So your program can be divided into as many file parts as you want, but the MASM listing is complete and contiguous. Also, all your references are in the same module and do not need EXTERN directives. I can give you an example of the last program I sent to a "Code Warrior" if you are interested. Ratch
Posted on 2003-12-17 05:17:09 by Ratch
Ratch,

I'm very interested on how you manage your code. In fact I don't understand how I must do with different Asm Files. I'll send you a PM. If anyone has another way to do it...

Thank you.
Posted on 2003-12-17 08:07:09 by Neitsa
Neitsa,

There is no need to do this privately. I am sending you a updated file containing an example program I recently sent to another code warrior, coredump, concerning another problem. Look at file MSGBOXCOLOR.ASM. The beginning contains INCLUDES needed from the MASM32 package available from this messageboard. The end contains INCLUDES for files needed to complete the program. Use MSGBOXCOLOR.BAT to assemble and link the code if you want. The program contains a lot of other material about programming that you might not be interested at this time. Just ignore what you do not care about. Ask publicly on this thread about anything you do not understand concerning this program. Ratch
Posted on 2003-12-17 12:12:10 by Ratch
And the light cames to me...:grin:

I've read your code and i understand exactly how to do it!

It was more simple than i was thinking...Anyway, i'm grateful to you Ratch !

(This is a nice program, i like the plaid effect very much :tongue: )

Thank you very much.

Regards, Neitsa.
Posted on 2003-12-17 13:21:18 by Neitsa
Neitsa.

Your're welcome. Ratch
Posted on 2003-12-17 14:33:38 by Ratch
You might want to take a look at the chapter on "Managing Large Programs" in the 16-bit edition of the "Art of Assembly". In addition to dealing with issues like public and extern, it also discusses makefiles and the like (which are real handy when breaking up programs into smaller pieces).
Cheers,
Randy Hyde
Posted on 2003-12-17 23:27:36 by rhyde
Ratch, i just bumped into this problem as well, can you post what you were saying you use earlier?
(this is first relevant thread search brought up, don't blame me for reviving the dead  :) )

AFAIK there are these methods:
1. global/extern
2. make files
3. 3rd party env as python?
4. ratch way?
5. what do C inline directive looks like in assembly? Or the void func(void) equiv?

I don't know any of these yet, i'm gonna pick global/extern way for starters and put my functions in a .dll, perhaps even void func(void) stuff to cut out chunks of my code(will it work?).

I would appreciate a short briefing on all of these methods from anyone who knows about them so i can get enlightened  :)

C inline == include directive in the middle of the code?

ratch meant a simple inline with all the function definitions in it?

*discovered RadASM's module support for global/extern stuff. Good .chm  :)
Posted on 2006-09-07 20:53:07 by w0lfshad3