not sure if a union of an int and an std::opional is guaranteed to work

This commit is contained in:
folkert van heusden 2023-03-24 21:23:11 +01:00
parent ba5916f750
commit 3dddae94c3
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 4 additions and 6 deletions

View file

@ -149,7 +149,7 @@ void cpu::setRegisterLowByte(const int nr, const bool word_mode, const uint16_t
bool cpu::put_result(const gam_rc_t & g, const uint16_t value)
{
if (g.addr.has_value() == false) {
setRegisterLowByte(g.reg, g.word_mode, value);
setRegisterLowByte(g.reg.value(), g.word_mode, value);
return true;
}
@ -397,7 +397,7 @@ bool cpu::putGAM(const gam_rc_t & g, const uint16_t value)
return g.addr.value() != ADDR_PSW;
}
setRegister(g.reg, value, g.prev_mode);
setRegister(g.reg.value(), value, g.prev_mode);
return true;
}

4
cpu.h
View file

@ -17,10 +17,8 @@ typedef struct {
bool prev_mode;
d_i_space_t space;
union {
std::optional<uint16_t> addr;
int reg;
};
std::optional<int> reg;
std::optional<uint16_t> value;
} gam_rc_t;