[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt.
From: |
Stan Behrens |
Subject: |
[Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt. |
Date: |
Wed, 11 Jan 2012 21:51:21 +0100 |
TODO: Check if execution is continuable on a real MCU.
---
src/avrdevice.cpp | 6 ++----
src/decoder.cpp | 9 +++++++++
src/decoder.h | 19 +++++++++++++++++++
src/decoder_trace.cpp | 6 ++++++
4 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/src/avrdevice.cpp b/src/avrdevice.cpp
index 0d2b38e..e2230db 100644
--- a/src/avrdevice.cpp
+++ b/src/avrdevice.cpp
@@ -514,10 +514,8 @@ int AvrDevice::Step(bool &untilCoreStepFinished,
SystemClockOffset *nextStepIn_n
statusRegister->trigger_change();
}
- if(cpuCycles != BREAK_POINT) {
- PC++;
- cpuCycles--;
- }
+ PC++;
+ cpuCycles--;
} else { //cpuCycles>0
if(trace_on == 1)
traceOut << "CPU-waitstate";
diff --git a/src/decoder.cpp b/src/decoder.cpp
index abe252a..9245282 100644
--- a/src/decoder.cpp
+++ b/src/decoder.cpp
@@ -30,6 +30,7 @@
#include "hwsreg.h"
#include "avrerror.h"
#include "ioregs.h"
+#include "global.h" //only 2 defines here... please move that sometimes
womewhere TODO XXX
static int n_bit_unsigned_to_signed(unsigned int val, int n );
@@ -1767,6 +1768,13 @@ int avr_op_WDR::operator()() {
return 1;
}
+avr_op_BREAK::avr_op_BREAK(word opcode, AvrDevice *c):
+ DecodedInstruction(c) {}
+
+int avr_op_BREAK::operator()() {
+ return BREAK_POINT+1;
+}
+
avr_op_ILLEGAL::avr_op_ILLEGAL(word opcode, AvrDevice *c):
DecodedInstruction(c) {}
@@ -1996,6 +2004,7 @@ DecodedInstruction* lookup_opcode( word opcode, AvrDevice
*core )
else
return new avr_op_ILLEGAL(opcode, core);
case 0x95A8: return new avr_op_WDR(opcode, core); /*
1001 0101 1010 1000 | WDR */
+ case 0x9598: return new avr_op_BREAK(opcode, core); /*
1001 0101 1001 1000 | BREAK */
default:
{
/* opcodes with two 5-bit register (Rd and Rr)
operands */
diff --git a/src/decoder.h b/src/decoder.h
index 4e5d13f..df6f7c3 100644
--- a/src/decoder.h
+++ b/src/decoder.h
@@ -2055,6 +2055,25 @@ class avr_op_WDR: public DecodedInstruction
int Trace();
};
+class avr_op_BREAK: public DecodedInstruction
+{
+ /*
+ * Halts execution
+ *
+ * TODO Check if execution is continuable on a real MCU
+ *
+ * Opcode : 1001 0101 1001 1000
+ * Usage : BREAK
+ * Operation : (see specific hardware specification for BREAK)
+ * Flags : None
+ * Num Clocks : N/A
+ */
+
+ public:
+ avr_op_BREAK(word opcode, AvrDevice *c);
+ int operator()();
+ int Trace();
+};
class avr_op_ILLEGAL: public DecodedInstruction
diff --git a/src/decoder_trace.cpp b/src/decoder_trace.cpp
index 4e2e5eb..3bfc30f 100644
--- a/src/decoder_trace.cpp
+++ b/src/decoder_trace.cpp
@@ -750,6 +750,12 @@ int avr_op_WDR::Trace() {
return ret;
}
+int avr_op_BREAK::Trace() {
+ traceOut << "BREAK ";
+ int ret = this->operator()();
+ return ret;
+}
+
int avr_op_ILLEGAL::Trace() {
traceOut << "Invalid Instruction! ";
int ret = this->operator()();
--
1.7.5.4
- [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt., Stan Behrens, 2012/01/04
- Re: [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt., Stan Behrens, 2012/01/04
- Re: [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt., Petr Hluzín, 2012/01/05
- Re: [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt., Stan Behrens, 2012/01/05
- Re: [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt., Petr Hluzín, 2012/01/08
- Re: [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt., Stan Behrens, 2012/01/11
- [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt.,
Stan Behrens <=
- Re: [Simulavr-devel] [PATCH] Add BREAK-instruction, causes simulavr to halt., Petr Hluzín, 2012/01/11