-
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 #72 from ninezerozeronine/add_jump_if_flag_ops
Add jump if flag ops. Update tox to fix coverage/coveralls version dependency bug.
- Loading branch information
Showing
17 changed files
with
786 additions
and
2 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
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
41 changes: 41 additions & 0 deletions
41
src/eight_bit_computer/operations/jump_if_negative_flag.py
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,41 @@ | ||
""" | ||
JUMP_IF_NEGATIVE_FLAG operation | ||
""" | ||
|
||
from . import jump_if_flag_base | ||
from ..language_defs import FLAGS | ||
|
||
_NAME = "JUMP_IF_NEGATIVE_FLAG" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the JUMP_IF_NEGATIVE_FLAG instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the | ||
JUMP_IF_NEGATIVE_FLAG instructions. | ||
""" | ||
|
||
return jump_if_flag_base.generate_microcode_templates( | ||
"C", | ||
FLAGS["NEGATIVE"]["HIGH"], | ||
FLAGS["NEGATIVE"]["LOW"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a JUMP_IF_NEGATIVE_FLAG 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 jump_if_flag_base.parse_line(line, "C", _NAME) |
41 changes: 41 additions & 0 deletions
41
src/eight_bit_computer/operations/jump_if_not_overflow_flag.py
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,41 @@ | ||
""" | ||
JUMP_IF_NOT_OVERFLOW_FLAG operation | ||
""" | ||
|
||
from . import jump_if_flag_base | ||
from ..language_defs import FLAGS | ||
|
||
_NAME = "JUMP_IF_NOT_OVERFLOW_FLAG" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the JUMP_IF_NOT_OVERFLOW_FLAG instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the | ||
JUMP_IF_NOT_OVERFLOW_FLAG instructions. | ||
""" | ||
|
||
return jump_if_flag_base.generate_microcode_templates( | ||
"PC", | ||
FLAGS["CARRY_BORROW"]["LOW"], | ||
FLAGS["CARRY_BORROW"]["HIGH"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a JUMP_IF_NOT_OVERFLOW_FLAG 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 jump_if_flag_base.parse_line(line, "PC", _NAME) |
41 changes: 41 additions & 0 deletions
41
src/eight_bit_computer/operations/jump_if_not_underflow_flag.py
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,41 @@ | ||
""" | ||
JUMP_IF_NOT_UNDERFLOW_FLAG operation | ||
""" | ||
|
||
from . import jump_if_flag_base | ||
from ..language_defs import FLAGS | ||
|
||
_NAME = "JUMP_IF_NOT_UNDERFLOW_FLAG" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the JUMP_IF_NOT_UNDERFLOW_FLAG instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the | ||
JUMP_IF_NOT_UNDERFLOW_FLAG instructions. | ||
""" | ||
|
||
return jump_if_flag_base.generate_microcode_templates( | ||
"CONST", | ||
FLAGS["CARRY_BORROW"]["HIGH"], | ||
FLAGS["CARRY_BORROW"]["LOW"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a JUMP_IF_NOT_UNDERFLOW_FLAG 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 jump_if_flag_base.parse_line(line, "CONST", _NAME) |
41 changes: 41 additions & 0 deletions
41
src/eight_bit_computer/operations/jump_if_not_zero_flag.py
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,41 @@ | ||
""" | ||
JUMP_IF_NOT_ZERO_FLAG operation | ||
""" | ||
|
||
from . import jump_if_flag_base | ||
from ..language_defs import FLAGS | ||
|
||
_NAME = "JUMP_IF_NOT_ZERO_FLAG" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the JUMP_IF_NOT_ZERO_FLAG instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the | ||
JUMP_IF_NOT_ZERO_FLAG instructions. | ||
""" | ||
|
||
return jump_if_flag_base.generate_microcode_templates( | ||
"A", | ||
FLAGS["ZERO"]["LOW"], | ||
FLAGS["ZERO"]["HIGH"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a JUMP_IF_NOT_ZERO_FLAG 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 jump_if_flag_base.parse_line(line, "A", _NAME) |
41 changes: 41 additions & 0 deletions
41
src/eight_bit_computer/operations/jump_if_positive_flag.py
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,41 @@ | ||
""" | ||
JUMP_IF_POSITIVE_FLAG operation | ||
""" | ||
|
||
from . import jump_if_flag_base | ||
from ..language_defs import FLAGS | ||
|
||
_NAME = "JUMP_IF_POSITIVE_FLAG" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the JUMP_IF_POSITIVE_FLAG instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the | ||
JUMP_IF_POSITIVE_FLAG instructions. | ||
""" | ||
|
||
return jump_if_flag_base.generate_microcode_templates( | ||
"B", | ||
FLAGS["NEGATIVE"]["LOW"], | ||
FLAGS["NEGATIVE"]["HIGH"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a JUMP_IF_POSITIVE_FLAG 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 jump_if_flag_base.parse_line(line, "B", _NAME) |
41 changes: 41 additions & 0 deletions
41
src/eight_bit_computer/operations/jump_if_underflow_flag.py
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,41 @@ | ||
""" | ||
JUMP_IF_UNDERFLOW_FLAG operation | ||
""" | ||
|
||
from . import jump_if_flag_base | ||
from ..language_defs import FLAGS | ||
|
||
_NAME = "JUMP_IF_UNDERFLOW_FLAG" | ||
|
||
|
||
def generate_microcode_templates(): | ||
""" | ||
Generate microcode for all the JUMP_IF_UNDERFLOW_FLAG instructions. | ||
Returns: | ||
list(DataTemplate): DataTemplates for all the | ||
JUMP_IF_UNDERFLOW_FLAG instructions. | ||
""" | ||
|
||
return jump_if_flag_base.generate_microcode_templates( | ||
"SP+/-", | ||
FLAGS["CARRY_BORROW"]["LOW"], | ||
FLAGS["CARRY_BORROW"]["HIGH"], | ||
) | ||
|
||
|
||
def parse_line(line): | ||
""" | ||
Parse a line of assembly code to create machine code byte templates. | ||
If a line is not identifiably a JUMP_IF_UNDERFLOW_FLAG 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 jump_if_flag_base.parse_line(line, "SP+/-", _NAME) |
Oops, something went wrong.