eight_bit_computer.operations.jump_if_comparison_base module

Base functionality for the the JUMP_IF_***_ACC operations.

Except JUMP_IF_EQ_ACC

eight_bit_computer.operations.jump_if_comparison_base.generate_microcode_templates(instruction_group, instruction_byte_const_bitdef, instruction_byte_arg_bitdef_dict, alu_flag_gen_bitdefs, true_flag_bitdefs, false_flag_bitdefs)[source]

Generate microcode for this JUMP_IF_***_ACC operations.

Parameters:
  • instruction_group (str) – Bitdef representing the instruction group for the instruction byte.
  • instruction_byte_const_bitdef (str) – Bitdef representing the part of the instruction byte that remains the same regardless of the arguments. Could be on the source side or the dest side.
  • (dist(str (instruction_byte_arg_bitdef_map) – str)): Dictionary that contains the bitdefs which map to the arguments used. On the complementary side (i.e. src vs. dest) to the side used by the instruction_byte_const_bitdef.
  • alu_flag_gen_bitdefs (list(str)) – List of bitdefs that make up the control flags for the ALU to generate the appropriate flags.
  • true_flag_bitdefs (list(str)) – List of bitdef that represent the flag state when the condition is true.
  • false_flag_bitdefs (list(str)) – List of bitdef that represent the flag state when the condition is false.
Returns:

DataTemplates for all the JUMP_IF_***_ACC microcode.

Return type:

list(DataTemplate)

eight_bit_computer.operations.jump_if_comparison_base.generate_signatures()[source]

Generate the definitions of all possible arguments passable.

Returns:All possible arguments. See get_arg_def_template() for more information.
Return type:list(list(dict))
eight_bit_computer.operations.jump_if_comparison_base.generate_operation_templates(signature, instruction_group, instruction_byte_const_bitdef, instruction_byte_arg_bitdef_dict, alu_flag_gen_bitdefs, true_flag_bitdefs, false_flag_bitdefs)[source]

Create the DataTemplates to define a JUMP_IF_***_ACC with the given args.

Parameters:
  • signature (list(dict)) – List of argument definitions that specify which particular operation to generate templates for.
  • instruction_group (str) – Bitdef representing the instruction group for the instruction byte.
  • instruction_byte_const_bitdef (str) – Bitdef representing the part of the instruction byte that remains the same regardless of the arguments. Could be on the source side or the dest side.
  • (dist(str (instruction_byte_arg_bitdef_map) – str)): Dictionary that contains the bitdefs which map to the arguments used. On the complementary side (i.e. src vs. dest) to the side used by the instruction_byte_const_bitdef.
  • alu_flag_gen_bitdefs (list(str)) – List of bitdefs that make up the control flags for the ALU to generate the appropriate flags.
  • true_flag_bitdefs (list(str)) – List of bitdefs that represent the flag state when the condition is true.
  • false_flag_bitdefs (list(str)) – List of bitdefs that represent the flag state when the condition is false.
Returns:

Datatemplates that define this JUMP_IF_***_ACC operation.

Return type:

list(DataTemplate)

eight_bit_computer.operations.jump_if_comparison_base.generate_false_datatemplates(signature, instruction_group, instruction_byte_const_bitdef, instruction_byte_arg_bitdef_dict, alu_flag_gen_bitdefs, flag_bitdefs)[source]

Create DataTemplates to define a conditional jump if condition is false.

This is the case where no jump happens.

Parameters:
  • signature (list(dict)) – List of argument definitions that specify which particular not operation to generate templates for.
  • instruction_group (str) – Bitdef representing the instruction group for the instruction byte.
  • instruction_byte_const_bitdef (str) – Bitdef representing the part of the instruction byte that remains the same regardless of the arguments. Could be on the source side or the dest side.
  • (dist(str (instruction_byte_arg_bitdef_map) – str)): Dictionary that contains the bitdefs which map to the arguments used. On the complementary side (i.e. src vs. dest) to the side used by the instruction_byte_const_bitdef.
  • alu_flag_gen_bitdefs (list(str)) – List of bitdefs that make up the control flags for the ALU to generate the appropriate flags.
  • flag_bitdefs (list(str)) – List of bitdef that represent the flag state when the condition is false.
Returns:

Datatemplates that define the “false half” of a JUMP_IF_***_ACC operation.

Return type:

list(DataTemplate)

eight_bit_computer.operations.jump_if_comparison_base.generate_nonconditional_steps(signature, alu_flag_gen_bitdefs)[source]

Generate the nonconditional control steps.

These steps generate the flags which then govern whether the jump happens or not.

Parameters:
  • signature (list(dict)) – List of argument definitions that specify which particular operation to generate steps for.
  • alu_flag_gen_bitdefs (list(str)) – List of bitdefs that make up the control flags for the ALU to generate the appropriate flags.
Returns:

List of list of bitdefs that represent the steps, and the control signals at each step.

Return type:

list(list(str))

eight_bit_computer.operations.jump_if_comparison_base.generate_instruction_byte_bitdefs(signature, instruction_group, instruction_byte_const_bitdef, instruction_byte_arg_bitdef_dict)[source]

Generate bitdefs to specify the instruction byte for these args.

Parameters:
  • signature (list(dict)) – List of argument definitions that specify which particular operation to generate the instruction byte bitdefs for.
  • instruction_group (str) – Bitdef representing the instruction group for the instruction byte.
  • instruction_byte_const_bitdef (str) – Bitdef representing the part of the instruction byte that remains the same regardless of the arguments. Could be on the source side or the dest side.
  • (dist(str (instruction_byte_arg_bitdef_map) – str)): Dictionary that contains the bitdefs which map to the arguments used. On the complementary side (i.e. src vs. dest) to the side used by the instruction_byte_const_bitdef.
Returns:

Bitdefs that make up the instruction_byte

Return type:

list(str)

eight_bit_computer.operations.jump_if_comparison_base.generate_true_datatemplates(signature, instruction_group, instruction_byte_const_bitdef, instruction_byte_arg_bitdef_dict, alu_flag_gen_bitdefs, flag_bitdefs)[source]

Create DataTemplates to define a conditional jump if condition is true.

This is the case where no jump happens

Parameters:
  • signature (list(dict)) – List of argument definitions that specify which particular operation to generate templates for.
  • instruction_group (str) – Bitdef representing the instruction group for the instruction byte.
  • instruction_byte_const_bitdef (str) – Bitdef representing the part of the instruction byte that remains the same regardless of the arguments. Could be on the source side or the dest side.
  • (dist(str (instruction_byte_arg_bitdef_map) – str)): Dictionary that contains the bitdefs which map to the arguments used. On the complementary side (i.e. src vs. dest) to the side used by the instruction_byte_const_bitdef.
  • alu_flag_gen_bitdefs (list(str)) – List of bitdefs that make up the control flags for the ALU to generate the appropriate flags.
  • flag_bitdefs (list(str)) – List of bitdef that represent the flag state when the condition is true.
Returns:

Datatemplates that define the “true half” of a JUMP_IF_***_ACC operation.

Return type:

list(DataTemplate)

eight_bit_computer.operations.jump_if_comparison_base.parse_line(line, name, instruction_group, instruction_byte_const_bitdef, instruction_byte_arg_bitdef_dict)[source]

Parse a line of assembly code to create machine code byte templates.

If a line is not identifiably a JUMP_IF_***_ACC assembly line, return an empty list instead.

Parameters:
  • line (str) – Assembly line to be parsed.
  • name (str) – Name of the operation. E.g. JUMP_IF_LT_ACC.
  • instruction_group (str) – Bitdef representing the instruction group for the instruction byte.
  • instruction_byte_const_bitdef (str) – Bitdef representing the part of the instruction byte that remains the same regardless of the arguments. Could be on the source side or the dest side.
  • (dist(str (instruction_byte_arg_bitdef_map) – str)): Dictionary that contains the bitdefs which map to the arguments used. On the complementary side (i.e. src vs. dest) to the side used by the instruction_byte_const_bitdef.
Returns:

List of instruction byte template dictionaries or an empty list.

Return type:

list(dict)