def test_jms_scenario1(address12):
    """Test JMS instruction functionality."""
    chip_test = Processor()
    chip_base = Processor()

    # Simulate conditions at end of instruction in base chip
    chip_base.PROGRAM_COUNTER = 300
    chip_base.write_to_stack(chip_base.PROGRAM_COUNTER + 2)
    chip_base.PROGRAM_COUNTER = address12 - 1

    # Set up conditions in test chip
    chip_test.PROGRAM_COUNTER = 300

    # Perform the instruction under test:
    # Jump to a subroutine
    Processor.jms(chip_test, address12)

    # Make assertions that the base chip is now at the same state as
    # the test chip which has been operated on by the instruction under test.

    assert chip_test.PROGRAM_COUNTER == address12 - 1
    assert chip_test.STACK_POINTER == 1
    assert chip_test.STACK[chip_test.STACK_POINTER + 1] == 302  # Return

    # Pickling each chip and comparing will show equality or not.
    assert pickle.dumps(chip_test) == pickle.dumps(chip_base)
def test_jms_scenario2(address12):
    """Test JMS instruction failure."""
    chip_test = Processor()

    # Simulate conditions at START of operation in base chip
    # chip should have not had any changes as the operations will fail
    # N/A

    # Simulate conditions at END of operation in test chip
    # chip should have not had any changes as the operations will fail
    # N/A

    # attempting to use an invalid value
    with pytest.raises(Exception) as e:
        assert Processor.jms(chip_test, address12)
    assert str(e.value) == ' Value: ' + str(address12)
    assert e.type == ValueOutOfRangeForStack