dasm-assembler / dasm

Macro assembler with support for several 8-bit microprocessors

Home Page:https://dasm-assembler.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Macros can't redefine instructions

andrew-davie opened this issue · comments

I wanted to block out a particular instruction from use in my program.
I thought to define the instruction as a macro, and ERR inside the macro.
However, to my surprise, you don't appear to be able to redefine an instruction.

 MAC LDA ; redefine as an error!
  ECHO 'Don't use LDA!'
  ECHO {0}
  ERR
 ENDM

In my tests, the macro is never instantiated.
Perhaps the documentation needs updating to indicate - or is it possible to 'fix' this issue?

Yes, this is a "feature" of dasm. Macros and Instructions don't share the same "namespace". Therefore there will be no clash. The macro will be silently ignored because the processor mnemonic is matched earlier.

A fix would need to introduce some extra "cross-checking" and proper aborting. Dasm could not decide by itself what is better to choose (macro or processor mnemonic).

A solution to this problem could be to have another processor definition (subset, like with the 68705 and 68908) or to implement a special UNDEFINE keyword that kicks out a special mnemonic.