15 negative(_negative), byte1(_byte1), byte2(_byte2) {
19 negative(sign ==
'-'), byte1(_byte1), byte2(_byte2) {
20 if (sign !=
'+' && sign !=
'-') {
21 throw std::runtime_error(
"Invalid sign: " + std::string(1, sign));
32 throw std::runtime_error(
"Invalid index for a two bytes register: " + std::to_string(index));
36 int16_t high =
static_cast<int16_t
>(
static_cast<uint8_t
>(byte1));
37 int16_t low =
static_cast<int16_t
>(
static_cast<uint8_t
>(byte2));
38 return high * 64 + low;
42 int16_t val =
static_cast<int16_t
>(
bytes12());
43 return negative ? -val : val;
49 }
else if (
value < 0) {
53 byte1 =
static_cast<uint8_t
>(
value / (1 << 6));
54 byte2 =
static_cast<uint8_t
>(
value % (1 << 6));
60 }
else if (index == 2) {
63 throw std::runtime_error(
"Invalid index for a two bytes register: " + std::to_string(index));
68 this->negative = negative;
74 if (sign !=
'+' && sign !=
'-') {
75 throw std::runtime_error(
"Invalid sign: " + std::string(1, sign));
77 this->negative = sign ==
'-';