From 1d1b6de61632ff61f23eb2a70dde1192e2ae9854 Mon Sep 17 00:00:00 2001 From: mariusmonton Date: Sun, 31 Jan 2021 12:09:15 +0100 Subject: [PATCH] reduce scope variables --- src/CPU.cpp | 3 +-- src/CPU64.cpp | 3 +-- src/Memory.cpp | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/CPU.cpp b/src/CPU.cpp index 57da1e0..89e2259 100644 --- a/src/CPU.cpp +++ b/src/CPU.cpp @@ -57,7 +57,6 @@ CPU::~CPU() { bool CPU::cpu_process_IRQ() { uint32_t csr_temp; - uint32_t new_pc; bool ret_value = false; if (interrupt == true) { @@ -84,7 +83,7 @@ bool CPU::cpu_process_IRQ() { register_bank->setCSR(CSR_MCAUSE, 0x80000000); /* set new PC address */ - new_pc = register_bank->getCSR(CSR_MTVEC); + uint32_t new_pc = register_bank->getCSR(CSR_MTVEC); //new_pc = new_pc & 0xFFFFFFFC; // last two bits always to 0 log->SC_log(Log::DEBUG) << "NEW PC Value 0x" << std::hex << new_pc << std::endl; diff --git a/src/CPU64.cpp b/src/CPU64.cpp index fa7b6bf..030c06f 100644 --- a/src/CPU64.cpp +++ b/src/CPU64.cpp @@ -62,7 +62,6 @@ CPU64::~CPU64() { bool CPU64::cpu_process_IRQ() { uint32_t csr_temp; - uint32_t new_pc; bool ret_value = false; if (interrupt == true) { @@ -89,7 +88,7 @@ bool CPU64::cpu_process_IRQ() { register_bank->setCSR(CSR_MCAUSE, 0x80000000); /* set new PC address */ - new_pc = register_bank->getCSR(CSR_MTVEC); + uint32_t new_pc = register_bank->getCSR(CSR_MTVEC); //new_pc = new_pc & 0xFFFFFFFC; // last two bits always to 0 log->SC_log(Log::DEBUG) << "NEW PC Value 0x" << std::hex << new_pc << std::endl; diff --git a/src/Memory.cpp b/src/Memory.cpp index fe1358e..b652ad8 100644 --- a/src/Memory.cpp +++ b/src/Memory.cpp @@ -148,11 +148,11 @@ void Memory::readHexFile(std::string const& filename) { std::ifstream hexfile; std::string line; - uint32_t extended_address = 0; - hexfile.open(filename); if (hexfile.is_open()) { + uint32_t extended_address = 0; + while (getline(hexfile, line)) { if (line[0] == ':') { if (line.substr(7, 2) == "00") {