Remix.run Logo
▲ Lerc 2 hours ago

When I made an AVR assembler, I had a play around with a few ideas.

My changes were less to do with instruction representation, and more related to macros and reusable code.

https://github.com/Lerc/AvrAsm

One example of some of the bits I added, is the macros at

https://gist.github.com/Lerc/ad96329670965dc023c5ae740b433ad...

This provides a blend of macros and snips to allow

    init:
      set_stack_pointer RAMEND
      load_let_values
      call Someroutine

    ...
    ...
    ...

    Someroutine:
      letb bits_x,62
      letb bits_y,56

      lds r16,bits_x
      lds r17,bits_y
    Etc.
So the letb macro puts the constant parameter into ROM and assigns a RAM symbol for the variable. The load_let_values macro copies the ROM values into the RAM locations (essentially dropping some of requirements for sections)

The load_let_values macro manages to copy values that are defined later in the program.

I'm not sure if this is a wise use of this feature, but it was a good tricky task to attempt to implement with it.