Bob Kanefsky writes (wrote?) lisp code for nasa/jpl mars missions.
Iirc, it’s sorta planning/verification code that parses and checks command streams intended to be sent to the landers, run way ahead of time.
It’s a great song. I really like the line about assembler...
It's a great song and kinda catchy.
The bit about assembler is generally true but I have a few Forth tools that make writing/testing assembly much faster and a lot easier than traditional assembly methods.
What you're looking at here is in fact Forth code, looks a lot like assembly doesn't it ? Forth can do that
: ms ( u -- ) \ Blocking delay for use on STM32F0xx @ 8MHz RC Clock. "1000 ms" = 1 second delay
l-: ldr= r0 1913
l-: subs r0 #1
bne -
subs r6 #1
bne --
drop
;
This is the actual "ms" Word disassembly after it has been compiled by Forth: The movs,lsls and adds commands are the only way to load a Cortex-M0 register with a value greater than 8 bits without referencing the PC (using Thumb). The ldr= Word works out the shortest possible sequence of movs,lsls and adds for the given value. If you shift 0xef left 3 places then add 1, you get 1913.
: calc $ef 3 lshift 1 + . cr ; ok.
calc 1913
"ms" Word disassembly
--------------------------------
200005B8: 20EF movs r0 #EF
200005BA: 00C0 lsls r0 r0 #3
200005BC: 3001 adds r0 #1
200005BE: 3801 subs r0 #1
200005C0: D1FD bne 200005BE
200005C2: 3E01 subs r6 #1
200005C4: D1F8 bne 200005B8
Once I've developed my delay word and tested it, I can then just inline the Machine Code into a Forth Word like this, which doesn't need the "Interactive Assembler" facility I used above:
: ms ( u -- ) \ millisecond blocking delay for Cortex-m0 with 8MHz rc clock (mecrisp-stellaris default)
[
$20EF h,
$00C0 h,
$3001 h,
$3801 h,
$D1FD h,
$3E01 h,
$D1F8 h,
] drop
;