2019-03-15 13:06:56 +01:00
|
|
|
# Internals: The Retro Image
|
|
|
|
|
2021-05-12 15:57:22 +02:00
|
|
|
The actual Retro language is stored as a memory image for Nga.
|
2019-03-15 13:06:56 +01:00
|
|
|
|
2019-03-19 19:31:59 +01:00
|
|
|
## Format
|
|
|
|
|
|
|
|
The image file is a flat, linear sequence of signed 32-bit
|
|
|
|
values. Each value is stored in little endian format. The
|
|
|
|
size is not fixed. An interface should check when loading to
|
|
|
|
ensure that the physical image is not larger than the emulated
|
|
|
|
memory.
|
|
|
|
|
|
|
|
## Header
|
|
|
|
|
|
|
|
The image will start with two cells. The first is a liju....
|
|
|
|
instruction, the second is the target address for the jump.
|
|
|
|
This serves to skip over the rest of the data and reach the
|
|
|
|
actual entry point.
|
|
|
|
|
|
|
|
This is followed by a pointer to the most recent dictionary
|
|
|
|
header, a pointer to the next free address in memory, and
|
2021-05-12 15:57:22 +02:00
|
|
|
then the Retro version number.
|
2019-03-19 19:31:59 +01:00
|
|
|
|
|
|
|
| Offset | Contains |
|
|
|
|
| ------ | --------------------------- |
|
|
|
|
| 0 | lit call nop nop |
|
|
|
|
| 1 | Pointer to main entry point |
|
|
|
|
| 2 | Dictionary |
|
|
|
|
| 3 | Heap |
|
2021-05-12 15:57:22 +02:00
|
|
|
| 4 | Retro version |
|
2019-03-19 19:31:59 +01:00
|
|
|
|
|
|
|
The actual code starts after this header.
|
|
|
|
|
|
|
|
The version number is the year and month. As an example,
|
|
|
|
the 12.2019.6 release will have a version number of
|
|
|
|
`201906`.
|
|
|
|
|
2019-03-15 19:35:34 +01:00
|
|
|
## Layout
|
|
|
|
|
|
|
|
Assuming an Nga built with 524287 cells of memory:
|
|
|
|
|
2019-03-19 19:31:59 +01:00
|
|
|
| RANGE | CONTAINS |
|
|
|
|
| --------------- | ---------------------------- |
|
2021-05-12 15:57:22 +02:00
|
|
|
| 0 - 1024 | Retro Core kernel |
|
2019-03-19 19:31:59 +01:00
|
|
|
| 1025 - 1535 | token input buffer |
|
|
|
|
| 1536 + | start of heap space |
|
|
|
|
| ............... | free memory for your use |
|
|
|
|
| 506879 | buffer for string evaluate |
|
|
|
|
| 507904 | temporary strings (32 * 512) |
|
|
|
|
| 524287 | end of memory |
|
2019-03-15 19:35:34 +01:00
|
|
|
|
|
|
|
The buffers at the end of memory will resize when specific
|
|
|
|
variables related to them are altered.
|