Skip to content

Commit

Permalink
More quality improvements
Browse files Browse the repository at this point in the history
Also - all tests now using convert_to_absolute_address
  • Loading branch information
alshapton committed Oct 9, 2021
1 parent 2abe70a commit 6ba9051
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyntel4004/src/hardware/instructions/io_ram.py
Expand Up @@ -494,7 +494,7 @@ def sbm(self, register: int):
address = self.COMMAND_REGISTER
chip = int(bin(int(address))
[2:].zfill(8)[:2], 2)
register = int(bin(int(address))[2:].zfill(8)[2:4], 2)
register = int(bin(int(address))[2:].zfill(8)[2:4], 2)
absolute_address = convert_to_absolute_address(
self, crb, chip, register, address)
value = self.RAM[absolute_address]
Expand Down
2 changes: 1 addition & 1 deletion pyntel4004/src/hardware/suboperation.py
Expand Up @@ -37,7 +37,7 @@ def convert_to_absolute_address(self, rambank, chip, register, address):
"""
absolute_address = (rambank * self.RAM_BANK_SIZE) + \
(chip * self.RAM_CHIP_SIZE) + \
- (register * self.RAM_REGISTER_SIZE) + address
(register * self.RAM_REGISTER_SIZE) + address
return absolute_address


Expand Down
Expand Up @@ -37,9 +37,9 @@ def test_wrm_scenario1(rambank, chip, register, address):
# Perform the instruction under test:
chip_test.PROGRAM_COUNTER = 0
chip_test.CURRENT_RAM_BANK = rambank
absolute_address = (rambank * chip_test.RAM_BANK_SIZE) + \
(chip * chip_test.RAM_CHIP_SIZE) + \
(register * chip_test.RAM_REGISTER_SIZE) + address
absolute_address = convert_to_absolute_address(
chip_test, rambank, chip, register, address)
chip_test.set_accumulator(value)
b_chip = decimal_to_binary(2, chip)
b_register = decimal_to_binary(2, register)
Expand Down
12 changes: 6 additions & 6 deletions pyntel4004/test/06_io_ram/test_0200_233_instruction_rdm.py
Expand Up @@ -7,6 +7,7 @@
sys.path.insert(1, '../src')

from hardware.processor import processor # noqa
from hardware.suboperation import convert_to_absolute_address # noqa


def test_validate_rdm_instruction():
Expand All @@ -18,9 +19,9 @@ def test_validate_rdm_instruction():
assert op == known


@pytest.mark.parametrize("values", [[0, 1, 0, 7, 3], [1, 3, 1, 6, 4], [2, 5, 2, 5, 5],
[3, 7, 3, 4, 6], [4, 3, 4, 3, 7], [
5, 2, 5, 2, 2],
@pytest.mark.parametrize("values", [[0, 1, 0, 7, 3], [1, 3, 1, 6, 4],
[2, 5, 2, 5, 5], [3, 7, 3, 4, 6],
[4, 3, 4, 3, 7], [5, 2, 5, 2, 2],
[6, 0, 6, 1, 1], [7, 4, 7, 0, 0]])
def test_rdm_scenario1(values):
"""Test RDM instruction functionality."""
Expand All @@ -35,9 +36,8 @@ def test_rdm_scenario1(values):

# Perform the instruction under test:
chip_test.CURRENT_RAM_BANK = rambank
absolute_address = (rambank * chip_test.RAM_BANK_SIZE) + \
(chip * chip_test.RAM_CHIP_SIZE) + \
(register * chip_test.RAM_REGISTER_SIZE) + address
absolute_address = convert_to_absolute_address(
chip_test, rambank, chip, register, address)
chip_test.RAM[absolute_address] = value
chip_test.set_accumulator(0)
chip_test.COMMAND_REGISTER = absolute_address
Expand Down

0 comments on commit 6ba9051

Please sign in to comment.