flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 07 Oct 2019, 06:45
Thank you for the questions that show me the places in documentation that need some work!
![]() MaoKo wrote: Hi! I've two problems. The first one is that I'm trying to write some M68K macro and I need to handle some names such as "adda.w, sub.l, ...". Code: macro eor?.w? Code: namespace eor? macro w? ; ... You can therefore define such macro like this: Code: macro eor.w? Code: define eor? ; or: eor? = 0 ; or even: eor?: In other words, when you use a symbol like EOR.W, only the W portion is the name of the macro, EOR portion is the name of the parent symbol of the namespace, which is an expression-class symbol. You need to define them both. And if you also define an EOR macro, it is a completely separate matter (a definition like "macro eor?" does not create an expression-class symbol). MaoKo wrote: My second problem is that I need to define the source file name in the object file generated by fasmg for debug purpose. So in a file, I declare a postpone block that db __file__, which is included in source file. But in the output, the name match the file who declare the postpone block cuz file included by "include" are preprocessed first. How I can do this without manually do the db __file__ in each source file. If you have no such option, you could perhaps go super-tricky and put something like this at the end of the header file: Code: postpone display __mainfile__ end postpone macro ?! line& ; this is a one-shot line interceptor that should catch a line of the outer file purge ? __mainfile__? = __file__ outscope line end macro ; make sure that this is the last line of file, with no line break after it PS. I have updated the manual. I could also add another built-in variable just for the purpose of getting the name of main file. It's quite easy to add if we decide that it's needed. |
|||
![]() |
|
Tomasz Grysztar 07 Oct 2019, 21:42
I have added new symbol, __SOURCE__, to refer to the main source file. I concluded that this is something that should not really be so tricky to do. You get it starting with version "ip7v4".
|
|||
![]() |
|
MaoKo 07 Oct 2019, 22:45
Hello. Thx to reply for my problems
![]() So a better code is: Code: iterate <instr,opcode>, and,1100b, add,1101b, eor,1011b ;, .... restore instr? ; prevent forward-referencing if ~ (definite instr) define instr? end if iterate suffix, b,w,l macro instr?.suffix? ; ... end macro end iterate end iterate Hopefully definite/defined op work only on expression class sym ![]() For the __file__ sym, macro ?! work fine but, yeah, I think __source__ is more lisible. Thx. |
|||
![]() |
|
Tomasz Grysztar 08 Oct 2019, 06:19
MaoKo wrote:
Another thing to note is that DEFINITE does not allow an expression to be empty, while DEFINE does. So when you make an empty symbolic definition with line like "define instr?", then "defined instr" becomes a valid condition, while "definite instr" becomes invalid expression. I would suggest using either of the following variants instead: Code: if ~ defined instr restore instr? ; prevent forward-referencing define instr? end if Code: if ~ definite instr instr? := 1 ; you can also use a definition like "element instr?" here end if |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.