dasm-assembler / dasm

Macro assembler with support for several 8-bit microprocessors
https://dasm-assembler.github.io/
GNU General Public License v2.0
213 stars 39 forks source link

Macros can't redefine instructions #110

Open andrew-davie opened 3 years ago

andrew-davie commented 3 years ago

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?

thomas374b commented 3 years ago

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.