From 48586146054f99b6a55d0d73961fbbd85614315b Mon Sep 17 00:00:00 2001 From: uz Date: Fri, 6 Apr 2012 11:35:56 +0000 Subject: [PATCH] Moving around stuff. Preparation for loadable CPUs. git-svn-id: svn://svn.cc65.org/cc65/trunk@5645 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/sim65/cpu-6502.h | 88 ------------------------ src/sim65/{cpu-6502.c => cpus/6502.c} | 22 +++--- src/sim65/{cpuregs.h => cpus/6502regs.h} | 0 src/sim65/cpus/make/gcc.mak | 59 ++++++++++++++++ 4 files changed, 67 insertions(+), 102 deletions(-) delete mode 100644 src/sim65/cpu-6502.h rename src/sim65/{cpu-6502.c => cpus/6502.c} (99%) rename src/sim65/{cpuregs.h => cpus/6502regs.h} (100%) create mode 100644 src/sim65/cpus/make/gcc.mak diff --git a/src/sim65/cpu-6502.h b/src/sim65/cpu-6502.h deleted file mode 100644 index 469cf60c8..000000000 --- a/src/sim65/cpu-6502.h +++ /dev/null @@ -1,88 +0,0 @@ -/*****************************************************************************/ -/* */ -/* cpu-6502.h */ -/* */ -/* CPU core for the 6502 simulator */ -/* */ -/* */ -/* */ -/* (C) 2002-2012, Ullrich von Bassewitz */ -/* Roemerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ -/* */ -/* */ -/* 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 CPU_6502_H -#define CPU_6502_H - - - -/* sim65 */ -#include "cpuregs.h" - - - -/*****************************************************************************/ -/* Data */ -/*****************************************************************************/ - - - -/* Registers */ -extern CPURegs Regs; - - - -/*****************************************************************************/ -/* Code */ -/*****************************************************************************/ - - - -void CPUInit (void); -/* Initialize the CPU */ - -void RESET (void); -/* Generate a CPU RESET */ - -void IRQRequest (void); -/* Generate an IRQ */ - -void NMIRequest (void); -/* Generate an NMI */ - -void Break (const char* Format, ...); -/* Stop running and display the given message */ - -void CPURun (void); -/* Run one CPU instruction */ - - - -/* End of cpu-6502.h */ - -#endif - - - diff --git a/src/sim65/cpu-6502.c b/src/sim65/cpus/6502.c similarity index 99% rename from src/sim65/cpu-6502.c rename to src/sim65/cpus/6502.c index 06ef2cf3f..0c0a7ed98 100644 --- a/src/sim65/cpu-6502.c +++ b/src/sim65/cpus/6502.c @@ -1,8 +1,8 @@ /*****************************************************************************/ /* */ -/* cpu-6502.c */ +/* 6502.c */ /* */ -/* CPU core for the 6502 simulator */ +/* CPU core for the 6502 */ /* */ /* */ /* */ @@ -44,9 +44,7 @@ #include "strbuf.h" /* sim65 */ -#include "cpu-6502.h" -#include "cpuregs.h" -#include "cputype.h" +#include "6502regs.h" #include "error.h" #include "global.h" #include "memory.h" @@ -1037,15 +1035,11 @@ static void OPC_6502_6C (void) unsigned Addr; Cycles = 5; Addr = MemReadWord (Regs.PC+1); - if (CPU == CPU_6502) { - /* Emulate the 6502 bug */ - Regs.PC = MemReadByte (Addr); - Addr = (Addr & 0xFF00) | ((Addr + 1) & 0xFF); - Regs.PC |= (MemReadByte (Addr) << 8); - } else { - /* 65C02 and above have this bug fixed */ - Regs.PC = MemReadWord (Addr); - } + + /* Emulate the 6502 bug */ + Regs.PC = MemReadByte (Addr); + Addr = (Addr & 0xFF00) | ((Addr + 1) & 0xFF); + Regs.PC |= (MemReadByte (Addr) << 8); } diff --git a/src/sim65/cpuregs.h b/src/sim65/cpus/6502regs.h similarity index 100% rename from src/sim65/cpuregs.h rename to src/sim65/cpus/6502regs.h diff --git a/src/sim65/cpus/make/gcc.mak b/src/sim65/cpus/make/gcc.mak new file mode 100644 index 000000000..608fd3d8e --- /dev/null +++ b/src/sim65/cpus/make/gcc.mak @@ -0,0 +1,59 @@ +# +# gcc Makefile for the sim65 chip plugins +# + +# Include directories +COMMON = ../../common +SIM65 = .. + +CFLAGS = -g -Wall -W -std=c89 +override CFLAGS += -I$(COMMON) -I$(SIM65) -fpic +CC = gcc +EBIND = emxbind +LDFLAGS = + +#LIBS = $(COMMON)/common.a + +CPUS = 6502.so + +OBJS = $(CPUS:.so=.o) + +#---------------------------------------------------------------------------- +# Build rules + +%.obj: %.c + $(CC) $(CFLAGS) $^ + +%.so: %.o + $(CC) $(CFLAGS) -shared -o $@ $(LIBS) $^ -L /usr/X11R6/lib -lX11 + @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi + +#---------------------------------------------------------------------------- + +.PHONY: all +ifeq (.depend,$(wildcard .depend)) +all: $(CPUS) +include .depend +else +all: depend + @$(MAKE) -f make/gcc.mak all +endif + + +# Admin stuff + +clean: + rm -f *~ core *.lst + +zap: clean + rm -f *.o $(EXECS) .depend + +# ------------------------------------------------------------------------------ +# Make the dependencies + +.PHONY: depend dep +depend dep: $(CPUS:.so=.c) + @echo "Creating dependency information" + $(CC) $(CFLAGS) -MM $^ > .depend + +