From: Manfred Steiner <sx@htl-kaindorf.at>
Date: Mon, 5 Dec 2022 10:26:11 +0000 (+0100)
Subject: simuc V0.0.5 (merge from dc6b4ab)
X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=82e889ae1ebe47597bf87ace7b1937fa63d1aa44;p=sx%2Fsimavr.git

simuc V0.0.5 (merge from dc6b4ab)
---

diff --git a/examples/simuc/Makefile b/examples/simuc/Makefile
index 91501cb..e3ee48d 100644
--- a/examples/simuc/Makefile
+++ b/examples/simuc/Makefile
@@ -51,7 +51,7 @@ ifeq ($(ARCH), arm-linux-gnueabihf)
 	DEBARCH="armhf"
 endif
 
-DEBVERSION := 0.0.3~1
+DEBVERSION := 0.0.5~1
 DEBNAME := dpkg/htl-simuc_version_arch
 DEBSRC := dpkg/htl-simuc_version_arch
 DEBARCH := $(shell dpkg --print-architecture)
diff --git a/examples/simuc/src/main.cpp b/examples/simuc/src/main.cpp
index fe2fe31..575165b 100644
--- a/examples/simuc/src/main.cpp
+++ b/examples/simuc/src/main.cpp
@@ -8,7 +8,7 @@
 #include "simavr/simavr.h"
 
 void printHelp () {
-    printf("simuc V0.0.4 (%s,%s)\n", __DATE__, __TIME__);
+    printf("simuc V0.0.5 (%s,%s)\n", __DATE__, __TIME__);
     printf("usage: simuc [options] elf-file [elf-file ...]\n\n");
     printf("  available options (you can use file .simucinit instead):\n");
     printf("    --port ...         listining port for gdb (default 1234)\n");
@@ -200,7 +200,7 @@ int main (int argc, char **argv) {
         return 1;
     }
     printf("--------------------------------------------------------------------\n");
-    printf("available commands: i (interrupt), c (continue), s (stack), q (quit)\n");
+    printf("available commands: i (interrupt), c (continue), s (stack), r (reset), q (quit)\n");
     printf("--------------------------------------------------------------------\n");
     printf("init done - press key to start\n");
     getchar();
@@ -223,7 +223,7 @@ int main (int argc, char **argv) {
         // }
         
         if (getline(&line, &size, stdin) > 0) {
-            const char *commands[] = { "quit", "interrupt", "continue", "stack" };
+            const char *commands[] = { "quit", "interrupt", "continue", "stack", "reset" };
             try {
                 int foundIndex = -1;
                 int foundCnt = 0;
diff --git a/examples/simuc/src/simavr/simavr.cpp b/examples/simuc/src/simavr/simavr.cpp
index ac15d1f..c3fc119 100644
--- a/examples/simuc/src/simavr/simavr.cpp
+++ b/examples/simuc/src/simavr/simavr.cpp
@@ -507,7 +507,9 @@ bool SimAvr::sprintfLedStatus (char *s, size_t size, bool onlyOnChange) {
 				for (int i = 0; i < 4; i++) {
 					int8_t nextLed = -1;
 					if (ddra & (1 << i)) {
-						nextLed = porta & (1 << i) ? 0 : 1;
+						nextLed = porta & (1 << i) ? 0 : 1; // port output
+					} else {
+						nextLed = 0; // port input _> led is off
 					}
 					if (nextLed != led[i]) {
 						change = 1;
@@ -605,7 +607,7 @@ void SimAvr::avrRun () {
 
 						}
 						printf(printHeader ? "\n" : "\n");
-						char s[20];
+						char s[80];
 						sprintfLedStatus(s, sizeof(s), false);
 						printf("   %s\n", s);
 						break;
@@ -764,6 +766,13 @@ void SimAvr::avrRun () {
 						break;
 					}
 
+					case CommandReset: {
+						avr_reset(avr);
+						printf("RESET done -> PC=0x%04x, use command 'continue' to start!\n", avr->pc);
+						avr->state = cpu_Stopped;
+						break;
+					}
+
 					default: break;
 				}
 				command = ReadyForNewCommand;
diff --git a/examples/simuc/src/simavr/simavr.h b/examples/simuc/src/simavr/simavr.h
index 1f2090b..0184f5b 100644
--- a/examples/simuc/src/simavr/simavr.h
+++ b/examples/simuc/src/simavr/simavr.h
@@ -60,7 +60,8 @@ typedef enum {
 	CommandQuit,
 	CommandInterrupt,
 	CommandContinue,
-	CommandStack
+	CommandStack,
+	CommandReset
 } EnumSimAvrCommand;
 
 struct SimAvrStatus {