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

request for new feature, EQADD assembler directive

thomas374b opened this issue · comments

several attempts have been made in the past to get dasm to define a string "in pieces" aka "stepwise". (see issues #32, #98 and testcases segfault, reverse_segfault, recursive_eqm, recursive_set, concat_str)

They all are doomed to fail since the way how dasm works implies (endless) recursion.

To address this use-case I propose to add the new assembly directive EQADD to globals.c and a new function v_eqadd(..) to main.c. The function should not deepen the evaluation / should not lead to recursion, should replace a previously made equation by appending the argument(s).

Example usage that defines a string cpu_variant according to the capabilities of the processor

cpu_variant   .SET  "68HC"     ; initial declaration of the symbol

   .IF FLASH_START == $F800
cpu_variant  .EQADD "8"       ; appending char "8"   (this variant has 8k mask ROM )
   .ENDIF

cpu_variant  .EQADD "11"     ; appending string "11"

   .IF BOOTROM_START == $BF40
        .IF FLASH_START == $F800
cpu_variant .EQADD "e"
        .ELSE
cpu_variant .EQADD "a"
        .ENDIF
   .ELSE
cpu_variant .EQADD "e"
   .ENDIF

   .IF FLASH_SIZE == 2048
cpu_variant .EQADD "2"
   .ELSE    
cpu_variant .EQUADD "1"   ; only 512 bytes flash
   .ENDIF

; should produce  "68HC11a1", "68HC11e1" or "68HC811e2" depending on the given variable definitions