blob: c2bebe4007ac11af6a3f04490cc8196ab6d6e04b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
---
vim: noexpandtab tabstop=2 shiftwidth=2
---
# Snug
Snug is a lazy functional programming language. It is designed to be tiny in
memory footprint of both generated code and run time memory use, so that it can
run on embedded systems.
The current goal is to be able to run a Snug compiler written in Snug on a
[PIC32MZ2048EFG064][]. This microcontroller has 2MB flash memory, 512KB SRAM,
and a MIPS32 instruction set (with microMIPS code compression).
The end goal is as follows:
1. The microcontroller has access to a flash drive or SD card with a basic file
system.
2. The kernel contains a basic terminal application and can run programs from
the external memory. To this end it dynamically loads these programs into
RAM and executes from RAM.
3. There is an application to edit text files.
4. The Snug compiler is just one of these programs, and was compiled from Snug
itself. It outputs human-readable assembly code.
5. A basic assembler (presumably written in C) can turn this output into object
code.
6. A linker (presumably written in C) can link several object code files
together into an executable program.
7. Combining steps 3-6, possibly using a `make`-like program, enables the user
to edit, compile, and run new Snug programs entirely on the embedded system.
Before we can accomplish this some intermediate steps are required:
1. At first the compiler is written in [Clean][], and we use an assembler and
linker on a PC. This way an executable compiler can be built entirely on a
PC.
2. The next step is to test how much RAM the compiler requires. It should be
able to compile reasonably large programs with only 512KB of RAM (and
actually less, because part of the RAM must be reserved for the kernel and
to hold the program itself).
3. After this a basic assembler and linker can be written. If these are written
in C it is easily possible to test them on a PC.
[Clean]: https://clean-lang.org
[PIC32MZ2048EFG064]: https://www.microchip.com/en-us/product/PIC32MZ2048EFG064
|