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