Advertisement
Garey

Radislav MIPS

May 15th, 2019
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. [[nodiscard]]
  2. constexpr auto position(int pc) -> bool {
  3.     return (pc == ADDR_TEXT ? 0 : (pc - ADDR_TEXT) / 4);
  4. }
  5.  
  6.     while (text[
  7.         position(pc)
  8.     ] != 0x0) {
  9.         switch (position(pc) & 0xFC000000) {
  10.             case 0x20000000:
  11.             {
  12.                 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 )
  13.                 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 )
  14.                 auto imm = text[position(pc)] & 0xFFFF; // Mask with 11111111 11111111 to get the offset leftover (255 255)
  15.  
  16.                 registers[t] = registers[s] + imm;  // Add offset to the registers
  17.                 pc = pc + 4;    // Increment the counter with 4 cause one instruction is set as 4 bytes
  18.             }
  19.  
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement