I have recently switched from tasm to masm.. well in tasm i could write a procedure like this:

proc test, something:dword
call lstrcmp, , offset somedata
somedata db 'foo',0

well in masm a similar procedure produces an error because the ref to somedata is a forward reference.. is there a way how i could do this in masm? (no please not the szText macro). i want the somedata to be local to the procedure, so i dont want to define somedata before the proc.

would be happy for any replies.
Posted on 2002-02-01 20:10:34 by B-Boy

You have to put the TEXT data somewhere, szText writes it in the .CODE section, the alternative is to write it to the .DATA section.

Inline in your source code, try this,

MyString db "Hi Dude, this is a string",0

It works fine.


Posted on 2002-02-01 20:27:31 by hutch--
Can you also write it to the .cont section.

I think i seen it there in someone example code a while back.

If so are there any pro's and cons
Posted on 2002-02-01 21:11:36 by cmax

In 16 bit DOS assembler there is a .CONST section that you can use to write data to DGROUP but I doubt its much use to you in 32 bit assembler. In MASM you already have .DATA for initialised data and .DATA? for uninitialised data so there is little point in adding another to it.


Posted on 2002-02-02 03:47:41 by hutch--
Hi again!
First of all thanks for your help, but i think i didn't describe my problem too well :)

I know that I have to define the text somewhere, but I want the text to be defined *inside* the proc statement so the text label is only accessable inside the proc (well, like the szText macro does, _except_ that I want to define the text after the proc's actual code so that I wont get those jmp-after-text-definition jmp instructions).
It seems to me as if the whole problem is that masm doesnt (want to) handle forward data references, while it yet can handle forward code references (jmp/jz/... instructions) very well.
That's why I'm asking, I mean if forward code refs are possible, why not forward data refs, too?

Again, I would be happy if someone could give me some advice :)
Posted on 2002-02-03 15:20:32 by B-Boy
You could possibly do with a PROTO statement. You might want to
have a look at the CTEXT macro as well, it's very very handy...
Posted on 2002-02-03 15:40:07 by f0dder

I have not used that style of code for a long time but I gather you want to place the data locally within a procedure. There are only 2 choices to have this as the binary file does not have LOCAL in any real sense. A procedure is only constructed on the stack and ceases to exist once the stack is restored.

The szText macro writes to the .CODE section, you can use the format of .DATA/your data/.CODE as explained before but I doubt that you can use the format in your sample of putting the line of code below the RET as you will get the forward reference problem.

The macro f0dder mentioned is convenient to use but it writes the data in the .DATA section so it is doing nothing different to what you already know.


Posted on 2002-02-03 15:57:34 by hutch--
OK, now I see.. although I'm a bit disappointed about the fact that masm cannot handle forward data refs (can I complain to MS about it? ;)..
Well, but this CTEXT macro looks very handy indeed :) so again big thanks for this hint and for your help.

Posted on 2002-02-04 15:02:28 by B-Boy
Well I guess if you emailed Bill Gates and said,

Hey Bill etc ...

but I would not advise you to hold your breath waiting for a reply. :grin:


Posted on 2002-02-05 05:52:58 by hutch--