Skip to content

Commit

Permalink
Still Not Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherrytree56567 committed Oct 22, 2023
1 parent 0c8685c commit 59a75fa
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 12 deletions.
24 changes: 16 additions & 8 deletions PSEMU/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void CPU::fetch() {
}

void CPU::decode_execute(Instruction instruction) {
std::cout << "Instruction " << instruction.instruction << "\n";
std::cout << "instruction: " << instruction.instruction << "\n";
switch (instruction.opcode()) {
case (0b000000):
switch (instruction.function()) {
Expand Down Expand Up @@ -582,15 +582,23 @@ void CPU::op_bne(Instruction instruction) {
}

void CPU::op_addi(Instruction instruction) {
uint32_t rs = regs[instruction.rs()];
uint32_t imm_s = instruction.imm_s();
uint32_t addi = rs + imm_s;
int32_t i = instruction.imm_s();
uint32_t t = instruction.rt();
uint32_t s = instruction.rs();

bool overflow = (((addi ^ rs) & (addi ^ imm_s)) & UINT32_C(0x80000000)) != 0;
if (!overflow)
set_reg(instruction.rt(), addi);
else
int32_t sValue = regs[s];

int32_t v;

// Manual overflow check
if ((i > 0 && sValue > INT_MAX - i) || (i < 0 && sValue < INT_MIN - i)) {
// Overflow occurred
exception(Exception::Overflow);
}
else {
v = sValue + i;
set_reg(t, static_cast<uint32_t>(v));
}
}

void CPU::op_lw(Instruction instruction) {
Expand Down
2 changes: 1 addition & 1 deletion PSEMU/RAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

void RAM::newl() {
for (int i = 0; i < (2 * 1024 * 1024); i++) {
ram[i] = 0xca;
ram[i] = 0x0;
}
}

Expand Down
Binary file modified PSEMU/x64/Debug/CPU.obj
Binary file not shown.
Binary file modified PSEMU/x64/Debug/PSEMU.ilk
Binary file not shown.
6 changes: 3 additions & 3 deletions PSEMU/x64/Debug/PSEMU.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.h(114,1): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.h(123,1): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.h(132,1): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.cpp(815,53): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.cpp(1091,16): warning C4244: 'initializing': conversion from 'uint64_t' to 'uint32_t', possible loss of data
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.cpp(1093,23): warning C4293: '>>': shift count negative or too big, undefined behavior
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.cpp(823,53): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.cpp(1099,16): warning C4244: 'initializing': conversion from 'uint64_t' to 'uint32_t', possible loss of data
C:\Users\ronit\Desktop\PSEMU\PSEMU\CPU.cpp(1101,23): warning C4293: '>>': shift count negative or too big, undefined behavior
PSEMU.vcxproj -> C:\Users\ronit\Desktop\PSEMU\x64\Debug\PSEMU.exe
Binary file modified PSEMU/x64/Debug/PSEMU.obj
Binary file not shown.
Binary file modified PSEMU/x64/Debug/PSEMU.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified PSEMU/x64/Debug/PSEMU.tlog/CL.write.1.tlog
Binary file not shown.
Binary file modified PSEMU/x64/Debug/PSEMU.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified PSEMU/x64/Debug/vc143.idb
Binary file not shown.
Binary file modified PSEMU/x64/Debug/vc143.pdb
Binary file not shown.
Binary file modified x64/Debug/PSEMU.exe
Binary file not shown.
Binary file modified x64/Debug/PSEMU.pdb
Binary file not shown.

0 comments on commit 59a75fa

Please sign in to comment.