[HN Gopher] A Lisp compiler to RISC-V written in Lisp
       ___________________________________________________________________
        
       A Lisp compiler to RISC-V written in Lisp
        
       Author : chrisjj
       Score  : 209 points
       Date   : 2024-10-11 11:56 UTC (11 hours ago)
        
 (HTM) web link (www.ulisp.com)
 (TXT) w3m dump (www.ulisp.com)
        
       | rwmj wrote:
       | As I understand it, this compiles down to assembly instructions.
       | What then assembles it to machine code? The reason I'm asking is
       | I wanted to find out if the compiler/assembler supports
       | compressed instructions (which are supported by the RP RISC-V
       | core).
       | 
       | Edit: Yes it does support the compressed extension, although the
       | page calls them "compact" instructions.
        
         | steeleduncan wrote:
         | In the article there is a link to an earlier post with a RISC-V
         | assembler (I think written by the same author), which generates
         | the actual machine code
        
         | johnsondavies wrote:
         | Thanks - corrected "compact" to "compressed".
        
       | Pet_Ant wrote:
       | There is something about RISC-V that really inspires lots of
       | hackers and it's not really technical thing AFAICT.
        
         | bee_rider wrote:
         | It is cool as heck that truly open hardware might actually win
         | in our lifetimes. (ARM was an interesting start, but too much
         | licensing).
        
         | chrisjj wrote:
         | > There is something about RISC-V that really inspires lots of
         | hackers
         | 
         | "Not Arm" :)
        
         | trq01758 wrote:
         | Simplicity, it's a modern MOS 6502. Base RISC-V has even less
         | instructions than 6502.
        
           | Joker_vD wrote:
           | Also it has less registers (32 vs. 256 in the zero page) and
           | less addressing modes.
        
             | wk_end wrote:
             | But the 6502's "registers" are much smaller and you can do
             | much less with them. You can't really sensibly compare the
             | two approaches so superficially.
        
           | acegopher wrote:
           | The same could be said of the ARM Cortex-M0+.
        
             | kragen wrote:
             | The Cortex-M0's Thumb-1 is a really unpleasant instruction
             | set compared to ARM, Thumb-2, RISC-V, or ARM64.
        
         | marssaxman wrote:
         | For me, it's the fact that it is a truly open standard, with no
         | licensing entanglements. It has the potential to be a durable
         | ecosystem, worth investing in.
        
         | KerrAvon wrote:
         | It's a bunch of things; many of the reasons are actually
         | technical. It's very simple to compile to RISC-V instructions.
        
         | rootnod3 wrote:
         | For me, part of it is also the beauty of the ISA. I think it is
         | just really well thought out with its extensions and
         | namespacing for custom ISAs.
        
       | spsesk117 wrote:
       | ulisp is an incredible achievement and has brought me a lot of
       | joy.
       | 
       | There is something very fun about writing lisp for an Arduino
       | nano, and trying to golf your intentions into ~300 characters :)
        
         | bongodongobob wrote:
         | That's neat but I don't know why you'd minimize characters
         | rather than ROM size for a microcontroller.
        
       | bloopernova wrote:
       | I got a RP2350 "Feather"[1] from Adafruit[2]. Amazing little
       | thing, with lots of stuff built-in. The lipoly charge port is
       | super useful and Just Works, and the STEMMA QT connector means no
       | soldering or breadboards for simple projects. My main half-baked
       | idea for this is to control a CPU usage monitor[3], but I also
       | want to make some better lights for my Lego SHIELD Helicarrier,
       | and maybe add some movement too.
       | 
       | And now you're telling me I can use Lisp on this? It would be
       | interesting to see how streamlined the development process is for
       | each one of uLisp, CircuitPython, MicroPython, and Arduino/C.
       | 
       | [1] https://www.adafruit.com/product/6000
       | 
       | [2] https://www.adafruit.com/new <-- one of my favourite places
       | to window-shop :)
       | 
       | [3] Yeah I'm rambling but my end goal is to drive an LED matrix
       | that ends up looking like btop's CPU meter. Why not just show
       | btop on a separate small screen? That is a very good question to
       | which I have no answer.
        
         | jwhitlark wrote:
         | Rust also runs on picos and Esp32s, if that's your jam.
        
       | pjmlp wrote:
       | I see Lisp compilers and upvote. :)
       | 
       | Great work.
        
         | patrickmay wrote:
         | I see people who upvote Lisp compilers and upvote.
        
       | reikonomusha wrote:
       | SBCL is a Common Lisp compiler written in Common Lisp that also
       | can target RISC-V.
        
         | amszmidt wrote:
         | Can it run on the MCU mentioned in the post? Somehow I doubt
         | that.
         | 
         | Can SBCL even target MCU boards like the pico?
        
           | AyyEye wrote:
           | Second sentence from TFA:
           | 
           | > You can run the compiler on the RISC-V core of a Raspberry
           | Pi Pico 2 (or another RP2350-based board)
        
             | McGuffin wrote:
             | What article are you referring to? (Specifically, the
             | parent comment asked about SBCL, Steel Bank Common Lisp,
             | running on the pico 2, not about uLISP)
        
               | AyyEye wrote:
               | No more comments before coffee for me.
        
       | hinkley wrote:
       | Gretchen! Stop trying to make Lisp happen. It's not going to
       | happen.
        
       | kragen wrote:
       | I don't think it's yet complete enough to compile itself; though
       | I haven't looked at the assembler code, I'm pretty sure it
       | requires bitwise operations the compiler can't compile yet. Also,
       | the compiler itself requires things like null, symbolp, eq, and
       | atom, which it also doesn't implement yet. Without those I'm not
       | sure that it's fair to describe its input language as Lisp,
       | though it does support car and cdr.
       | 
       | But it's still super cool. A really great thing about Lisp for
       | purposes like this is that you don't get hung up on syntax and
       | parsing, which is the most salient part of writing a compiler but
       | not the most important.
        
       | Joker_vD wrote:
       | This is all very neat and all but could anyone please explain to
       | me how this thing handles forward label resolution e.g. in the
       | "if" construct? I _think_ I know how it does that but I am very
       | likely to be be wrong.
        
       | dang wrote:
       | Edit: It's a pity we missed http://www.ulisp.com/show?4W2I. It
       | was posted (https://news.ycombinator.com/item?id=41190553) but
       | didn't get attention. We'd have put it in the SCP for sure
       | (https://news.ycombinator.com/item?id=26998308) if we had seen
       | it.
       | 
       | ---
       | 
       | Related. Others?
       | 
       |  _uLisp: Lisp for Microcontrollers_ -
       | https://news.ycombinator.com/item?id=41681705 - Sept 2024 (1
       | comment)
       | 
       |  _An ARM Assembler Written in Lisp_ -
       | https://news.ycombinator.com/item?id=36646277 - July 2023 (31
       | comments)
       | 
       |  _uLisp wireless message display with a Pi Pico W_ -
       | https://news.ycombinator.com/item?id=32722475 - Sept 2022 (6
       | comments)
       | 
       |  _Visible Lisp Computer: embedded real-time display of Lisp
       | workspace using uLisp_ -
       | https://news.ycombinator.com/item?id=30612770 - March 2022 (7
       | comments)
       | 
       |  _uLisp on the Raspberry Pi Pico_ -
       | https://news.ycombinator.com/item?id=29970231 - Jan 2022 (14
       | comments)
       | 
       |  _uLisp_ - https://news.ycombinator.com/item?id=27036317 - May
       | 2021 (87 comments)
       | 
       |  _Lisp Badge: A single-board computer that you can program in
       | uLisp_ - https://news.ycombinator.com/item?id=23729970 - July
       | 2020 (25 comments)
       | 
       |  _A new RISC-V version of uLisp_ -
       | https://news.ycombinator.com/item?id=22640980 - March 2020 (35
       | comments)
       | 
       |  _uLisp - ARM Assembler in Lisp_ -
       | https://news.ycombinator.com/item?id=22117241 - Jan 2020 (49
       | comments)
       | 
       |  _Ray tracing with uLisp_ -
       | https://news.ycombinator.com/item?id=20565559 - July 2019 (10
       | comments)
       | 
       |  _uLisp: Lisp for microcontrollers_ -
       | https://news.ycombinator.com/item?id=18882335 - Jan 2019 (16
       | comments)
       | 
       |  _GPS mapping application in uLisp_ -
       | https://news.ycombinator.com/item?id=18466566 - Nov 2018 (4
       | comments)
       | 
       |  _Tiny Lisp Computer 2_ -
       | https://news.ycombinator.com/item?id=16347048 - Feb 2018 (2
       | comments)
       | 
       |  _uLisp - Lisp for the Arduino_ -
       | https://news.ycombinator.com/item?id=11777662 - May 2016 (33
       | comments)
        
       ___________________________________________________________________
       (page generated 2024-10-11 23:01 UTC)