mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 02:30:44 +00:00
Intermediate state - doesn't run as is.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5643 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
032c16dda4
commit
10d58204b5
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2003 Ullrich von Bassewitz */
|
/* (C) 2002-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2003 Ullrich von Bassewitz */
|
/* (C) 2003-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2002-2003 Ullrich von Bassewitz */
|
/* (C) 2002-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -57,17 +57,14 @@ CfgData* NewCfgData (void)
|
|||||||
* uses the current output of the config scanner.
|
* uses the current output of the config scanner.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Get the length of the identifier */
|
|
||||||
unsigned AttrLen = strlen (CfgSVal);
|
|
||||||
|
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
CfgData* D = xmalloc (sizeof (CfgData) + AttrLen);
|
CfgData* D = xmalloc (sizeof (CfgData) + SB_GetLen (&CfgSVal));
|
||||||
|
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
D->Type = CfgDataInvalid;
|
D->Type = CfgDataInvalid;
|
||||||
D->Line = CfgErrorLine;
|
D->Line = CfgErrorLine;
|
||||||
D->Col = CfgErrorCol;
|
D->Col = CfgErrorCol;
|
||||||
memcpy (D->Attr, CfgSVal, AttrLen+1);
|
memcpy (D->Attr, SB_GetConstBuf (&CfgSVal), SB_GetLen (&CfgSVal) + 1);
|
||||||
|
|
||||||
/* Return the new struct */
|
/* Return the new struct */
|
||||||
return D;
|
return D;
|
||||||
@ -78,7 +75,7 @@ CfgData* NewCfgData (void)
|
|||||||
void FreeCfgData (CfgData* D)
|
void FreeCfgData (CfgData* D)
|
||||||
/* Free a config data structure */
|
/* Free a config data structure */
|
||||||
{
|
{
|
||||||
if (D->Type == CfgDataString) {
|
if (D->Type == CfgDataId || D->Type == CfgDataString) {
|
||||||
/* Free the string value */
|
/* Free the string value */
|
||||||
xfree (D->V.SVal);
|
xfree (D->V.SVal);
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2002-2003 Ullrich von Bassewitz */
|
/* (C) 2002-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -58,7 +58,7 @@ struct CfgData {
|
|||||||
CfgDataString
|
CfgDataString
|
||||||
} Type; /* Type of the value */
|
} Type; /* Type of the value */
|
||||||
union {
|
union {
|
||||||
char* SVal; /* String or id value */
|
char* SVal; /* String or id value */
|
||||||
long IVal; /* Integer value */
|
long IVal; /* Integer value */
|
||||||
} V;
|
} V;
|
||||||
unsigned Line; /* Line where the attribute was defined */
|
unsigned Line; /* Line where the attribute was defined */
|
||||||
|
@ -105,6 +105,8 @@ static const SimData Sim65Data = {
|
|||||||
GetCfgId,
|
GetCfgId,
|
||||||
GetCfgStr,
|
GetCfgStr,
|
||||||
GetCfgNum,
|
GetCfgNum,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
Break,
|
Break,
|
||||||
IRQRequest,
|
IRQRequest,
|
||||||
NMIRequest,
|
NMIRequest,
|
||||||
@ -156,7 +158,7 @@ static int GetCfgNum (void* CfgInfo, const char* Name, long* Val)
|
|||||||
|
|
||||||
|
|
||||||
static int CmpChips (void* Data attribute ((unused)),
|
static int CmpChips (void* Data attribute ((unused)),
|
||||||
const void* lhs, const void* rhs)
|
const void* lhs, const void* rhs)
|
||||||
/* Compare function for CollSort */
|
/* Compare function for CollSort */
|
||||||
{
|
{
|
||||||
/* Cast the object pointers */
|
/* Cast the object pointers */
|
||||||
@ -404,7 +406,7 @@ void LoadChipLibrary (const char* LibName)
|
|||||||
/* Output chip name and version to keep the user happy */
|
/* Output chip name and version to keep the user happy */
|
||||||
Print (stdout, 1,
|
Print (stdout, 1,
|
||||||
" Found %s `%s', version %u.%u in library `%s'\n",
|
" Found %s `%s', version %u.%u in library `%s'\n",
|
||||||
(D->Type == CHIPDATA_TYPE_CHIP)? "chip" : "cpu",
|
(D->Type == CHIPDATA_TYPE_CHIP)? "chip" : "cpu",
|
||||||
D->ChipName,
|
D->ChipName,
|
||||||
D->MajorVersion,
|
D->MajorVersion,
|
||||||
D->MinorVersion,
|
D->MinorVersion,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2003-2009, Ullrich von Bassewitz */
|
/* (C) 2003-2012, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
COMMON = ../../common
|
COMMON = ../../common
|
||||||
SIM65 = ..
|
SIM65 = ..
|
||||||
|
|
||||||
CFLAGS = -g -O2 -Wall -W -std=c89
|
CFLAGS = -g -Wall -W -std=c89
|
||||||
override CFLAGS += -I$(COMMON) -I$(SIM65) -fpic
|
override CFLAGS += -I$(COMMON) -I$(SIM65) -fpic
|
||||||
CC = gcc
|
CC = gcc
|
||||||
EBIND = emxbind
|
EBIND = emxbind
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2002-2003 Ullrich von Bassewitz */
|
/* (C) 2002-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -60,9 +60,15 @@ static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo);
|
|||||||
static void DestroyInstance (void* Data);
|
static void DestroyInstance (void* Data);
|
||||||
/* Destroy a chip instance */
|
/* Destroy a chip instance */
|
||||||
|
|
||||||
|
static void WriteCtrl (void* Data, unsigned Offs, unsigned char Val);
|
||||||
|
/* Write control data */
|
||||||
|
|
||||||
static void Write (void* Data, unsigned Offs, unsigned char Val);
|
static void Write (void* Data, unsigned Offs, unsigned char Val);
|
||||||
/* Write user data */
|
/* Write user data */
|
||||||
|
|
||||||
|
static unsigned char ReadCtrl (void* Data, unsigned Offs);
|
||||||
|
/* Read control data */
|
||||||
|
|
||||||
static unsigned char Read (void* Data, unsigned Offs);
|
static unsigned char Read (void* Data, unsigned Offs);
|
||||||
/* Read user data */
|
/* Read user data */
|
||||||
|
|
||||||
@ -74,6 +80,9 @@ static unsigned char Read (void* Data, unsigned Offs);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The SimData pointer we get when InitChip is called */
|
||||||
|
static const SimData* Sim;
|
||||||
|
|
||||||
/* Control data passed to the main program */
|
/* Control data passed to the main program */
|
||||||
static const struct ChipData CData[1] = {
|
static const struct ChipData CData[1] = {
|
||||||
{
|
{
|
||||||
@ -86,15 +95,33 @@ static const struct ChipData CData[1] = {
|
|||||||
InitChip,
|
InitChip,
|
||||||
CreateInstance,
|
CreateInstance,
|
||||||
DestroyInstance,
|
DestroyInstance,
|
||||||
|
WriteCtrl,
|
||||||
Write,
|
Write,
|
||||||
Write,
|
ReadCtrl,
|
||||||
Read,
|
|
||||||
Read
|
Read
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The SimData pointer we get when InitChip is called */
|
/* Screen instance data */
|
||||||
static const SimData* Sim;
|
typedef struct InstanceData InstanceData;
|
||||||
|
struct InstanceData {
|
||||||
|
/* The memory area used for data */
|
||||||
|
unsigned char* Mem[32];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Function opcodes */
|
||||||
|
enum {
|
||||||
|
F_open,
|
||||||
|
F_close,
|
||||||
|
F_write,
|
||||||
|
F_read,
|
||||||
|
F_lseek,
|
||||||
|
F_unlink,
|
||||||
|
F_chdir,
|
||||||
|
F_getcwd,
|
||||||
|
F_mkdir,
|
||||||
|
F_rmdir,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -137,8 +164,14 @@ static int InitChip (const struct SimData* Data)
|
|||||||
static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
|
static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
|
||||||
/* Initialize a new chip instance */
|
/* Initialize a new chip instance */
|
||||||
{
|
{
|
||||||
/* We don't need any instance data */
|
/* Allocate the instance data */
|
||||||
return 0;
|
InstanceData* D = Sim->Malloc (sizeof (InstanceData));
|
||||||
|
|
||||||
|
/* Initialize the instance data */
|
||||||
|
memset (D->Mem, 0x00, sizeof (D->Mem));
|
||||||
|
|
||||||
|
/* Return the instance data */
|
||||||
|
return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,28 +179,111 @@ static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
|
|||||||
static void DestroyInstance (void* Data)
|
static void DestroyInstance (void* Data)
|
||||||
/* Destroy a chip instance */
|
/* Destroy a chip instance */
|
||||||
{
|
{
|
||||||
|
/* Cast the instance data pointer */
|
||||||
|
InstanceData* D = Data;
|
||||||
|
|
||||||
|
/* Free the instance data */
|
||||||
|
Sim->Free (D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void Write (void* Data attribute ((unused)),
|
static void WriteCtrl (void* Data attribute, unsigned Offs, unsigned char Val)
|
||||||
unsigned Offs attribute ((unused)),
|
|
||||||
unsigned char Val)
|
|
||||||
/* Write user data */
|
/* Write user data */
|
||||||
{
|
{
|
||||||
putchar (Val);
|
/* Cast the instance data pointer */
|
||||||
|
InstanceData* D = Data;
|
||||||
|
|
||||||
|
/* Write to the memory */
|
||||||
|
D->Mem[Offs] = Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char Read (void* Data attribute ((unused)),
|
static void Write (void* Data, unsigned Offs, unsigned char Val)
|
||||||
unsigned Offs attribute ((unused)))
|
/* Write user data */
|
||||||
|
{
|
||||||
|
/* Cast the instance data pointer */
|
||||||
|
InstanceData* D = Data;
|
||||||
|
|
||||||
|
/* Write to the memory */
|
||||||
|
D->Mem[Offs] = Val;
|
||||||
|
|
||||||
|
/* Now check the offset. Zero is special because it will trigger the
|
||||||
|
* action
|
||||||
|
*/
|
||||||
|
if (Offs == 0) {
|
||||||
|
|
||||||
|
/* The action is determined by the value that is written */
|
||||||
|
switch (Val) {
|
||||||
|
|
||||||
|
case F_open:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_close:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_write:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_read:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_lseek:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_unlink:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_chdir:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_getcwd:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_mkdir:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_rmdir:
|
||||||
|
Sim->Break ("Unsupported function $%02X", Val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned char ReadCtrl (void* Data, unsigned Offs)
|
||||||
/* Read user data */
|
/* Read user data */
|
||||||
{
|
{
|
||||||
/* Read a character and return the value */
|
/* Cast the instance data pointer */
|
||||||
return getchar ();
|
InstanceData* D = Data;
|
||||||
|
|
||||||
|
/* Read the cell and return the value */
|
||||||
|
return D->Mem[Offs];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned char Read (void* Data, unsigned Offs)
|
||||||
|
/* Read user data */
|
||||||
|
{
|
||||||
|
/* Cast the instance data pointer */
|
||||||
|
InstanceData* D = Data;
|
||||||
|
|
||||||
|
/* Read the cell and return the value */
|
||||||
|
return D->Mem[Offs];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
/* (C) 1998-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -46,11 +46,11 @@
|
|||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
|
#include "addrspace.h"
|
||||||
#include "cfgdata.h"
|
#include "cfgdata.h"
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "memory.h"
|
|
||||||
#include "location.h"
|
#include "location.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -143,18 +143,26 @@ static void ParseCPU (void)
|
|||||||
AttrCheck (Attr, atType, "TYPE");
|
AttrCheck (Attr, atType, "TYPE");
|
||||||
AttrCheck (Attr, atAddrSpace, "ADDRSPACE");
|
AttrCheck (Attr, atAddrSpace, "ADDRSPACE");
|
||||||
|
|
||||||
|
/* Create the CPU */
|
||||||
|
CPUInstance = NewCPU ("6502", Size);
|
||||||
|
|
||||||
/* Skip the semicolon */
|
/* Skip the semicolon */
|
||||||
CfgConsumeSemi ();
|
CfgConsumeSemi ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ParseMemory (void)
|
static void ParseAddrSpace (void)
|
||||||
/* Parse a MEMORY section */
|
/* Parse a ADDRSPACE section */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
|
/* CPU must be defined before the address space */
|
||||||
|
if (CPUInstance == 0) {
|
||||||
|
CfgError ("CPU must be defined before address space definitions");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse addresses */
|
||||||
while (CfgTok == CFGTOK_INTCON) {
|
while (CfgTok == CFGTOK_INTCON) {
|
||||||
|
|
||||||
Location* L;
|
Location* L;
|
||||||
@ -263,8 +271,8 @@ static void ParseMemory (void)
|
|||||||
/* Delete the "name" attribute */
|
/* Delete the "name" attribute */
|
||||||
FreeCfgData (D);
|
FreeCfgData (D);
|
||||||
|
|
||||||
/* Assign the chip instance to memory */
|
/* Assign the chip instance to address space */
|
||||||
MemAssignChip (CI, L->Start, Range);
|
ASAssignChip (CPUInstance->AS, CI, L->Start, Range);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the mirrors */
|
/* Create the mirrors */
|
||||||
@ -295,7 +303,7 @@ static void ParseMemory (void)
|
|||||||
/* For simplicity, get the chip instance we're mirroring from the
|
/* For simplicity, get the chip instance we're mirroring from the
|
||||||
* memory, instead of searching for the range in the list.
|
* memory, instead of searching for the range in the list.
|
||||||
*/
|
*/
|
||||||
CI = MemGetChip (MirrorAddr);
|
CI = ASGetChip (MirrorAddr);
|
||||||
if (CI == 0) {
|
if (CI == 0) {
|
||||||
/* We are mirroring an unassigned address */
|
/* We are mirroring an unassigned address */
|
||||||
Error ("%s(%u): Mirroring an unassigned address",
|
Error ("%s(%u): Mirroring an unassigned address",
|
||||||
@ -316,8 +324,8 @@ static void ParseMemory (void)
|
|||||||
/* Clone the chip instance for the new location */
|
/* Clone the chip instance for the new location */
|
||||||
MCI = MirrorChipInstance (CI, L->Start - Offs);
|
MCI = MirrorChipInstance (CI, L->Start - Offs);
|
||||||
|
|
||||||
/* Assign the chip instance to memory */
|
/* Assign the chip instance to address space */
|
||||||
MemAssignChip (MCI, L->Start, Range);
|
ASAssignChip (CPUInstance->AS, MCI, L->Start, Range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,8 +335,8 @@ static void ParseConfig (void)
|
|||||||
/* Parse the config file */
|
/* Parse the config file */
|
||||||
{
|
{
|
||||||
static const IdentTok BlockNames [] = {
|
static const IdentTok BlockNames [] = {
|
||||||
{ "CPU", CFGTOK_CPU },
|
{ "ADDRSPACE", CFGTOK_ADDRSPACE },
|
||||||
{ "MEMORY", CFGTOK_MEMORY },
|
{ "CPU", CFGTOK_CPU },
|
||||||
};
|
};
|
||||||
cfgtok_t BlockTok;
|
cfgtok_t BlockTok;
|
||||||
|
|
||||||
@ -345,12 +353,12 @@ static void ParseConfig (void)
|
|||||||
/* Read the block */
|
/* Read the block */
|
||||||
switch (BlockTok) {
|
switch (BlockTok) {
|
||||||
|
|
||||||
case CFGTOK_CPU:
|
case CFGTOK_ADDRSPACE:
|
||||||
ParseCPU ();
|
ParseAddrSpace ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CFGTOK_MEMORY:
|
case CFGTOK_CPU:
|
||||||
ParseMemory ();
|
ParseCPU ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
2592
src/sim65/cpu-6502.c
Normal file
2592
src/sim65/cpu-6502.c
Normal file
File diff suppressed because it is too large
Load Diff
88
src/sim65/cpu-6502.h
Normal file
88
src/sim65/cpu-6502.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* cpucore.h */
|
||||||
|
/* */
|
||||||
|
/* CPU core for the 6502 simulator */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 2002-2003 Ullrich von Bassewitz */
|
||||||
|
/* Römerstrasse 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 CPUCORE_H
|
||||||
|
#define CPUCORE_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 cpucore.h */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
2552
src/sim65/cpucore.c
2552
src/sim65/cpucore.c
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,15 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* cpucore.h */
|
/* cpucore.h */
|
||||||
/* */
|
/* */
|
||||||
/* CPU core for the 6502 simulator */
|
/* CPU definition for the simulator */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2002-2003 Ullrich von Bassewitz */
|
/* (C) 2003-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -39,44 +39,36 @@
|
|||||||
|
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
#include "cpuregs.h"
|
#include "addrspace.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Data */
|
/* Data */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Registers */
|
/* CPU core structure */
|
||||||
extern CPURegs Regs;
|
typedef struct CPUCore CPUCore;
|
||||||
|
struct CPUCore {
|
||||||
|
void* Handle; /* Pointer to shared lib handle */
|
||||||
|
AddressSpace* AS; /* Address space */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The actual CPU instance */
|
||||||
|
extern CPUCore* CPU;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CPUInit (void);
|
CPUCore* NewCPUCore (const char* Name, unsigned AddrSpaceSize);
|
||||||
/* Initialize the CPU */
|
/* Create and return a new CPU including it's address space */
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -86,3 +78,4 @@ void CPURun (void);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ COMMON = ../common
|
|||||||
|
|
||||||
#
|
#
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -O2 -Wall -W -std=c89
|
CFLAGS = -g -Wall -W -std=c89
|
||||||
override CFLAGS += -I$(COMMON)
|
override CFLAGS += -I$(COMMON)
|
||||||
EBIND = emxbind
|
EBIND = emxbind
|
||||||
LDFLAGS = -ldl
|
LDFLAGS = -ldl
|
||||||
@ -27,13 +27,13 @@ OBJS = addrspace.o \
|
|||||||
chip.o \
|
chip.o \
|
||||||
chippath.o \
|
chippath.o \
|
||||||
config.o \
|
config.o \
|
||||||
|
cpu-6502.o \
|
||||||
cpucore.o \
|
cpucore.o \
|
||||||
cputype.o \
|
cputype.o \
|
||||||
error.o \
|
error.o \
|
||||||
global.o \
|
global.o \
|
||||||
location.o \
|
location.o \
|
||||||
main.o \
|
main.o \
|
||||||
memory.o \
|
|
||||||
scanner.o \
|
scanner.o \
|
||||||
system.o
|
system.o
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2002-2003 Ullrich von Bassewitz */
|
/* (C) 2002-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2002-2003 Ullrich von Bassewitz */
|
/* (C) 2002-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
/* (C) 1998-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
/* Current token and attributes */
|
/* Current token and attributes */
|
||||||
cfgtok_t CfgTok;
|
cfgtok_t CfgTok;
|
||||||
char CfgSVal [CFG_MAX_IDENT_LEN+1];
|
StrBuf CfgSVal = STATIC_STRBUF_INITIALIZER;
|
||||||
unsigned long CfgIVal;
|
unsigned long CfgIVal;
|
||||||
|
|
||||||
/* Error location */
|
/* Error location */
|
||||||
@ -266,7 +266,7 @@ Again:
|
|||||||
I = 0;
|
I = 0;
|
||||||
while (C != '\"') {
|
while (C != '\"') {
|
||||||
if (C == EOF || C == '\n') {
|
if (C == EOF || C == '\n') {
|
||||||
Error ("%s(%u): Unterminated string", CfgName, InputLine);
|
Error ("%s(%u): Unterminated string", CfgName, InputLine);
|
||||||
}
|
}
|
||||||
if (I < CFG_MAX_IDENT_LEN) {
|
if (I < CFG_MAX_IDENT_LEN) {
|
||||||
CfgSVal [I++] = C;
|
CfgSVal [I++] = C;
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* scanner.h */
|
/* scanner.h */
|
||||||
/* */
|
/* */
|
||||||
/* Configuration file scanner for the sim65 6502 simulator */
|
/* Configuration file scanner for the sim65 6502 simulator */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
/* (C) 1998-2012, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "attrib.h"
|
#include "attrib.h"
|
||||||
|
#include "strbuf.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -67,12 +68,11 @@ typedef enum {
|
|||||||
|
|
||||||
/* Primary blocks */
|
/* Primary blocks */
|
||||||
CFGTOK_CPU,
|
CFGTOK_CPU,
|
||||||
CFGTOK_MEMORY,
|
|
||||||
|
|
||||||
/* CPU block */
|
|
||||||
CFGTOK_TYPE,
|
|
||||||
CFGTOK_ADDRSPACE,
|
CFGTOK_ADDRSPACE,
|
||||||
|
|
||||||
|
/* Secondary stuff */
|
||||||
|
CFGTOK_TYPE,
|
||||||
|
|
||||||
/* Special identifiers */
|
/* Special identifiers */
|
||||||
CFGTOK_TRUE,
|
CFGTOK_TRUE,
|
||||||
CFGTOK_FALSE
|
CFGTOK_FALSE
|
||||||
@ -92,9 +92,8 @@ struct IdentTok {
|
|||||||
|
|
||||||
|
|
||||||
/* Current token and attributes */
|
/* Current token and attributes */
|
||||||
#define CFG_MAX_IDENT_LEN 255
|
|
||||||
extern cfgtok_t CfgTok;
|
extern cfgtok_t CfgTok;
|
||||||
extern char CfgSVal [CFG_MAX_IDENT_LEN+1];
|
extern StrBuf CfgSVal;
|
||||||
extern unsigned long CfgIVal;
|
extern unsigned long CfgIVal;
|
||||||
|
|
||||||
/* Error location */
|
/* Error location */
|
||||||
|
@ -89,6 +89,12 @@ struct SimData {
|
|||||||
* true. If not found, return false.
|
* true. If not found, return false.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
unsigned char (*ReadCtrl) (unsigned Addr);
|
||||||
|
/* Read from the given address without triggering any additional action */
|
||||||
|
|
||||||
|
void (*WriteCtrl) (unsigned Addr, unsigned char Val);
|
||||||
|
/* Write to the given address without triggering additional action */
|
||||||
|
|
||||||
void (*Break) (const char* Format, ...);
|
void (*Break) (const char* Format, ...);
|
||||||
/* Stop the CPU and display the given message */
|
/* Stop the CPU and display the given message */
|
||||||
|
|
||||||
@ -98,7 +104,7 @@ struct SimData {
|
|||||||
void (*NMI) (void);
|
void (*NMI) (void);
|
||||||
/* Issue an nmi request */
|
/* Issue an nmi request */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user