Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [[nodiscard]]
- constexpr auto position(int pc) -> bool {
- return (pc == ADDR_TEXT ? 0 : (pc - ADDR_TEXT) / 4);
- }
- while (text[
- position(pc)
- ] != 0x0) {
- switch (position(pc) & 0xFC000000) {
- case 0x20000000:
- {
- auto s = (text[position(pc)] & 0x03E00000) >> 21; // Shift the mask of the current byte with 21 bits to get the LO 31 bits. ( 8192 bits as result )
- auto t = (text[position(pc)] & 0x001F0000) >> 16; // Shift the mask of the current byte with 21 bits to get the HI 31 bits. ( 256 bits as result )
- auto imm = text[position(pc)] & 0xFFFF; // Mask with 11111111 11111111 to get the offset leftover (255 255)
- registers[t] = registers[s] + imm; // Add offset to the registers
- pc = pc + 4; // Increment the counter with 4 cause one instruction is set as 4 bytes
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement