-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from ninezerozeronine/add_simple_alu_instructions
Add simple alu instructions
- Loading branch information
Showing
24 changed files
with
1,237 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
docs/software/source/eight_bit_computer.operations.and_op.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eight\_bit\_computer.operations.and\_op module | ||
============================================== | ||
|
||
.. automodule:: eight_bit_computer.operations.and_op | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eight\_bit\_computer.operations.or\_op module | ||
============================================= | ||
|
||
.. automodule:: eight_bit_computer.operations.or_op | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eight\_bit\_computer.operations.sub module | ||
========================================== | ||
|
||
.. automodule:: eight_bit_computer.operations.sub | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
AND Operation | ||
""" | ||
|
||
from . import simple_alu_op_base | ||
|
||
from ..language_defs import ( | ||
ALU_OPERATIONS, | ||
ALU_CONTROL_FLAGS, | ||
instruction_byte_from_bitdefs, | ||
) | ||
|
||
_NAME = "AND" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the AND instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the AND instructions. | ||
""" | ||
|
||
return simple_alu_op_base.generate_microcode_templates( | ||
ALU_OPERATIONS["AND"], | ||
ALU_CONTROL_FLAGS["A_AND_B"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a AND assembly line, return an empty | ||
list instead. | ||
Args: | ||
line (str): Assembly line to be parsed. | ||
Returns: | ||
list(dict): List of machine code byte template dictionaries or | ||
an empty list. | ||
""" | ||
|
||
return simple_alu_op_base.parse_line( | ||
line, _NAME, ALU_OPERATIONS["AND"] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
NAND Operation | ||
""" | ||
|
||
from . import simple_alu_op_base | ||
|
||
from ..language_defs import ( | ||
ALU_OPERATIONS, | ||
ALU_CONTROL_FLAGS, | ||
instruction_byte_from_bitdefs, | ||
) | ||
|
||
_NAME = "NAND" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the NAND instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the NAND instructions. | ||
""" | ||
|
||
return simple_alu_op_base.generate_microcode_templates( | ||
ALU_OPERATIONS["NAND"], | ||
ALU_CONTROL_FLAGS["A_NAND_B"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a NAND assembly line, return an empty | ||
list instead. | ||
Args: | ||
line (str): Assembly line to be parsed. | ||
Returns: | ||
list(dict): List of machine code byte template dictionaries or | ||
an empty list. | ||
""" | ||
|
||
return simple_alu_op_base.parse_line( | ||
line, _NAME, ALU_OPERATIONS["NAND"] | ||
) |
Oops, something went wrong.