Better output, change registers to unsigned int as base. Should be uint32_t?

This commit is contained in:
Màrius Montón 2021-11-08 09:25:36 +01:00
parent e22f321caf
commit 908b7e965d
2 changed files with 67 additions and 66 deletions

View File

@ -245,7 +245,7 @@ private:
/**
* bank of registers (32 regs of 32bits each)
*/
std::array<int,32> register_bank = { {0} };
std::array<unsigned int, 32> register_bank = { {0} };
/**
* Program counter (32 bits width)

View File

@ -24,79 +24,80 @@ Registers::Registers() {
void Registers::dump() {
std::cout << "************************************" << std::endl;
std::cout << "Registers dump" << std::dec << std::endl;
std::cout << "x0 (zero): " << std::right << std::setw(11)
<< register_bank[0];
std::cout << " x1 (ra): " << std::right << std::setw(11)
<< register_bank[1];
std::cout << " x2 (sp): " << std::right << std::setw(11)
<< register_bank[2];
std::cout << " x3 (gp): " << std::right << std::setw(11)
<< register_bank[3] << std::endl;
std::cout << std::setfill('0') << std::uppercase;
std::cout << "x0 (zero): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[0];
std::cout << " x1 (ra): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[1];
std::cout << " x2 (sp): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[2];
std::cout << " x3 (gp): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[3] << std::endl;
std::cout << "x4 (tp): " << std::right << std::setw(11)
<< register_bank[4];
std::cout << " x5 (t0): " << std::right << std::setw(11)
<< register_bank[5];
std::cout << " x6 (t1): " << std::right << std::setw(11)
<< register_bank[6];
std::cout << " x7 (t2): " << std::right << std::setw(11)
<< register_bank[7] << std::endl;
std::cout << "x4 (tp): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[4];
std::cout << " x5 (t0): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[5];
std::cout << " x6 (t1): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[6];
std::cout << " x7 (t2): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[7] << std::endl;
std::cout << "x8 (s0/fp): " << std::right << std::setw(11)
<< register_bank[8];
std::cout << " x9 (s1): " << std::right << std::setw(11)
<< register_bank[9];
std::cout << " x10 (a0): " << std::right << std::setw(11)
<< register_bank[10];
std::cout << " x11 (a1): " << std::right << std::setw(11)
<< register_bank[11] << std::endl;
std::cout << "x8 (s0/fp): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[8];
std::cout << " x9 (s1): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[9];
std::cout << " x10 (a0): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[10];
std::cout << " x11 (a1): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[11] << std::endl;
std::cout << "x12 (a2): " << std::right << std::setw(11)
<< register_bank[12];
std::cout << " x13 (a3): " << std::right << std::setw(11)
<< register_bank[13];
std::cout << " x14 (a4): " << std::right << std::setw(11)
<< register_bank[14];
std::cout << " x15 (a5): " << std::right << std::setw(11)
<< register_bank[15] << std::endl;
std::cout << "x12 (a2): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[12];
std::cout << " x13 (a3): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[13];
std::cout << " x14 (a4): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[14];
std::cout << " x15 (a5): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[15] << std::endl;
std::cout << "x16 (a6): " << std::right << std::setw(11)
<< register_bank[16];
std::cout << " x17 (a7): " << std::right << std::setw(11)
<< register_bank[17];
std::cout << " x18 (s2): " << std::right << std::setw(11)
<< register_bank[18];
std::cout << " x19 (s3): " << std::right << std::setw(11)
<< register_bank[19] << std::endl;
std::cout << "x16 (a6): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[16];
std::cout << " x17 (a7): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[17];
std::cout << " x18 (s2): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[18];
std::cout << " x19 (s3): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[19] << std::endl;
std::cout << "x20 (s4): " << std::right << std::setw(11)
<< register_bank[20];
std::cout << " x21 (s5): " << std::right << std::setw(11)
<< register_bank[21];
std::cout << " x22 (s6): " << std::right << std::setw(11)
<< register_bank[22];
std::cout << " x23 (s7): " << std::right << std::setw(11)
<< register_bank[23] << std::endl;
std::cout << "x20 (s4): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[20];
std::cout << " x21 (s5): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[21];
std::cout << " x22 (s6): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[22];
std::cout << " x23 (s7): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[23] << std::endl;
std::cout << "x24 (s8): " << std::right << std::setw(11)
<< register_bank[24];
std::cout << " x25 (s9): " << std::right << std::setw(11)
<< register_bank[25];
std::cout << " x26 (s10): " << std::right << std::setw(11)
<< register_bank[26];
std::cout << " x27 (s11): " << std::right << std::setw(11)
<< register_bank[27] << std::endl;
std::cout << "x24 (s8): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[24];
std::cout << " x25 (s9): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[25];
std::cout << " x26 (s10): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[26];
std::cout << " x27 (s11): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[27] << std::endl;
std::cout << "x28 (t3): " << std::right << std::setw(11)
<< register_bank[28];
std::cout << " x29 (t4): " << std::right << std::setw(11)
<< register_bank[29];
std::cout << " x30 (t5): " << std::right << std::setw(11)
<< register_bank[30];
std::cout << " x31 (t6): " << std::right << std::setw(11)
<< register_bank[31] << std::endl;
std::cout << "x28 (t3): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[28];
std::cout << " x29 (t4): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[29];
std::cout << " x30 (t5): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[30];
std::cout << " x31 (t6): 0x" << std::right << std::setw(8)
<< std::hex << register_bank[31] << std::endl;
std::cout << "PC: 0x" << std::hex << register_PC << std::dec << std::endl;
std::cout << "PC: 0x" << std::setw(8) << std::hex << register_PC << std::dec << std::endl;
std::cout << "************************************" << std::endl;
}