Skip to content

Running console emulator

Rodion Gorkovenko edited this page Jan 24, 2015 · 2 revisions

You can download the project in a zip file from main page or by this link.

You will get few files like this:

  • main.py - the main file of console emulator, you will run it with your Python (2.7+) interpreter
  • examples - the folder which contains few sample programs in 4004 assembly language
  • interpreter.py - this module parses your program and converts it into executable form
  • executor.py - this module executes interpreted program - it contains code of all implemented instructions
  • consolex.py - this extension to executor provides custom console-dealing subroutines

So if your program is in the file yourcode.asm, you can run it with the command line:

$ python main.py yourcode.asm

If you will supply few more parameters in the form of hexadecimal digits, they will be used to initialize registers (starting from r0) so for example if you run

$ python main.py examples/test.asm 8 1 2

Then before running your code registers would be set to r0=8, r1=1, r2=2.

If your program contains custom calls dealing with console, you will be expected to input something. You may try, for example, run this:

$ python main.py examples/toupper.asm
John Doe
JOHN DOE

Here the second line should be typed in by you after starting the program - and the third is printed by the program in response.


Next: Using Online Emulator