A Register Machine Package
Project description
py_register_machine2
********************
A Register Machine package for Python3
You might take a look at the `docs<https://daknuett.github.io/py_register_machine2>` for a lot information about design, usage and the complete code documentation.
Installing PyRegisterMachine2
=============================
`py_register_machine2` is a python3 package, so all you need to do is to place the project folder in your
`$PYTHONPATH`. You are able to get the pythonpath using `echo $PYTHONPATH` and `python3 -c "import sys; print(sys.path)"`.
So you are able to install the package using::
cd /usr/local/lib/python3.5/dist-packages/
git clone https://github.com/daknuett/py_register_machine2
Or::
python3 -m pip install py_register_machine2
Using PyRegisterMachine2
========================
Using Prepared Machines
-----------------------
In ``py_register_machine2.machines`` is a bunch of modules providing a bunch of _register machine definitions_
those are functions returning a 4-tuple: ``(processor, rom, ram, flash)``, maybe you need to invoke ``processor.setup_done()``.
Creating Your Own Machines
--------------------------
If the prepared machines do not match your requirements you might want to create your own machines,
to do so you should study the `docs<https://daknuett.github.io/py_register_machine2/machines.html`.
Instructionset, Machinecode and Assembly
----------------------------------------
The Instructionset of a machine is defined by obhects inherited from ``py_register_machine2.core.commands.BaseCommand``,
a bunch of ready-to-use commands is in ``py_register_machine2.commands``.
The processor reads one word of data for the opcode, decodes this opcode and reads n words of data for n arguments.
Machinecode can be witten using ``list`` objects like this::
program = [0x16, 0x01, 0x01] # using the py_register_machine2.commands.basic_commands instructionset
# this equals "ldi 0x01 ECR" and will halt the engine.
This machinecode can be programmed to a persistent device (ROM or Flash) using ::
rom.program(program)
# or
flash.program(program)
There is a basic Assembler in ``py_register_machine2.tools.assembler.assembler`` that uses the KASM2 assembly language to generate
machiecode ( a ``list`` object)
The Assembler uses a configured Processor and an open stream to generate the machinecode::
from io import StringIO
processor.setup_done()
progstr = "ldi 0x01 ECR"
asm = Assembler(processor, StringIO(progstr))
program = asm.assemble()
Once the ROM is programmed (the Processor starts executing code in the ROM) you are able to run the code using::
processor.run()
********************
A Register Machine package for Python3
You might take a look at the `docs<https://daknuett.github.io/py_register_machine2>` for a lot information about design, usage and the complete code documentation.
Installing PyRegisterMachine2
=============================
`py_register_machine2` is a python3 package, so all you need to do is to place the project folder in your
`$PYTHONPATH`. You are able to get the pythonpath using `echo $PYTHONPATH` and `python3 -c "import sys; print(sys.path)"`.
So you are able to install the package using::
cd /usr/local/lib/python3.5/dist-packages/
git clone https://github.com/daknuett/py_register_machine2
Or::
python3 -m pip install py_register_machine2
Using PyRegisterMachine2
========================
Using Prepared Machines
-----------------------
In ``py_register_machine2.machines`` is a bunch of modules providing a bunch of _register machine definitions_
those are functions returning a 4-tuple: ``(processor, rom, ram, flash)``, maybe you need to invoke ``processor.setup_done()``.
Creating Your Own Machines
--------------------------
If the prepared machines do not match your requirements you might want to create your own machines,
to do so you should study the `docs<https://daknuett.github.io/py_register_machine2/machines.html`.
Instructionset, Machinecode and Assembly
----------------------------------------
The Instructionset of a machine is defined by obhects inherited from ``py_register_machine2.core.commands.BaseCommand``,
a bunch of ready-to-use commands is in ``py_register_machine2.commands``.
The processor reads one word of data for the opcode, decodes this opcode and reads n words of data for n arguments.
Machinecode can be witten using ``list`` objects like this::
program = [0x16, 0x01, 0x01] # using the py_register_machine2.commands.basic_commands instructionset
# this equals "ldi 0x01 ECR" and will halt the engine.
This machinecode can be programmed to a persistent device (ROM or Flash) using ::
rom.program(program)
# or
flash.program(program)
There is a basic Assembler in ``py_register_machine2.tools.assembler.assembler`` that uses the KASM2 assembly language to generate
machiecode ( a ``list`` object)
The Assembler uses a configured Processor and an open stream to generate the machinecode::
from io import StringIO
processor.setup_done()
progstr = "ldi 0x01 ECR"
asm = Assembler(processor, StringIO(progstr))
program = asm.assemble()
Once the ROM is programmed (the Processor starts executing code in the ROM) you are able to run the code using::
processor.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_register_machine2-0.0.2.tar.gz
(17.5 kB
view hashes)
Built Distribution
Close
Hashes for py_register_machine2-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5fdb6c1b869ff5f53072de17722fc86e4ba015cd459b02b6058c579079973c9 |
|
MD5 | d53087f468751335b509e072578c1867 |
|
BLAKE2b-256 | 6cde06b7d302a093df5432bb673cd1a3dd5e01eb19bab2a221f9076d0f0d886e |
Close
Hashes for py_register_machine2-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b1c145eba21d5757e499aba8fd22757801605341152a9bd2bfc340a42b9a893 |
|
MD5 | f0ef5d53379f82475e0a691fa97e1616 |
|
BLAKE2b-256 | 2c77bc0815300221c4f5ae90aca810d0f8a01beb9817a05f4455d933c61820c5 |