The MASM Forum

General => The Campus => Topic started by: maxirdax on May 25, 2025, 07:46:30 PM

Title: Cleaner Macro Expanded Labels
Post by: maxirdax on May 25, 2025, 07:46:30 PM
Hello, I have been programming with masm64 and I ran into a problem with some code where I successfully made a macro to process some data and reused it successfully but when I view the disassembly to step through the expanded macro the labels are mangeled and hard to read (using local labels in macro).
Is there a way I can force masm to keep my label names as designated in the original macro in the disassembly? even the /EP preprocessing result is mangled.
Title: Re: Cleaner Macro Expanded Labels
Post by: maxirdax on May 25, 2025, 07:47:36 PM
I like working with macros but its nice to still be able to debug them. What is the clean workflow?
Title: Re: Cleaner Macro Expanded Labels
Post by: sinsi on May 25, 2025, 08:05:02 PM
If you mean that local vars in a macro show as e.g. ??0001 then the only way to see the actual var name is not declaring them local. This, of course, can cause more problems if the type changes.
Title: Re: Cleaner Macro Expanded Labels
Post by: maxirdax on May 25, 2025, 08:12:10 PM
cool, I'm not necessarily talking about var names, mainly labels, they do get translated to ??0166 in the disassembly.
I don't know if making a custom preprocessor that emits clean asm files with already expanded macros is the way to go this way I'll be able to step thru the code cleanly in the debugger
Title: Re: Cleaner Macro Expanded Labels
Post by: maxirdax on May 25, 2025, 08:27:27 PM

SSS: macro(i) {
  mov rax, <i>
  label_<i>:
  jmp label_<i>
}
for(i: count) {
  SSS(i)
}
; output
mov rax, 0
label_0:
jmp label_0

mov rax, 1
label_1:
jmp label_1

mov rax, 2
label_2:
jmp label_2

it'll just export an asm file which i can simply include and the debugger will show everything cleanly. overkill?
Title: Re: Cleaner Macro Expanded Labels
Post by: maxirdax on May 25, 2025, 08:30:23 PM
i can just include asmgen.asm and the debugger will gladly oblige me  :biggrin: