Confused? Type help

> blog post Eval assembly

Eval assembly
Mon, 05 Nov 2007 04:51:25

Related to the last post, it was good for Armish (my arm assembler) to see some use. Fortunately the mnemonic to opcode encoding went flawless till now, that's such a drag to debug. But it got clear quite fast that it needed some variable support. So now expressions surrounded by emit-asm escape symbols that are not assembler related:

(let ((foo 'r4)
      (bar 'r6))
   (stmib r3 (r3 foo_bar))
   (b :loop)))

==> (:LOOP
     (STMIB R3 (R3 R4_R6))
     (B :LOOP))

Lisp forms inside emit-asm can be escaped with

(ea ...)

Furthermore I'm quite happy with the whole assembler in Lisp setup. For my current project I interleave assembler code with lisp code used to calculate what should be in it. Assembly code blocks are defined within macros which gather them in functions stored in hash tables.

At one point some assembly depends on Lisp code which depends on assembly which depends on Lisp code. Now granted, that code is a bit hackerish atm, but I'd guess that this way of coding might be a bit of a pain with the gcc model of doing things.

But then, in my eyes, getting an assembler out of a high level language environment like the one a Common Lisp implementation houses, thus loosing all its expressive powers, seems quite absurd to begin with.

other relevant changes:

  • assemble now expects a list of expressions, not the different expressions themselves, so as to play nice with emit-asm
  • armish now also depends on the tools lib umpa-lumpa
  • added binary list handling directives
  • string encoding can be set
  • as a convenience when assembling, always append code with :code-end label, so one can branch to it if necessary
  • standard encoding of (ldr literal) is twos compliment, to encode as positive integer, append it with :pi
  • updated docs to reflect changes

Want to comment? Type comment. Type something else to randomy chat a bit. I won't bite.