1: <?php
2:
3: namespace Csim\Model;
4:
5: /**
6: * Represents one instruction.
7: */
8: class Instruction {
9:
10: private $instruction_type;
11: private $address;
12:
13: /**
14: * Constructs a new Instruction of the specified type that operates on the specified address.
15: */
16: public function __construct($type, $address) {
17: $this->instruction_type = $type;
18: $this->address = $address;
19: }
20:
21: /**
22: * Returns true is this is a load instruction, otherwise returns false.
23: *
24: * @return boolean
25: */
26: public function isLoad() {
27: return $this->instruction_type === \Csim\Model\InstructionType::LOAD;
28: }
29:
30: /**
31: * Returns true if this instruction's address has the bits in the specified bit mask equal
32: * to those of the specified address. Otherwise returns false.
33: *
34: * @param integer $address - The address to compare with this instruction's address.
35: * @param integer $bitCount - The bit mask specifying which bits to compare to compare.
36: */
37: public function addressEquals($address, $bit_mask) {
38: return ($this->address & $bit_mask) === ($address & $bit_mask);
39: }
40:
41: /**
42: * @return integer The address this instruction operates on.
43: */
44: public function getAddress() {
45: return $this->address;
46: }
47:
48: }
49: