#include <cstdint>
#include <iostream>
using byte = std::uint8_t;
struct Regs
{
union
{
std::uint16_t bc;
struct
{
// The order of these bytes matters
byte c;
byte b;
};
};
};
int main()
{
Regs regs;
regs.b = 1; // 0000 0001
regs.c = 7; // 0000 0111
// Read these vertically to know the value associated with each bit
//
// 2 1
// 5 2631
// 6 8426 8421
//
// 256 + 4 + 2 + 1 = 263
//
// The overall binary: 0000 0001 0000 0111
std::cout << regs.bc << "\n";
return 0;
}
I2luY2x1ZGUgPGNzdGRpbnQ+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCnVzaW5nIGJ5dGUgPSBzdGQ6OnVpbnQ4X3Q7CgpzdHJ1Y3QgUmVncwp7Cgl1bmlvbgoJewoJCXN0ZDo6dWludDE2X3QgYmM7CgkJCgkJc3RydWN0CgkJewoJCQkvLyBUaGUgb3JkZXIgb2YgdGhlc2UgYnl0ZXMgbWF0dGVycwoJCQlieXRlIGM7CgkJCWJ5dGUgYjsKCQl9OwoJfTsKfTsKCmludCBtYWluKCkKewoJUmVncyByZWdzOwoJCglyZWdzLmIgPSAxOyAvLyAwMDAwIDAwMDEKCXJlZ3MuYyA9IDc7IC8vIDAwMDAgMDExMQoJCgkvLyBSZWFkIHRoZXNlIHZlcnRpY2FsbHkgdG8ga25vdyB0aGUgdmFsdWUgYXNzb2NpYXRlZCB3aXRoIGVhY2ggYml0CgkvLwoJLy8gICAgICAgICAgICAgICAgICAgICAgICAgICAgIDIgMQoJLy8gICAgICAgICAgICAgICAgICAgICAgICAgICAgIDUgMjYzMQoJLy8gICAgICAgICAgICAgICAgICAgICAgICAgICAgIDYgODQyNiA4NDIxCgkvLwoJLy8gMjU2ICsgNCArIDIgKyAxID0gMjYzCgkvLwoJLy8gVGhlIG92ZXJhbGwgYmluYXJ5OiAwMDAwIDAwMDEgMDAwMCAwMTExIAoJCglzdGQ6OmNvdXQgPDwgcmVncy5iYyA8PCAiXG4iOwoJCglyZXR1cm4gMDsKfQ==