contur2
Loading...
Searching...
No Matches
block.h
Go to the documentation of this file.
1
8
9#pragma once
10
11#include <cstdint>
12
14
15namespace contur {
16
25 struct Block
26 {
28 std::uint8_t reg = 0;
29 std::int32_t operand = 0;
30 std::int32_t state = 0;
31
33 constexpr Block() noexcept = default;
34
36 constexpr Block(Instruction code, std::uint8_t reg, std::int32_t operand, std::int32_t state = 0) noexcept
37 : code(code)
38 , reg(reg)
40 , state(state)
41 {}
42
44 [[nodiscard]] constexpr bool operator==(const Block &other) const noexcept
45 {
46 return code == other.code && reg == other.reg && operand == other.operand && state == other.state;
47 }
48
50 [[nodiscard]] constexpr bool operator!=(const Block &other) const noexcept
51 {
52 return !(*this == other);
53 }
54 };
55
56} // namespace contur
Instruction enum class — all opcodes for the bytecode interpreter.
Definition block.h:15
Instruction
CPU instruction opcodes for the simulated architecture.
Definition instruction.h:16
@ Nop
No operation.
Definition instruction.h:17
std::int32_t state
Auxiliary state / flags.
Definition block.h:30
constexpr bool operator!=(const Block &other) const noexcept
Inequality comparison.
Definition block.h:50
std::uint8_t reg
Target/source register index.
Definition block.h:28
constexpr bool operator==(const Block &other) const noexcept
Equality comparison.
Definition block.h:44
Instruction code
Instruction opcode.
Definition block.h:27
constexpr Block() noexcept=default
Default-constructs a Nop block.
std::int32_t operand
Immediate value or address.
Definition block.h:29