rubyx/lib/risc
Torsten Ruger ce3cc72f9e move all position setting into position
Position and subclasses handle the logic, external to
the classes, so it can be swapped out later
(at runtime positions can’t change)
2018-05-07 22:30:43 +03:00
..
builtin use hex for labels 2018-05-01 19:20:16 +03:00
instructions move all position setting into position 2018-05-07 22:30:43 +03:00
binary_writer.rb fix (re)positioning when link exceptions are thrown 2018-05-01 19:48:11 +03:00
boot.rb implement larger/smaller or equal 2018-04-24 19:45:58 +03:00
builder.rb implement smaller than comparison 2018-04-19 22:41:40 +03:00
collector.rb don't collect labels anymore 2018-03-27 19:06:16 +03:00
instruction.rb let builder pass the source down, but inly once 2018-04-18 19:27:46 +03:00
interpreter.rb first resolved call running though 2018-04-08 23:45:23 +03:00
machine.rb move all position setting into position 2018-05-07 22:30:43 +03:00
method_compiler.rb pass a source into the builder 2018-04-18 19:12:30 +03:00
padding.rb rename register to risc 2017-01-19 09:02:29 +02:00
position.rb move all position setting into position 2018-05-07 22:30:43 +03:00
README.md polish docs 2018-03-11 16:11:15 +05:30
risc_value.rb bit more regs, bit more resets 2018-04-08 22:29:08 +03:00
text_writer.rb rename Position get/set 2018-05-06 20:04:02 +03:00

Risc Machine

The RiscMachine, is an abstract machine with registers. Think of it as an arm machine with normal instruction names. It is not however an abstraction of existing hardware, but only of that subset that we need.

Our primary objective is to compile typed code to this level, so the register machine has:

  • object access instructions
  • object load
  • object oriented call semantics
  • extended (and extensible) branching
  • normal integer operators (but no sub word instructions)

All data is in objects.

The register machine is aware of Parfait objects, and specifically uses Message and Frame to express call semantics.

Calls and syscalls

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)

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.

Syscalls are implemented by one Syscall instruction. The Risc machine does not specify/limit the meaning or number of syscalls. This is implemented by the level below, eg the arm/interpreter.

Interpreter

There is an interpreter that can interpret compiled register machine programs. This is very handy for debugging (and nothing else).

Even more handy is the graphical interface for the interpreter, which is in it's own repository: rubyx-debugger.

Arm / Elf

There is also a (very straightforward) transformation to arm instructions. Together with the also quite minimal elf module, arm binaries can be produced.

These binaries have no external dependencies and in fact can not even call c at the moment (only syscalls :-)).