2018-03-11 11:41:15 +01:00
|
|
|
# Risc Machine
|
2014-04-25 12:29:12 +02:00
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
The RiscMachine, is an abstract machine with registers. Think of it as an arm machine with
|
2015-10-22 16:38:49 +02:00
|
|
|
normal instruction names. It is not however an abstraction of existing hardware, but only
|
|
|
|
of that subset that we need.
|
2014-04-25 12:29:12 +02:00
|
|
|
|
2016-12-11 11:55:03 +01:00
|
|
|
Our primary objective is to compile typed code to this level, so the register machine has:
|
2015-10-22 16:38:49 +02:00
|
|
|
- object access instructions
|
|
|
|
- object load
|
|
|
|
- object oriented call semantics
|
|
|
|
- extended (and extensible) branching
|
|
|
|
- normal integer operators (but no sub word instructions)
|
2014-04-25 12:29:12 +02:00
|
|
|
|
2015-10-22 16:38:49 +02:00
|
|
|
All data is in objects.
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2015-10-22 16:38:49 +02:00
|
|
|
The register machine is aware of Parfait objects, and specifically uses Message and Frame to
|
|
|
|
express call semantics.
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2018-03-11 11:41:15 +01:00
|
|
|
## Calls and syscalls
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2018-03-11 11:41:15 +01:00
|
|
|
The RiscMachine only uses 1 fixed register, the currently worked on Message. (and assumes a
|
|
|
|
program counter and flags, neither of which are directly manipulated)
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2018-03-11 11:41:15 +01:00
|
|
|
There is no stack, rather messages form a linked list, and preparing to call, the data is
|
|
|
|
pre-filled into the next message. Calling then means moving the new message to the current
|
|
|
|
one and jumping to the address of the method. Returning is the somewhat reverse process.
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
Syscalls are implemented by *one* Syscall instruction. The Risc machine does not specify/limit
|
2015-10-22 16:38:49 +02:00
|
|
|
the meaning or number of syscalls. This is implemented by the level below, eg the arm/interpreter.
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2018-03-11 11:41:15 +01:00
|
|
|
## Interpreter
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2015-10-22 16:38:49 +02:00
|
|
|
There is an interpreter that can interpret compiled register machine programs.
|
2018-03-11 11:41:15 +01:00
|
|
|
This is very handy for debugging (and nothing else).
|
2014-05-25 09:57:56 +02:00
|
|
|
|
2015-10-22 16:38:49 +02:00
|
|
|
Even more handy is the graphical interface for the interpreter, which is in it's own repository:
|
2017-08-29 17:38:51 +02:00
|
|
|
rubyx-debugger.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2018-03-11 11:41:15 +01:00
|
|
|
## Arm / Elf
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2018-03-11 11:41:15 +01:00
|
|
|
There is also a (very straightforward) transformation to arm instructions.
|
2015-10-22 16:38:49 +02:00
|
|
|
Together with the also quite minimal elf module, arm binaries can be produced.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-10-22 16:38:49 +02:00
|
|
|
These binaries have no external dependencies and in fact can not even call c at the moment
|
|
|
|
(only syscalls :-)).
|