Add Memory Controllers for SP and PP, add Instruction Set
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Program;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class Block
|
||||
{
|
||||
public string $N;
|
||||
@@ -20,4 +22,27 @@ class Block
|
||||
{
|
||||
$this->words[] = $word;
|
||||
}
|
||||
|
||||
|
||||
public function valueOf(string $register): int
|
||||
{
|
||||
foreach ($this->words as $word) {
|
||||
if ($word->register === $register) {
|
||||
return $word->value;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("No word in block for register '$register'");
|
||||
}
|
||||
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$buffer = "$this->N\t";
|
||||
foreach ($this->words as $word) {
|
||||
$buffer .= "$word\t";
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user