added a new ToString method to Word, DWord, and QWord classes.
The ToString method will concatenate the string representations of the high and low words (or dwords) to create a single string representation of the entire word. This can be used to more easily write and read the value from the MC and CU classes.
This commit is contained in:
@@ -27,7 +27,7 @@ namespace CPUSimulation
|
||||
}
|
||||
}
|
||||
|
||||
public Word Read(Int16 address)
|
||||
public string Read(Int16 address)
|
||||
{
|
||||
AddressOkay(address);
|
||||
Byte[] byteData = new Byte[_numberOfMemoryBanks];
|
||||
@@ -35,7 +35,22 @@ namespace CPUSimulation
|
||||
{
|
||||
byteData[i] = _memoryBanks[i].Read(new Address(address).ToString());
|
||||
}
|
||||
return new Word(byteData);
|
||||
if (byteData.Length == 2)
|
||||
{
|
||||
return new Word(byteData).ToString();
|
||||
}
|
||||
else if (byteData.Length == 4)
|
||||
{
|
||||
return new DWord(new Word(byteData.Take(2).ToArray()), new Word(byteData.Skip(2).Take(2).ToArray())).ToString();
|
||||
}
|
||||
else if (byteData.Length == 8)
|
||||
{
|
||||
return new QWord(new DWord(new Word(byteData.Take(2).ToArray()), new Word(byteData.Skip(2).Take(2).ToArray())), new DWord(new Word(byteData.Skip(4).Take(2).ToArray()), new Word(byteData.Skip(6).Take(2).ToArray()))).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"Number of memory banks must be between 1 and 8 (inclusive).");
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(Int16 address, Word data)
|
||||
|
||||
Reference in New Issue
Block a user