| 1 | package com.rox.mem; | |
| 2 | ||
| 3 | /** | |
| 4 | * 16bit addressed, 8bit data memory | |
| 5 | */ | |
| 6 | public class Latched8BitMemoryBus implements LatchedMemoryBus { | |
| 7 | private final MemoryBus memoryBus; //XXX: Should probably make this MemoryBus8Bit which would do the masking for us | |
| 8 | private int addressedMemory; | |
| 9 | ||
| 10 | public final static int ADDRESS_MASK = 0xFFFF; | |
| 11 | public final static int DATA_MASK = 0xFF; | |
| 12 | ||
| 13 | public Latched8BitMemoryBus(final MemoryBus memoryBus){ | |
| 14 | this.memoryBus = memoryBus; | |
| 15 | } | |
| 16 | ||
| 17 | @Override | |
| 18 | public void loadMemoryAddress(final int memory) { | |
| 19 |
1
1. loadMemoryAddress : Replaced bitwise AND with OR → KILLED |
this.addressedMemory = memory & ADDRESS_MASK; |
| 20 | } | |
| 21 | ||
| 22 | @Override | |
| 23 | public int getAddressedMemory(){ | |
| 24 |
2
1. getAddressedMemory : Replaced bitwise AND with OR → KILLED 2. getAddressedMemory : replaced int return with 0 for com/rox/mem/Latched8BitMemoryBus::getAddressedMemory → KILLED |
return this.addressedMemory & ADDRESS_MASK; |
| 25 | } | |
| 26 | ||
| 27 | @Override | |
| 28 | public int fetch() { | |
| 29 |
1
1. fetch : replaced int return with 0 for com/rox/mem/Latched8BitMemoryBus::fetch → KILLED |
return memoryBus.read(addressedMemory); |
| 30 | } | |
| 31 | ||
| 32 | @Override | |
| 33 | public void store(final int value) { | |
| 34 |
2
1. store : Replaced bitwise AND with OR → KILLED 2. store : removed call to com/rox/mem/MemoryBus::write → KILLED |
memoryBus.write(addressedMemory, value & DATA_MASK); |
| 35 | } | |
| 36 | } | |
Mutations | ||
| 19 |
1.1 |
|
| 24 |
1.1 2.2 |
|
| 29 |
1.1 |
|
| 34 |
1.1 2.2 |