flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Mike Gonta 27 Oct 2012, 11:33
The use of local labels in macros instead of anonymous labels prevents conflicts with anonymous labels in the code
that the macro is used in. The use of a define is so the macro does not need to be edited. int 3 is two bytes, int3 is one. Code: define debugging 1 macro debug msg { local next if defined debugging int3 if ~msg eq jmp next db "DBG:" db `msg db " ", 0 next: end if end if } |
|||
![]() |
|
ejamesr 27 Oct 2012, 18:55
Very good points, Mike -- but that breaks my code. The problem is that the local label needs a '.' in front so that it doesn't conflict with previous labels. Here's a version with your improvements that works for me:
Code: define debugging 1 macro debug msg { local .next if defined debugging int3 if ~msg eq jmp .next db "DBG:" db `msg db " ", 0 .next: end if end if } ejamesr |
|||
![]() |
|
JohnFound 27 Oct 2012, 20:05
The best practice is to use labels with two dots prefix: "..next". They are global labels, but does not change the current global label set previously.
|
|||
![]() |
|
revolution 27 Oct 2012, 21:16
JohnFound wrote: The best practice is to use labels with two dots prefix: "..next". They are global labels, but does not change the current global label set previously. |
|||
![]() |
|
JohnFound 28 Oct 2012, 03:54
Of course it works. I am talking about "best practice". Using two dots is always safe in such situations.
|
|||
![]() |
|
revolution 28 Oct 2012, 04:41
JohnFound wrote: Of course it works. I am talking about "best practice". JohnFound wrote: Using two dots is always safes in such situation. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.