uLisp – ARM Assembler in Lisp
ulisp.com
ulisp.com
Related: Z80 assembler in Scheme
https://github.com/siraben/zkeme80/blob/master/src/assembler...
[0] https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-...
"CHIP-8 in Common Lisp: Disassembly"
For example SBCL
https://github.com/sbcl/sbcl/blob/master/src/compiler/disass...
and its ARM64 instructions:
https://github.com/sbcl/sbcl/blob/master/src/compiler/arm64/...
? (defun times13 (x) (* 13 x))
TIMES13
? (disassemble 'times13)
;;; (defun times13 (x) (* 13 x))
(recover-fn-from-rip) ; [0]
(cmpl ($ 8) (% nargs)) ; [7]
(jne L41) ; [10]
(pushq (% rbp)) ; [12]
(movq (% rsp) (% rbp)) ; [13]
(pushq (% arg_z)) ; [16]
;;; (* 13 x)
(movl ($ #x68) (% arg_y.l)) ; [17]
(movq (@ -8 (% rbp)) (% arg_z)) ; [22]
(movq (% rbp) (% rsp)) ; [26]
(popq (% rbp)) ; [29]
(jmp (@ .SPBUILTIN-TIMES)) ; [30]
;;; #<no source text>
(:align 3)
L41 ; [@56]
(uuo-error-wrong-number-of-args) ; [41]
NILe.g. set the 3 bytes starting at bit 2 of x to the binary value 110:
(setf (ldb (byte 3 2) x) #b110)
or set the 3rd byte (8 bits starting at bit 24) of x to 0xab: (setf (ldb (byte 8 24) x) #xab)
The first example compiles down to the following 2 instructions on sbcl/x64: ; A4: 4883E1C6 AND RCX, -58
; A8: 4883C930 OR RCX, 48
NOTE: The values are 1 bit shifted from what you might expect (binary 110 = 6; 6 << 2 == 24, not 48) because SBCL uses low-bit tagging to distinguish integers from pointers; working with arrays of unboxed machine-friendly sized integers (8,32,64) works as expected.In 1983, Rescue on Fractalus and Ballblazer, the first releases from Lucasfilm Games, were built with a system written in Lisp. It was a 6502 assembler with Lisp syntax and a Lisp-style macro facility, written in Portable Standard Lisp, running in Berkeley Unix on a 4MB VAX 11/750. Unfortunately it was eventually abandoned because the developer had left and it was a bit of a strain on the VAX that was shared by the whole development team.
Yes, I wrote it. Yes, it was my first non-academic programming job. Yes, the users complained about the parentheses, and the slowness. But, they also took advantage of the powerful macro facility.
It's powerful to re-code time critical snippets of code in Assembler, while still having access to a high level language like Lisp for the complex stuff.
It might interest people to know that Forth always offered this functionality and the ':' compiler lets one build ASM macros as well.
The old Lisp 1.5 manual documents an in-memory assembler in Appendix C, Page 73
http://www.softwarepreservation.org/projects/LISP/book/LISP%...
Neat!
Here's an example of GOAL code with inline code for the vector processors.
https://web.archive.org/web/20070127022728/http://lists.midn...
I'm working on a hobbyist rocketry project where I'm helping build the flight computer - basically an Arduino Nano connected to modules like a GPS system, accelerator, gyroscope, etc. Are there any Lisp dialects that someone would recommend for an Arduino? The Nano is technically replaceable so if there are better boards that can use Lisp I'd be interested too!
https://news.ycombinator.com/item?id=11790630
that said more powerful scheme features like tail recursion and macro systems may or may not be compatible with a more embedded scheme, so I wouldn't count on it being a full 'representative' of what scheme actually is - this may or may not matter, depending on the project
I've played with drivers using ulisp and its fun and very fast on an adafruit SAMD51 board with plenty of storage. A Metro M4 Gran Central is a lovely dev board but too large for OP to launch.
Maybe an adafruit M4 feather board would work. I've not used one but its supposedly plug and play with ulisp, so I've heard.
I've never used one, but in theory a mattairtech.com product seems like what OP wants. ulisp should compile its just another SAMD51 board, right? And its available with some of the sensors OP wanted onboard. Note that "never used one" means OP will literally be breaking new ground. All I'm sure of its a physically very small SAMD51 board and I can't see any obvious reason ulisp wouldn't work.
The future of embeded dev is probably FPGA for custom hardware and interfaces with lisp or similar HLL (Straight up Clojure getting embedded?). No I don't mean tomorrow future, but maybe 2030.
I'm not an Arduino person, but maybe there's a Common Lisp variant available to you.
I had the most luck installing the Zulu Embedded version of Java, and I've had a Clojure webapp running on my Pi Zero for over a week now without any hiccups.
I'm a post or two behind on chronicling my adventures, but I did at least capture how I got Clojure running on the Zero here: https://ajpierce.com/2020-01-08_safe-to-wake-pt4/
My plan at the time was to use a serial protocol and interface with a Nintendo GBA/DS for this kind of interactive Lisp programming.
It feels a bit dirty mixing implementation and target language like this, but it's great fun to program for.