News:

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

Label offset

Started by TNick, February 13, 2007, 10:33:12 AM

Previous topic - Next topic

TNick

Hello, all!

I think this is the right place for this problem...

I want to store in .DATA section an offset to a label within a function like this:

.DATA
  L1Addr    DWORD   x
  L2Addr    DWORD   y

.CODE
MyFunction    PROC    Param1:DWORD, Param2:DWORD

Label1:
   mov  eax, 1

Label2:
   mov  ecx, 1

et
MyFunction ENDP

where x = OFFSET Label1 and y = OFFSET Label2

I know I could make both labels public, but I don't want that. Also, disassambly is not an efficient solution, because every time I would change my function I would have to find it again. :eek

Is there any other way? :'(

Thanks
Nick

hutch--

Nick,

try something like this.


MyFunc proc args etc ....

    .data
      plbl1 dd label1
      plbl2 dd label2
    .code

    ; your code

  label1:

    ; more code

  label2:

    ret

MyFunc endp
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

TNick

Whohohoooo! Thanks hutch!!! That works perfectly!!

drizz

:: makes label global


.DATA
  L1Addr    DWORD   offset Label1
  L2Addr    DWORD   offset Label2

.CODE
MyFunction    PROC    Param1:DWORD, Param2:DWORD

Label1::
   mov  eax, L1Addr

Label2::
   mov  ecx, L2Addr

   ret
MyFunction ENDP
The truth cannot be learned ... it can only be recognized.

TNick

Yes, thanks, drizz, but that's exactly what I don't want: a global label ... :)

Regards,
Nick

drizz

ooops i didn't see that hutchs code was surounded by a procĀ (overlookded proc/endp lines) :red
The truth cannot be learned ... it can only be recognized.