Search code examples
assemblyx86fasm

Flat Assembler: How do I get the address of an label?


How do I get the address of a label?

I want to get the address of a label in flat assembler without adding extra code

example:

label1:  ;is at adress 0
db 1h,2h,3h,4h,5h  ;some data

label2: is at address 5 because label1 has 5 bytes of data

I could print the address to the console screen but that adds size to the program and changes the result.

I'm aware of just using the label but I want the raw address number.


Solution

  • Quick Solution:

    i just put all symbols at the very end of the assembly file and then looked at it with an hex editor:

    example:

    label1: ;example label (can be anywhere)
    ;...
    ;... My Programm
    ;...
    
    ;the end of the program
    db 0h ;just some spacer
    dw label1