I just found out that I can do this:


foo label dword


bar label dword

and my dissassembly:

lea edx, _foo
00401128 lea edx,[__IMPORT_DESCRIPTOR_KERNEL32+33h (404033h)]

Is this safe? It there a way to assign a value to foo in the .data section? ie. foo label dword 255?

Posted on 2002-06-13 07:38:18 by ThoughtCriminal
Due to alignment you probably can (unless your data segment is empty except for labels), but the problem is creating a label doesn't tell MASM to allocate any space for data. For example:

foo label dword
bar dd 31337

Would mean that foo and bar are the same piece of memory.

To answer your other question: use

foo label dword
dd 255
Posted on 2002-06-13 09:46:07 by Qweerdy
Good point. By the dissassembly it looks like I was just labeling addresses above my program code.

I'll try your examples. I'm not sure what I'm trying to get out of this....

Posted on 2002-06-13 21:41:17 by ThoughtCriminal

There is no real gain by using a label in the .DATA section, when you use a named variable in the data section,

var dd 0

You get its address by code like,

mov eax, offset var
lea eax, var

Primarily a label is the target for a jump, CALL or RET(n or f) mnemonic and it is a placeholder for the address of the next instruction after the label in the code.

The older style of assembler coding used a label on the SAME line as the instruction.

label: mov eax, 1
xor eax, ebx etc ....

I have heard of some very creative uses for what you are after where you write instructions in DB format in the DATA section but its unusual stuff.


Posted on 2002-06-14 07:11:42 by hutch--
I'm not really after anything, just surprised.

But just FYI, variables allocated the normal way(on my system), tend to be located around:


Using the label gives me an address above my program code int the 403000h range.

A curiosity.
Posted on 2002-06-14 07:22:27 by ThoughtCriminal