News:

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

Address of a label ...

Started by James Ladd, August 28, 2005, 02:43:32 AM

Previous topic - Next topic

James Ladd

I have a routine with several labels in it.
Is it possible to get the address of a label ?
Can you give an example as well.

Rgs, striker.

ThoughtCriminal

This should work:

mov eax,offset label

My best guess without more details.

hutch--

James,

There is a good technique in MASM if you want to hit those labels quickly, make a short table like this.


  table dd lbl1,lbl2,lbl3,lbl4 etc ....


This must match labels in you code and preferrably local in the procedure.



.data
table dd lbl1,lbl2,lbl3,lbl4 etc ....
.code

lbl1:

lbl2:

lbl3:

lbl4:


The assembler resolves the label names to addresses.

Not sure if this is what you are after but is cute anyway.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

James Ladd

Thanks Hutch and TC,

I should have tried Offet before asking.
Dang, addr vs offset.

UPucker

Excellent. I have been looking for an easy way to make jump tables.


James Ladd

Hutch,

Do you have a way of this working outside of a local routine ???

Rgs, Striker.

hutch--

Yes,

Make each label GLOBAL with the notation,


lbl1::

lbl2::

etc ....


The only catch with doing this is the labels must be unique for the entire module where if you use them in LOCAL scope with the table inboard, you don't.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

James Ladd

Hutch,

Thanks that worked !    :bg

Rgs, striker.