mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Working
git-svn-id: svn://svn.cc65.org/cc65/trunk@1213 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
d17936488c
commit
2a7a410532
90
src/sim65/error.c
Normal file
90
src/sim65/error.c
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
68
src/sim65/error.h
Normal file
68
src/sim65/error.h
Normal file
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -45,6 +45,7 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
|
#include "cpucore.h"
|
||||||
#include "cputype.h"
|
#include "cputype.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
@ -205,7 +206,7 @@ int main (int argc, char* argv[])
|
|||||||
|
|
||||||
/* Initialize modules */
|
/* Initialize modules */
|
||||||
MemInit ();
|
MemInit ();
|
||||||
|
CPUInit ();
|
||||||
|
|
||||||
/* Return an apropriate exit code */
|
/* Return an apropriate exit code */
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -12,6 +12,7 @@ LDFLAGS =
|
|||||||
|
|
||||||
OBJS = cpucore.o \
|
OBJS = cpucore.o \
|
||||||
cputype.o \
|
cputype.o \
|
||||||
|
error.o \
|
||||||
global.o \
|
global.o \
|
||||||
main.o \
|
main.o \
|
||||||
memory.o
|
memory.o
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* memory.h */
|
/* memory.h */
|
||||||
/* */
|
/* */
|
||||||
/* Memory subsystem for the 6502 simulator */
|
/* Memory subsystem for the 6502 simulator */
|
||||||
/* */
|
/* */
|
||||||
@ -36,7 +36,8 @@
|
|||||||
/* common */
|
/* common */
|
||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
|
#include "error.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ static void MemWrite (unsigned Addr, unsigned char Val)
|
|||||||
/* Write one byte to the memory cell */
|
/* Write one byte to the memory cell */
|
||||||
{
|
{
|
||||||
if (MemAttr[Addr] & RA_WPROT) {
|
if (MemAttr[Addr] & RA_WPROT) {
|
||||||
/* ### */
|
Warning ("Writing to write protected memory at $%04X", Addr);
|
||||||
}
|
}
|
||||||
Mem[Addr] = Val;
|
Mem[Addr] = Val;
|
||||||
MemAttr[Addr] |= RA_INITIALIZED;
|
MemAttr[Addr] |= RA_INITIALIZED;
|
||||||
@ -108,7 +109,7 @@ static unsigned char MemRead (unsigned Addr)
|
|||||||
{
|
{
|
||||||
if ((MemAttr[Addr] & RA_INITIALIZED) == 0) {
|
if ((MemAttr[Addr] & RA_INITIALIZED) == 0) {
|
||||||
/* We're reading a memory cell that was never written */
|
/* We're reading a memory cell that was never written */
|
||||||
/* ### */
|
Warning ("Reading from uninitialized memory at $%04X", Addr);
|
||||||
}
|
}
|
||||||
return Mem[Addr];
|
return Mem[Addr];
|
||||||
}
|
}
|
||||||
@ -116,7 +117,7 @@ static unsigned char MemRead (unsigned Addr)
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user