I normally label my procedures with two successive underscores as in "__something:" without the quotation marks. I can make local labels with a single dot like ".LocalLabel" in my procedures but I want to know if there is a way I can declare local constant values so that a constant with the same name can be made for another procedure. Is this possible in NASM?
Posted on 2007-05-11 04:17:13 by XCHG
Yes, the local label requires proviously defined global label, and the local really is named global.local, like
  cmp x,y
  jne .q
  mov e,r
.q:        // label name = __test.q
Posted on 2007-05-12 01:59:10 by sapero
Okay, I think I interpreted that differently than sapero. sapero is refering to accessing a local label globally, if I'm correct in my interpretation of you post you are wondering about 'local constants', or 'local defines' as they are called in GoASM. To my knowledge, nothing like this is supported in NASM. You do, however, have %define and %undef so that once you have finished with you're procedure you can %undef the constants you created with %define at the beginning of the procedure. This way you can reuse the names of your constant values time and time again throughout different procedures and the value can be 'localized' to that routine. I hope between myself and sapero, one of us answered your question. I wasn't exactly sure of what you were wanting.

Bryant Keller
Posted on 2007-05-12 12:40:07 by Synfire

Well, you got what I wanted to do. So we can't have local constants like HLLs. But you are right. I'm going to have to use %define and %undef instead. Thank you so much.


Thank you for your answer. But what if I compile something like this?

    ; void __MyProcedure (void); StdCall;
    .Params: DB 4
    RET    __MyProcedure.Params

A constant is supposed not to be assembled as an opcode while assigning the value of 4 to the .Params local parameter will cause the assembler to assemble that code.
Posted on 2007-05-13 01:17:44 by XCHG
i'm not experienced with NASM, but shouldn't this work?

.sub = 123

it seems strange to me that this doesn't work (maybe i'm too grown on FASM)

or if it doesn't, then following "tricking", ideally done by some macro

temp = $
org 123
org temp
Posted on 2007-05-13 04:09:52 by vid

No NASM does not allow assigning values to local labels and about macros or any other parts of the program that use ORG, NASM will complain about it. You can't use ORG more than once in your source code. Thank you anyway for your response.
Posted on 2007-05-13 08:17:31 by XCHG