News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Get globals, instructions and function addresses at assembly time.

Started by jacklack, January 15, 2015, 04:18:53 AM

Previous topic - Next topic

jacklack

In the process of writing a debugger for a custom language, I would like to know how to get global variables addresses, functions addresses and instructions addresses at assembly time.

I would like to write this addresses along with other debugging symbols to a debug file. (That I will use later to use for debugging, much like the pdb files generated by c/c++).
I think Masm fixes the address for code and globals at assembly time and would like to know how to get them?

Thanks in advance;

dedndave

    .data?

dwSomeVar dd ?

    .code

SomeProc PROC
;
    ret
SomeProc ENDP

;to get addresses....

    mov     edx,offset dwSomeVar  ;EDX = address of dwSomeVar
    mov     ecx,SomeProc          ;ECX = address of SomeProc ("offset" not needed for code)

jacklack

Thank you, but I would like to know theses address at assembly time, not when executing the program (runtime).
That is when Masm is assembling assembly files, he is assigning addresses to globals and instructions, I would like to know those addresses, and match each global, function or instruction to it's address.

dedndave

duh - my mistake - i didn't read carefully (first cup of coffee, here)

as far as i know, the assembler makes at least 2 passes
addresses may not be known in pass 1 that are in pass 2

refer to the MASM manual for some conditionals related to assembler passes

jacklack

Thank you dedndave.
Searching for masm and assembly passes, I found that masm generates a listing for all the symbols and include even code addresses and instruction hex in the .lst file.
Just opened my generated lst, looks like everything I need is there.
That is really all need. Just great!