Anybody know of a way to declare more than one variable on the same line?
My progs are starting to get lengthy and i'm just wondering.
I want my progs more readable if its possible.
I'm talking of any of the .data, data? or .const sections
thanx
My progs are starting to get lengthy and i'm just wondering.
I want my progs more readable if its possible.
I'm talking of any of the .data, data? or .const sections
thanx
Not directly, but a macro would make things work smooth:
This will work anywhere in your program, and separate initialized code from unitialized code.
Ie)
MultiData Var1, Var2 = 123, Var3=0fh, Var4
will produce..
I actually like this macro... thanx for the idea... :)
NaN
MultiData MACRO args:VARARG
LOCAL arg, cc1, sz1, sz2
FOR arg, <args>
cc1 = @InStr(1,<arg>,<=>)
IFE cc1 eq 0
sz1 SUBSTR <arg>, cc1+1
sz2 SUBSTR <arg>, 1, cc1-1
.data
@CatStr( sz2, < dd sz1>)
ELSE
.data?
@CatStr( arg, < dd ?>)
ENDIF
ENDM
ENDM
This will work anywhere in your program, and separate initialized code from unitialized code.
Ie)
MultiData Var1, Var2 = 123, Var3=0fh, Var4
will produce..
.data?
Var1 dd ?
.data
Var2 dd 123
.data
Var3 dd 0fh
.data?
Var4 dd ?
I actually like this macro... thanx for the idea... :)
NaN
Titan,
There is probably no choice when a program gets big enough but to use a seperate include file for things like the .DATA and .DATA? sections as this removes the list of prototypes, macros and constants from the working code and puts it in a place where it can easily be accessed.
Multi modular programming is the best way to keep a big project under control, instead of having to search through 100k of code to find a part you wish to modify, you can break the project up into sets of simliar functions so that they area easier to find.
Keep in mind that you can use seperate modules as well and if its a big serious project that takes a lot of planning, building a library for it is a good idea. It means you have sections of precompiled code that don't have to be rebuilt every time you rebuild the project.
Regards,
hutch@pbq.com.au
There is probably no choice when a program gets big enough but to use a seperate include file for things like the .DATA and .DATA? sections as this removes the list of prototypes, macros and constants from the working code and puts it in a place where it can easily be accessed.
Multi modular programming is the best way to keep a big project under control, instead of having to search through 100k of code to find a part you wish to modify, you can break the project up into sets of simliar functions so that they area easier to find.
Keep in mind that you can use seperate modules as well and if its a big serious project that takes a lot of planning, building a library for it is a good idea. It means you have sections of precompiled code that don't have to be rebuilt every time you rebuild the project.
Regards,
hutch@pbq.com.au
Yeah, Hutch of course is right.
Just in case you don't know how to do this its actually very simple. Simply have a file, maybe data.asm containing something like the following;
.data
Var1 dd 67
Var2 dw 56
VarX .. ..
.... .. ..
.... .. ..
.data?
uVar1 dd ?
uVar2 db ?
..... .. ?
..... .. ?
And then in your main asm file simply include it. The way the include directive work is that it place alaces the text in data.asm where ever you have include data.asm in the main file.
Just in case you don't know how to do this its actually very simple. Simply have a file, maybe data.asm containing something like the following;
.data
Var1 dd 67
Var2 dw 56
VarX .. ..
.... .. ..
.... .. ..
.data?
uVar1 dd ?
uVar2 db ?
..... .. ?
..... .. ?
And then in your main asm file simply include it. The way the include directive work is that it place alaces the text in data.asm where ever you have include data.asm in the main file.
NaN, Try this version - it has many benefits over the above. :)
MultiData MACRO args:VARARG
LOCAL arg, cc1
FOR arg, <args>
cc1 INSTR <arg>,<=>
IF cc1 ne 0
_DATA segment DWORD public 'DATA'
@SubStr(<arg>,1,cc1-1) dd @SubStr(<arg>,cc1+1,)
_DATA ends
ELSE
_BSS segment DWORD public 'BSS'
arg dd ?
_BSS ends
ENDIF
ENDM
ENDM
bitRake,
You ever considered changing your nick to "MacroMan":grin:
You ever considered changing your nick to "MacroMan":grin:
Unfortunately, I am bitRAKE. :)
bit + RAKE = bitRAKE
It's a difficult thing to explain exactly, but I'm sure it's something that many have known. :)
Posted on 2001-09-16 14:39:01 by bitRAKE
bit + RAKE = bitRAKE
It's a difficult thing to explain exactly, but I'm sure it's something that many have known. :)
Posted on 2001-09-16 14:39:01 by bitRAKE
Nice....
Thanx for the clean up... :)
BTW: I noticed the word PUBLIC in your version.. if i used PRIVATE would they be accessible from other asm files?
NaN
Thanx for the clean up... :)
BTW: I noticed the word PUBLIC in your version.. if i used PRIVATE would they be accessible from other asm files?
NaN
I believe that the PUBLIC/PRIVATE refers to link-time access. Therefor, these segments would be usable by code in other object files. Because of the class definition these segments are combined with the default segments - same as .data/.data?
Here is another version with an added feature:
Here is another version with an added feature:
.VAR MACRO args:VARARG
LOCAL arg,cc1,tsz
FOR arg, <args>
cc1 INSTR <arg>,<=>
tsz CATSTR <d>,@SubStr(<arg>,1,1)
IF cc1 ne 0
_DATA segment DWORD public 'DATA'
@SubStr(<arg>,1,cc1-1) tsz @SubStr(<arg>,cc1+1,)
_DATA ends
ELSE
_BSS segment DWORD public 'BSS'
arg tsz ?
_BSS ends
ENDIF
ENDM
ENDM
.VAR dSomeNumber=123,bSomeString="Hello, world!",bBaby,wChild,qBigGuy