]> git.sur5r.net Git - cc65/commitdiff
Working
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 1 Apr 2002 17:55:22 +0000 (17:55 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 1 Apr 2002 17:55:22 +0000 (17:55 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1213 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/sim65/error.c [new file with mode: 0644]
src/sim65/error.h [new file with mode: 0644]
src/sim65/main.c
src/sim65/make/gcc.mak
src/sim65/memory.c

diff --git a/src/sim65/error.c b/src/sim65/error.c
new file mode 100644 (file)
index 0000000..99d460d
--- /dev/null
@@ -0,0 +1,90 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                error.c                                   */
+/*                                                                           */
+/*                    Error handling for the sim65 simulator                 */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2002      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "error.h"
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+void Warning (const char* Format, ...)
+/* Print a warning message */
+{
+    va_list ap;
+    va_start (ap, Format);
+    fprintf (stderr, "Warning: ");
+    vfprintf (stderr, Format, ap);
+    putc ('\n', stderr);
+    va_end (ap);
+}
+
+
+
+void Error (const char* Format, ...)
+/* Print an error message and die */
+{
+    va_list ap;
+    va_start (ap, Format);
+    fprintf (stderr, "Error: ");
+    vfprintf (stderr, Format, ap);
+    putc ('\n', stderr);
+    va_end (ap);
+    exit (EXIT_FAILURE);
+}
+
+
+
+void Internal (const char* Format, ...)
+/* Print an internal error message and die */
+{
+    va_list ap;
+    va_start (ap, Format);
+    fprintf (stderr, "Internal error: ");
+    vfprintf (stderr, Format, ap);
+    putc ('\n', stderr);
+    va_end (ap);
+    exit (EXIT_FAILURE);
+}
+
+
+
diff --git a/src/sim65/error.h b/src/sim65/error.h
new file mode 100644 (file)
index 0000000..e67036d
--- /dev/null
@@ -0,0 +1,68 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                error.h                                   */
+/*                                                                           */
+/*                    Error handling for the sim65 simulator                 */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2002      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef ERROR_H
+#define ERROR_H
+
+
+
+/* common */
+#include "attrib.h"
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+void Warning (const char* Format, ...) attribute((format(printf,1,2)));
+/* Print a warning message */
+
+void Error (const char* Format, ...) attribute((format(printf,1,2)));
+/* Print an error message and die */
+
+void Internal (const char* Format, ...) attribute((format(printf,1,2)));
+/* Print an internal error message and die */
+
+
+
+/* End of error.h */
+
+#endif
+
+
+
index 89f48148d482cc8131c0bfc8fe08cd679ffb6613..0adf81828e954fee929ba2083faa3d94ac20b557 100644 (file)
@@ -45,6 +45,7 @@
 #include "version.h"
 
 /* sim65 */
+#include "cpucore.h"
 #include "cputype.h"
 #include "global.h"
 #include "memory.h"
@@ -205,7 +206,7 @@ int main (int argc, char* argv[])
 
     /* Initialize modules */
     MemInit ();
-
+    CPUInit ();
 
     /* Return an apropriate exit code */
     return EXIT_SUCCESS;
index b7b98aa9e87e848d978c80c7b5068e8c3fa8b683..0cfc23ee4fa8019a30349e4acc3cd99b944bc658 100644 (file)
@@ -12,6 +12,7 @@ LDFLAGS       =
 
 OBJS =         cpucore.o       \
        cputype.o       \
+        error.o         \
        global.o        \
        main.o          \
         memory.o
index 3bf85f6db9e9ed972a8533adfed21850188d650a..d4e7554f3d3c1a790cb2d7d508184afbe276c89d 100644 (file)
@@ -1,6 +1,6 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                memory.h                                  */
+/*                                memory.h                                  */
 /*                                                                           */
 /*                 Memory subsystem for the 6502 simulator                  */
 /*                                                                           */
@@ -36,7 +36,8 @@
 /* common */
 #include "coll.h"
 
-/* sim65 */
+/* sim65 */            
+#include "error.h"
 #include "memory.h"
 
 
@@ -95,7 +96,7 @@ static void MemWrite (unsigned Addr, unsigned char Val)
 /* Write one byte to the memory cell */
 {
     if (MemAttr[Addr] & RA_WPROT) {
-        /* ### */
+        Warning ("Writing to write protected memory at $%04X", Addr);
     }
     Mem[Addr] = Val;
     MemAttr[Addr] |= RA_INITIALIZED;
@@ -108,7 +109,7 @@ static unsigned char MemRead (unsigned Addr)
 {
     if ((MemAttr[Addr] & RA_INITIALIZED) == 0) {
         /* We're reading a memory cell that was never written */
-        /* ### */
+        Warning ("Reading from uninitialized memory at $%04X", Addr);
     }
     return Mem[Addr];
 }
@@ -116,7 +117,7 @@ static unsigned char MemRead (unsigned Addr)
 
 
 /*****************************************************************************/
-/*                                  Code                                    */
+/*                                  Code                                    */
 /*****************************************************************************/