eight_bit_computer.main module

Top level interface for the module

eight_bit_computer.main.assemble(input_filepath, output_filepath=None, variable_start_offset=0, output_format='logisim')[source]

Read an assembly file and write out equivalent machine code.

Parameters:
  • input_filepath (str) – The location of the assembly file.
  • output_filepath (str) (optional) – The location to write out the machine code. If nothing is passed, the output path will be the input path with the extension changed to mc.
  • variable_start_offset (int) (optional) – How far to offset the first variable in data memory from 0.
  • output_format (str) (optional) – How to format the output. logisim or cpp.
eight_bit_computer.main.filepath_to_lines(input_filepath)[source]

Take a filepath and get all the lines of the file.

The lines returned have the newline stripped.

Parameters:input_filepath (str) – Path to the file of disk to read.
Returns:Lines of the file.
Return type:list(str)
eight_bit_computer.main.get_mc_filepath(asm_path)[source]

Get the filepath for the machine code.

This is the assembly filepath with .asm replaced with .mc

Parameters:asm_path (str) – Path to the assembly file.
Returns:Path to the machine code file.
Return type:str
eight_bit_computer.main.extract_machine_code(assembly_lines)[source]

Extract machine code from assembly line dictionaries.

Parameters:assembly_lines (list(dict)) – List of assembly line info dictionaries to extract machine code from. See get_assembly_line_template() for details on what those dictionaries contain.
Returns:List of bit strings for the machine code.
Return type:list(str)
eight_bit_computer.main.gen_roms(output_dir='.', rom_prefix='rom', output_format='logisim')[source]

Write files containing microcode for drive the roms.

Parameters:
  • output_dir (str) (optional) – The directory to write the roms into.
  • rom_prefix (str) (optional) – The prefix for the rom files.
  • output_format (str) (optional) – How to foramt the output. logisim or cpp.