Showing the changes to src/vm/module_reader.cpp (1 of 7 files). Show all
Unified · Split
| @@ -191,16 +191,13 @@ namespace · 190 unmodified lines | ||
| 191 | 191 | return dest; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | − std::tuple<address_mode_middle_t, address_mode_t, address_mode_t> convert_to_address_mode(uint8_t instr_addr_mode) | |
| 194 | + std::tuple<address_mode_middle_t, address_mode_t, address_mode_t> convert_to_address_mode(addr_code_t instr_addr_mode) | |
| 195 | 195 | { |
| 196 | − // Taken from Dis VM specification | |
| 197 | − // bit 7 6 5 4 3 2 1 0 | |
| 198 | − // m1 m0 s2 s1 s0 d2 d1 d0 | |
| 199 | − | |
| 196 | + // See definition of addr_code_t | |
| 200 | 197 | static const auto mid_mask = uint8_t{ 0xc0 }; |
| 201 | 198 | static const auto src_mask = uint8_t{ 0x38 }; |
| 202 | 199 | static const auto dest_mask = uint8_t{ 0x07 }; |
| 203 | − assert((mid_mask | src_mask | dest_mask) == std::numeric_limits<uint8_t>::max()); | |
| 200 | + assert((mid_mask | src_mask | dest_mask) == std::numeric_limits<addr_code_t>::max()); | |
| 204 | 201 | |
| 205 | 202 | const auto mid = static_cast<address_mode_middle_t>((instr_addr_mode & mid_mask) >> 6); |
| 206 | 203 | const auto src = static_cast<address_mode_t>((instr_addr_mode & src_mask) >> 3); |
| @@ -286,6 +283,7 @@ namespace · 79 unmodified lines | ||
| 286 | 283 | |
| 287 | 284 | instr.opcode = static_cast<opcode_t>(op_and_addrmode[0]); |
| 288 | 285 | assert(opcode_t::first_opcode <= instr.opcode && instr.opcode <= opcode_t::last_opcode); |
| 286 | + instr.addr_code = op_and_addrmode[1]; | |
| 289 | 287 | |
| 290 | 288 | std::tie(instr.middle.mode, instr.source.mode, instr.destination.mode) = convert_to_address_mode(op_and_addrmode[1]); |
| 291 | 289 | |