From: cuz Date: Mon, 1 Apr 2002 17:55:22 +0000 (+0000) Subject: Working X-Git-Tag: V2.12.0~2403 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2a7a4105329b7a09222e1a4c30308fd21c115fcd;p=cc65 Working git-svn-id: svn://svn.cc65.org/cc65/trunk@1213 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/sim65/error.c b/src/sim65/error.c new file mode 100644 index 000000000..99d460da9 --- /dev/null +++ b/src/sim65/error.c @@ -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 +#include +#include + +#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 index 000000000..e67036d37 --- /dev/null +++ b/src/sim65/error.h @@ -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 + + + diff --git a/src/sim65/main.c b/src/sim65/main.c index 89f48148d..0adf81828 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -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; diff --git a/src/sim65/make/gcc.mak b/src/sim65/make/gcc.mak index b7b98aa9e..0cfc23ee4 100644 --- a/src/sim65/make/gcc.mak +++ b/src/sim65/make/gcc.mak @@ -12,6 +12,7 @@ LDFLAGS = OBJS = cpucore.o \ cputype.o \ + error.o \ global.o \ main.o \ memory.o diff --git a/src/sim65/memory.c b/src/sim65/memory.c index 3bf85f6db..d4e7554f3 100644 --- a/src/sim65/memory.c +++ b/src/sim65/memory.c @@ -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 */ /*****************************************************************************/