Skip to content

Commit

Permalink
Protoize
Browse files Browse the repository at this point in the history
command:
  protoize -c '-m32 -DTARGET_CPU=CPU_6502' -g $(ls *.c | grep -v 68)
  • Loading branch information
pdewacht committed Jan 23, 2016
1 parent b9748cb commit e10a35e
Show file tree
Hide file tree
Showing 34 changed files with 1,130 additions and 1,661 deletions.
107 changes: 34 additions & 73 deletions actions_6502.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@
and operand.
*/

void
actionsDir1(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];

bool isByteAddress (valueType *value);
bool isDefined (valueType *value);
extern void emitByte (byte byteValue);
bool wordCheck (int value);
extern void putFixupsHere (fixupKindType kindOfFixupsToPut, int whichFixup);
extern void emitWord (wordType wordValue);
bool byteCheck (int value);
bool isByteOffset (int value);
extern void error (errorType theError, ...);

void
actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define ZERO_PAGE_ADDRESS_BIT 0x00
#define NON_ZERO_PAGE_ADDRESS_BIT 0x08
Expand All @@ -66,10 +74,7 @@ actionsDir1(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsDir2(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDir2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
if (wordCheck(address)) {
emitByte(binary);
Expand All @@ -79,10 +84,7 @@ actionsDir2(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsDirIndir(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_BIT 0x00
#define INDIRECT_ADDRESS_BIT 0x20
Expand All @@ -98,10 +100,7 @@ actionsDirIndir(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsDirX1(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirX1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X1 0x04
#define A_REGISTER_BITS_X1 0x08
Expand Down Expand Up @@ -133,10 +132,7 @@ actionsDirX1(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsDirX2(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X2 0x00
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_X2 0x08
Expand Down Expand Up @@ -165,10 +161,7 @@ actionsDirX2(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsDirX3(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
if (class == EXPRESSION_OPND) {
if (isByteAddress(operand) && isDefined(operand)) {
Expand All @@ -189,10 +182,7 @@ actionsDirX3(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsDirY(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_Y 0x00
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_Y 0x08
Expand All @@ -217,10 +207,7 @@ actionsDirY(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsImmDir(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmDir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define IMMEDIATE_DATA_BITS_ID 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_ID 0x04
Expand All @@ -245,10 +232,7 @@ actionsImmDir(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsImmDirX(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmDirX(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define IMMEDIATE_DATA_BITS_IX 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IX 0x04
Expand Down Expand Up @@ -284,10 +268,7 @@ actionsImmDirX(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsImmDirY(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define IMMEDIATE_DATA_BITS_IY 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IY 0x04
Expand Down Expand Up @@ -323,10 +304,7 @@ actionsImmDirY(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsImmIndex(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define PRE_INDEXED_BITS_A 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_A 0x04
Expand Down Expand Up @@ -383,10 +361,7 @@ actionsImmIndex(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsIndex(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
if (class == EXPRESSION_OPND) {
if (isByteAddress(operand) && isDefined(operand)) {
Expand Down Expand Up @@ -428,19 +403,13 @@ actionsIndex(opcode, numberOfOperands, evaluatedOperands)
}

void
actionsNone(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
emitByte(binary);
}

void
actionsRelative(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
int offset;

Expand All @@ -465,43 +434,37 @@ actionsRelative(opcode, numberOfOperands, evaluatedOperands)
*/

bool
isByte(value)
int value;
isByte(int value)
{
return (-129<value && value<256);
}

bool
isByteOffset(value)
int value;
isByteOffset(int value)
{
return (-129<value && value<128);
}

bool
isWordOffset(value)
int value;
isWordOffset(int value)
{
return (-32769<value && value<32768);
}

bool
isByteAddress(value)
valueType *value;
isByteAddress(valueType *value)
{
return(value->kindOfValue==ABSOLUTE_VALUE && isByte(value->value));
}

bool
isWord(value)
int value;
isWord(int value)
{
return (-32769<value && value<65536);
}

bool
byteCheck(value)
int value;
byteCheck(int value)
{
if (isByte(value)) {
return(TRUE);
Expand All @@ -512,8 +475,7 @@ byteCheck(value)
}

bool
wordCheck(value)
int value;
wordCheck(int value)
{
if (isWord(value)) {
return(TRUE);
Expand All @@ -525,8 +487,7 @@ wordCheck(value)
}

bool
isDefined(value)
valueType *value;
isDefined(valueType *value)
{
return(value!=NULL && value->kindOfValue!=UNDEFINED_VALUE);
}
Loading

0 comments on commit e10a35e

Please sign in to comment.