News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

local labels not in procs, or leaf procs

Started by vid, July 10, 2007, 03:05:51 PM

Previous topic - Next topic

vid

hi, i need to write set of procedures.

These procedures won't use EBP as stack frame pointer, but instead as normal register. They will take arguments only in registers, and won't have any local variables. But I need to have couple of local labels with same name in every procedure.

Is it possible to do this with PROC directive, so that it doesn't generate prologue/epilogue which changes EBP? Or is there some way to declare local label outside procedure?

thanks

Tedd

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

fun1 proc
  label1:
    nop
  label2:
    ret
fun1 endp

fun2 proc
  label1:
    nop
  label2:
    ret
fun2 endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef


The first set of OPTIONs turn off the stack-frame, and the last ones turn it back on - any procs in between will not have a stack-frame generated.
No snowflake in an avalanche feels responsible.

vid


Ian_B

Quote from: vid on July 10, 2007, 03:05:51 PMBut I need to have couple of local labels with same name in every procedure.

This isn't affected by the Prologue/Epilogue options Tedd has explained. By default, there's no problem having duplicate labels in different procs, each procedure is "encapsulated".

However, if for some reason you want to be able to jump into a proc from elsewhere (perhaps to have a single error-handling "tail" common to a group of file-handling procedures, which is something I do a lot, although it's probably bad programming practise) then you need to enable this deliberately with Option Noscoped. That will prevent you from having duplicate labels anywhere in your program though, but as I said it is NOT enabled by default.

MichaelW

To be clear, OPTION NOSCOPED affects all labels that follow the directive, up to the next OPTION SCOPED directive, if present. Any single label can be made accessible from outside a procedure by defining it with a double colon, as in "labelname::", but the name cannot then be duplicated anywhere in the source.
eschew obfuscation

Ian_B

Thanks for the clarification, Michael. That's all extra neat, especially the double-colon trick.  :thumbu