Home > News & Updates > Arduino News > AVR BARE METAL WITH LISP

AVR BARE METAL WITH LISP

Summary of AVR BARE METAL WITH LISP


ulisp is a lightweight Lisp interpreter for microcontrollers like Arduino, ESP, and RISC-V. A recent update enables direct assembler insertion into AVR programs, allowing developers to write macros and manipulate hardware registers efficiently. This integration supports position-independent code, essential for embedded environments where load addresses vary.

Parts used in the ulisp Project:

  • Arduino boards of the AVR variety
  • Arduino boards of the ARM variety
  • ESP chips
  • RISC-V chips

There are two kinds of programmers: those who don’t use Lisp, and those who need new parenthesis keycaps every six months. Lisp is one of those languages you either really love or really hate. If you love it, you may have checked out ulisp, which runs on Arduino boards of the AVR and ARM variety, as well as ESP chips, RISC-V, and others. A recent update allows the language to insert assembler into AVR programs.

We probably don’t need to convince anyone reading Hackaday why adding assembler is a good thing. It seems to integrate well with the environment, too, so you can write assembler macros in Lisp, which opens up many possibilities.

Of course, the format isn’t the same as your garden variety assembler. After all, Lisp should stand for “lots of irritating spurious parenthesis.” Plus your code needs to be position-independent since you’ll never know where it loads.

Here’s a simple example:

; Greatest Common Divisor
(defcode gcd (x y)
swap
($movw 'r30 'r22)
($movw 'r22 'r24)
again
($movw 'r24 'r30)
($sub 'r30 'r22)
($sbc 'r31 'r23)
($br 'cs swap)
($br 'ne again)
($ret))
(gcd 3287 3460)

There are more examples on the website, including direct I/O register manipulation.

We’ve seen badges running ulsip. Honestly, though, we’d be just as happy with Forth and it is easier on our parenthesis keys.

Source: AVR BARE METAL WITH LISP

Quick Solutions to Questions related to ulisp:

  • What platforms does ulisp run on?
    It runs on Arduino boards of the AVR and ARM varieties, as well as ESP chips and RISC-V.
  • Can I insert assembler into AVR programs using ulisp?
    Yes, a recent update allows the language to insert assembler directly into AVR programs.
  • Does ulisp support writing assembler macros?
    Yes, it integrates well with the environment so you can write assembler macros in Lisp.
  • Why must the code be position-independent?
    You never know where the code will load, so it must be position-independent.
  • What is the format characteristic of this Lisp implementation?
    The format uses lots of irritating spurious parenthesis as implied by the name Lisp.
  • Can I perform direct I/O register manipulation?
    Yes, there are examples on the website demonstrating direct I/O register manipulation.
  • Is Forth an alternative mentioned for similar tasks?
    Yes, the author mentions being happy with Forth as an easier alternative regarding parenthesis keys.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top