py_register_machine2.machines

A collection of register machines in different states of configuration.

Small Machines

py_register_machine2.machines.small: a collection of small ready to use register machines

py_register_machine2.machines.small.small_register_machine(rom_size=50, ram_size=200, flash_size=500)[source]

An unprogrammend Register Machine with

  • one OutputRegister to sys.stdout (out0)
  • 15 General Purpose Register (r0 - r14)

returns : (Processor, ROM, RAM, Flash)

Machines for Curriculae

py_register_machine2.machines.gym_bav_16

A register machine compatible to the schedule of the bavarian gymnasium.

Differences:

  • Register names are rX instead of X (i.e. r5 instead of 5)
  • The Program Counters are unused
  • Comments start with ; instead of --. (see this)

Examples

Old style:

0: DLOAD 1 -- load stuff
1: STORE 1 -- store stuff
2: DLOAD 5
3: SUB 1
4: HALT

New style:

DLOAD 1 ; load stuff
; comments can take a complete line
; store stuff
STORE r1
DLOAD 5
SUB r1
HALT

Note:

You are able to change the commentstart strings using the argument commentstarts:

asm = Assembler(processor, stream, commentstarts = ["--"])

Generate a register machine using

from py_register_machine2.machines.gym_bav_16 import machine
processor, rom, ram, flash = machine()

Note:

This machine does not provide a RAM or Flash device by default. You can change the number of registers and the size of the ROM by passing the attributes to the function machine(romsize = 200, numregister = 15)