mirror of
https://github.com/Museum-of-Art-and-Digital-Entertainment/macross.git
synced 2024-06-02 14:41:26 +00:00
Merge 5b952ae580
into 9921797235
This commit is contained in:
commit
951a58e7a6
|
@ -17,6 +17,9 @@ void actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueTy
|
|||
void actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||
void actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||
void actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||
void actionsSTZ(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||
void actionsBitZPRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||
void actionsBitZP(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||
bool isByte(int value);
|
||||
bool isByteOffset(int value);
|
||||
bool isWordOffset(int value);
|
||||
|
|
147
actions_6502.c
147
actions_6502.c
|
@ -55,7 +55,10 @@ actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **eval
|
|||
#define ZERO_PAGE_ADDRESS_BIT 0x00
|
||||
#define NON_ZERO_PAGE_ADDRESS_BIT 0x08
|
||||
|
||||
if(class==EXPRESSION_OPND && isByteAddress(operand) &&
|
||||
/* only used for BIT */
|
||||
/* 65c02 bit uses actionsDirX2 */
|
||||
|
||||
if (class==EXPRESSION_OPND && isByteAddress(operand) &&
|
||||
isDefined(operand)){
|
||||
emitByte(binary | ZERO_PAGE_ADDRESS_BIT);
|
||||
emitByte(address);
|
||||
|
@ -81,10 +84,13 @@ actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **
|
|||
{
|
||||
#define DIRECT_ADDRESS_BIT 0x00
|
||||
#define INDIRECT_ADDRESS_BIT 0x20
|
||||
#define INDIRECT_ADDRESS_BIT_X 0x30
|
||||
|
||||
if (wordCheck(address)) {
|
||||
if (class == INDIRECT_OPND)
|
||||
emitByte(binary | INDIRECT_ADDRESS_BIT);
|
||||
else if (class == PRE_INDEXED_X_OPND || class == PRE_SELECTED_X_OPND) /* 65c02 jmp (abs,x) */
|
||||
emitByte(binary | INDIRECT_ADDRESS_BIT_X);
|
||||
else
|
||||
emitByte(binary | DIRECT_ADDRESS_BIT);
|
||||
putFixupsHere(WORD_FIXUP, 0);
|
||||
|
@ -132,7 +138,21 @@ actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **eva
|
|||
#define X_INDEXED_ZERO_PAGE_BITS_X2 0x10
|
||||
#define X_INDEXED_NON_ZERO_PAGE_BITS_X2 0x18
|
||||
|
||||
if (class == EXPRESSION_OPND) {
|
||||
/*
|
||||
special case for 65c02 inc a / dec a which were shoe-horned in
|
||||
*/
|
||||
if (class == A_REGISTER_OPND) {
|
||||
emitByte(binary == 0xC6 ? 0x3A : 0x1A);
|
||||
}
|
||||
else if (class == IMMEDIATE_OPND) {
|
||||
/* special case for 65c02 bit #immediate */
|
||||
if (byteCheck(address)) {
|
||||
emitByte(0x89);
|
||||
putFixupsHere(BYTE_FIXUP, 0);
|
||||
emitByte(address);
|
||||
}
|
||||
}
|
||||
else if (class == EXPRESSION_OPND) {
|
||||
if (isByteAddress(operand) && isDefined(operand)) {
|
||||
emitByte(binary | DIRECT_ADDRESS_ZERO_PAGE_BITS_X2);
|
||||
emitByte(address);
|
||||
|
@ -174,6 +194,31 @@ actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **eva
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
actionsSTZ(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||
{
|
||||
/* STZ was shoe-horned in for the 65c02 and the encoding doesn't match up nicely */
|
||||
if (class == EXPRESSION_OPND) {
|
||||
if (isByteAddress(operand) && isDefined(operand)) {
|
||||
emitByte(0x64);
|
||||
emitByte(address);
|
||||
} else if (wordCheck(address)) {
|
||||
emitByte(0x9C);
|
||||
putFixupsHere(WORD_FIXUP, 0);
|
||||
emitWord(address);
|
||||
}
|
||||
} else {
|
||||
if (isByteAddress(operand) && isDefined(operand)) {
|
||||
emitByte(0x74);
|
||||
emitByte(address);
|
||||
} else if (wordCheck(address)) {
|
||||
emitByte(0x9E);
|
||||
putFixupsHere(WORD_FIXUP, 0);
|
||||
emitWord(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||
{
|
||||
|
@ -307,6 +352,7 @@ actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **
|
|||
#define X_INDEXED_ZERO_PAGE_BITS_A 0x14
|
||||
#define Y_INDEXED_NON_ZERO_PAGE_BITS_A 0x18
|
||||
#define X_INDEXED_NON_ZERO_PAGE_BITS_A 0x1C
|
||||
#define INDIRECT_OPND_BITS_A 0x11
|
||||
|
||||
if (class == EXPRESSION_OPND) {
|
||||
if (isByteAddress(operand) && isDefined(operand)) {
|
||||
|
@ -344,6 +390,13 @@ actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **
|
|||
putFixupsHere(BYTE_FIXUP, 0);
|
||||
emitByte(address);
|
||||
}
|
||||
} else if (class == INDIRECT_OPND) {
|
||||
/* 65c02 */
|
||||
if (byteCheck(address)) {
|
||||
emitByte(binary + INDIRECT_OPND_BITS_A);
|
||||
putFixupsHere(BYTE_FIXUP, 0);
|
||||
emitByte(address);
|
||||
}
|
||||
} else {
|
||||
if (byteCheck(address)) {
|
||||
emitByte(binary | PRE_INDEXED_BITS_A);
|
||||
|
@ -386,6 +439,13 @@ actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **eva
|
|||
putFixupsHere(BYTE_FIXUP, 0);
|
||||
emitByte(address);
|
||||
}
|
||||
} else if (class == INDIRECT_OPND) {
|
||||
/* 65c02 */
|
||||
if (byteCheck(address)) {
|
||||
emitByte(binary + INDIRECT_OPND_BITS_A);
|
||||
putFixupsHere(BYTE_FIXUP, 0);
|
||||
emitByte(address);
|
||||
}
|
||||
} else {
|
||||
if (byteCheck(address)) {
|
||||
emitByte(binary | PRE_INDEXED_BITS_A);
|
||||
|
@ -422,6 +482,89 @@ actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
actionsBitZPRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||
{
|
||||
/* rockwell 65c02 bbr bit,zp,branch and bbs bit,zp,branch. */
|
||||
|
||||
#define operand_0 (evaluatedOperands[0])
|
||||
#define address_0 (evaluatedOperands[0])->value
|
||||
#define class_0 (evaluatedOperands[0])->addressMode
|
||||
|
||||
#define operand_1 (evaluatedOperands[1])
|
||||
#define address_1 (evaluatedOperands[1])->value
|
||||
#define class_1 (evaluatedOperands[1])->addressMode
|
||||
|
||||
#define operand_2 (evaluatedOperands[2])
|
||||
#define address_2 (evaluatedOperands[2])->value
|
||||
#define class_2 (evaluatedOperands[2])->addressMode
|
||||
|
||||
|
||||
int bit;
|
||||
int zp;
|
||||
int offset;
|
||||
|
||||
|
||||
if (class_0 == EXPRESSION_OPND && isDefined(operand_0) && address_0 >= 0 && address_0 <= 7) {
|
||||
bit = address_0;
|
||||
} else {
|
||||
error(BIT_VALUE_TOO_LARGE_ERROR, address_0);
|
||||
}
|
||||
|
||||
if (class_1 == EXPRESSION_OPND && isDefined(operand_1) && isByteAddress(operand_1)) {
|
||||
zp = address_1;
|
||||
} else {
|
||||
error(BYTE_VALUE_TOO_LARGE_ERROR, address_1);
|
||||
zp = 0;
|
||||
}
|
||||
|
||||
if (operand_2->kindOfValue == UNDEFINED_VALUE || (currentCodeMode ==
|
||||
RELOCATABLE_BUFFER && targetOffset == 0))
|
||||
offset = 0;
|
||||
else
|
||||
offset = address_2 - (currentLocationCounter.value - targetOffset) - 2;
|
||||
if (offset < 0)
|
||||
offset--;
|
||||
if (isByteOffset(offset)) {
|
||||
emitByte(binary + (bit << 4));
|
||||
emitByte(zp);
|
||||
putFixupsHere(BYTE_RELATIVE_FIXUP, 0);
|
||||
emitByte(offset);
|
||||
} else {
|
||||
error(RELATIVE_OFFSET_TOO_LARGE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
actionsBitZP(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||
{
|
||||
/* rockwell 65c02 smb bit,zp and rmb bit,zp */
|
||||
|
||||
|
||||
int bit;
|
||||
int zp;
|
||||
|
||||
if (class_0 == EXPRESSION_OPND && isDefined(operand_0) && address_0 >= 0 && address_0 <= 7) {
|
||||
bit = address_0;
|
||||
} else {
|
||||
error(BIT_VALUE_TOO_LARGE_ERROR, address_0);
|
||||
}
|
||||
|
||||
if (class_1 == EXPRESSION_OPND && isDefined(operand_1) && isByteAddress(operand_1)) {
|
||||
zp = address_1;
|
||||
} else {
|
||||
error(BYTE_VALUE_TOO_LARGE_ERROR, address_1);
|
||||
zp = 0;
|
||||
}
|
||||
|
||||
emitByte(binary + (bit << 4));
|
||||
emitByte(zp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Miscellaneous helper predicates.
|
||||
*/
|
||||
|
|
|
@ -56,6 +56,7 @@ emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupL
|
|||
#define BNE_OPCODE 0xD0
|
||||
#define NOP_OPCODE 0xEA
|
||||
#define BEQ_OPCODE 0xF0
|
||||
#define BRA_OPCODE 0x80
|
||||
|
||||
static byte conditionalBranchOpcodes[] = {
|
||||
/* CARRY_COND */ BCS_OPCODE,
|
||||
|
@ -66,7 +67,7 @@ emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupL
|
|||
/* LEQ_COND */ COMPOUND,
|
||||
/* SLT_COND */ COMPOUND,
|
||||
/* SLEQ_COND */ COMPOUND,
|
||||
/* ALWAYS_COND */ NOP_OPCODE,
|
||||
/* ALWAYS_COND */ COMPOUND,
|
||||
/* NOT_CARRY_COND */ BCC_OPCODE,
|
||||
/* NOT_ZERO_COND */ BNE_OPCODE,
|
||||
/* NOT_NEGATIVE_COND */ BPL_OPCODE,
|
||||
|
@ -85,11 +86,21 @@ emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupL
|
|||
if (fixupLocation != NULL)
|
||||
for (i=0; i<COMPOUND_BRANCH_MAX; i++)
|
||||
fixupLocation[i].value = -1;
|
||||
|
||||
if (conditionalBranchOpcodes[(int)condition] != COMPOUND) {
|
||||
emitByte(conditionalBranchOpcodes[(int)condition]);
|
||||
conditionalFixup(0);
|
||||
} else switch (condition) {
|
||||
|
||||
case ALWAYS_COND:
|
||||
if (processor > P6502) {
|
||||
emitByte(BRA_OPCODE); conditionalFixup(0);
|
||||
} else {
|
||||
emitByte(BCS_OPCODE); conditionalFixup(0);
|
||||
emitByte(BCC_OPCODE); conditionalFixup(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case GT_COND:
|
||||
emitByte(BEQ_OPCODE); emitByte(2);
|
||||
emitByte(BCS_OPCODE); conditionalFixup(0);
|
||||
|
@ -150,13 +161,17 @@ emitJump(valueType *target, simpleFixupListType *previousFixups)
|
|||
result = previousFixups;
|
||||
if (positionIndependentCodeMode) {
|
||||
if (target == NULL) {
|
||||
emitRelativeBranch(CARRY_COND, NULL, picFixup);
|
||||
result = buildSimpleFixupList(picFixup[0], result);
|
||||
emitRelativeBranch(NOT_CARRY_COND, NULL, picFixup);
|
||||
result = buildSimpleFixupList(picFixup[0], result);
|
||||
if (processor > P6502) {
|
||||
emitRelativeBranch(ALWAYS_COND, NULL, picFixup);
|
||||
result = buildSimpleFixupList(picFixup[0], result);
|
||||
} else {
|
||||
emitRelativeBranch(CARRY_COND, NULL, picFixup);
|
||||
result = buildSimpleFixupList(picFixup[0], result);
|
||||
emitRelativeBranch(NOT_CARRY_COND, NULL, picFixup);
|
||||
result = buildSimpleFixupList(picFixup[0], result);
|
||||
}
|
||||
} else {
|
||||
emitRelativeBranch(CARRY_COND, target, NULL);
|
||||
emitRelativeBranch(NOT_CARRY_COND, target, NULL);
|
||||
emitRelativeBranch(ALWAYS_COND, target, NULL);
|
||||
}
|
||||
} else {
|
||||
emitByte(JUMP_OPCODE);
|
||||
|
|
|
@ -220,6 +220,10 @@ printErrorMessage(errorType theError, va_list ap)
|
|||
"fatal: no name definition given on command line after '-D'",
|
||||
"bad name definition: '%s'",
|
||||
"warning: perform statement has no side effects",
|
||||
"value %d is too large to fit in a bit",
|
||||
"fatal: no processor given on command line after '-P'",
|
||||
"fatal: unknown processor: %s",
|
||||
|
||||
};
|
||||
|
||||
static int errorCount = 0;
|
||||
|
|
|
@ -102,6 +102,7 @@ addressType targetOffset;
|
|||
bool terseErrorMessages;
|
||||
valueType *UndefinedValue;
|
||||
symbolUsageKindType unknownSymbolTag;
|
||||
int processor;
|
||||
|
||||
int (*lexDispatchTable[128])();
|
||||
|
||||
|
|
61
initialize.c
61
initialize.c
|
@ -36,6 +36,7 @@
|
|||
#include "semanticMisc.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define isAlphaNumeric(c) (alphaNumericCharacterTable[c])
|
||||
|
@ -45,6 +46,7 @@ extern int yydebug;
|
|||
static fileNameListType *bottomOfInputFileStack;
|
||||
static char *outputFileName;
|
||||
|
||||
|
||||
void
|
||||
chokePukeAndDie(void)
|
||||
{
|
||||
|
@ -139,6 +141,7 @@ initializeStuff(int argc, char **argv)
|
|||
symbolTableDumpOn = 0;
|
||||
positionIndependentCodeMode = FALSE;
|
||||
hackFlag = 0;
|
||||
processor = P6502; /* 6502 */
|
||||
|
||||
args = argv + 1;
|
||||
for (i=1; i<argc; i++) {
|
||||
|
@ -220,6 +223,26 @@ initializeStuff(int argc, char **argv)
|
|||
positionIndependentCodeMode = TRUE;
|
||||
continue;
|
||||
|
||||
case 'P':
|
||||
/* -P 6502 65c02 w65c02 65c02 */
|
||||
|
||||
if (++i >= argc) {
|
||||
fatalError(NO_DASH_P_PROCESSOR_ERROR);
|
||||
} else {
|
||||
char *cpu = *args++;
|
||||
if (strcasecmp(cpu, "6502") == 0)
|
||||
processor = P6502;
|
||||
else if (strcasecmp(cpu, "65c02") == 0)
|
||||
processor = P65C02;
|
||||
else if (strcasecmp(cpu, "65c02r") == 0)
|
||||
processor = P65C02R;
|
||||
else if (strcasecmp(cpu, "65c02s") == 0)
|
||||
processor = P65C02S;
|
||||
else
|
||||
fatalError(DASH_P_UNKNOWN_PROCESSOR, cpu);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 's':
|
||||
case 'S':
|
||||
case 'h':
|
||||
|
@ -335,6 +358,7 @@ initializeStuff(int argc, char **argv)
|
|||
installBuiltInFunctions();
|
||||
installPredefinedSymbols();
|
||||
installCommandLineDefineSymbols();
|
||||
installProcessorDefine();
|
||||
|
||||
if (listingOn) {
|
||||
if ((saveFileForPass2 = fdopen(mkstemp(pass2SourceFileName),
|
||||
|
@ -385,7 +409,7 @@ installBuiltInFunctions(void)
|
|||
for (i=0; builtInFunctionTable[i].functionName!=NULL; i++) {
|
||||
newFunction = lookupOrEnterSymbol(builtInFunctionTable[i].
|
||||
functionName, BUILT_IN_FUNCTION_SYMBOL);
|
||||
newFunction->context->value =newValue(BUILT_IN_FUNCTION_VALUE,
|
||||
newFunction->context->value = newValue(BUILT_IN_FUNCTION_VALUE,
|
||||
i, EXPRESSION_OPND);
|
||||
if (builtInFunctionTable[i].isSpecialFunction)
|
||||
newFunction->context->attributes |=
|
||||
|
@ -425,6 +449,33 @@ installCommandLineDefineSymbols(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
installStringDefine(char *name, char *value)
|
||||
{
|
||||
symbolTableEntryType *newSymbol;
|
||||
|
||||
newSymbol = lookupOrEnterSymbol(name, DEFINE_SYMBOL);
|
||||
newSymbol->context->value = makeStringValue(value);
|
||||
newSymbol->context->attributes |= DEFINED_VARIABLE_ATT;
|
||||
}
|
||||
|
||||
void
|
||||
installProcessorDefine()
|
||||
{
|
||||
static char *values[] = {
|
||||
"",
|
||||
"6502",
|
||||
"65c02",
|
||||
"",
|
||||
"65c02r",
|
||||
"",
|
||||
"65c02s",
|
||||
};
|
||||
|
||||
installStringDefine("__processor__", values[processor]);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
createHashTables(void)
|
||||
{
|
||||
|
@ -433,8 +484,12 @@ createHashTables(void)
|
|||
conditionTableEntryType *newConditionEntry;
|
||||
|
||||
newOpcodeEntry = theOpcodes;
|
||||
while (newOpcodeEntry->mnemonic != NULL)
|
||||
hashStringEnter(newOpcodeEntry++, opcodeTable);
|
||||
while (newOpcodeEntry->mnemonic != NULL) {
|
||||
int subClass = newOpcodeEntry->subClass;
|
||||
if ((subClass == 0) || (subClass & processor))
|
||||
hashStringEnter(newOpcodeEntry, opcodeTable);
|
||||
newOpcodeEntry++;
|
||||
}
|
||||
|
||||
newKeywordEntry = theKeywords;
|
||||
while (newKeywordEntry->string != NULL)
|
||||
|
|
|
@ -8,6 +8,7 @@ void initializeStuff(int argc, char **argv);
|
|||
void installBuiltInFunctions(void);
|
||||
void installPredefinedSymbols(void);
|
||||
void installCommandLineDefineSymbols(void);
|
||||
void installProcessorDefine();
|
||||
void createHashTables(void);
|
||||
void queueInputFile(char *name);
|
||||
void openFirstInputFile(void);
|
||||
|
|
|
@ -102,6 +102,7 @@ extern addressType targetOffset;
|
|||
extern bool terseErrorMessages;
|
||||
extern valueType *UndefinedValue;
|
||||
extern symbolUsageKindType unknownSymbolTag;
|
||||
extern int processor;
|
||||
|
||||
#define DEFAULT_OBJECT_FILE_NAME "m.out"
|
||||
|
||||
|
|
|
@ -127,19 +127,84 @@ keywordTableEntryType *keywordTable[HASH_TABLE_SIZE];
|
|||
|
||||
conditionTableEntryType *conditionTable[HASH_TABLE_SIZE];
|
||||
|
||||
|
||||
#define m P6502 /* mos 6502 */
|
||||
#define c P65C02 /* wdc 65c02 */
|
||||
#define r P65C02R /* rockwell 65c02 */
|
||||
/* wdc w65c02s is c | r */
|
||||
/* 0 means all machines */
|
||||
|
||||
|
||||
/*
|
||||
65c02 modifications:
|
||||
adc (zp)
|
||||
and (zp)
|
||||
bit abs,x
|
||||
bit #immediate
|
||||
bit zp,x
|
||||
cmp (zp)
|
||||
dec a
|
||||
eor (zp)
|
||||
inc a
|
||||
jmp (abs,x)
|
||||
lda (zp)
|
||||
ora (zp)
|
||||
sbc (zp)
|
||||
sta (zp)
|
||||
|
||||
additions:
|
||||
bra relative
|
||||
phx
|
||||
phy
|
||||
plx
|
||||
ply
|
||||
stp [not present in rockwell 65c02]
|
||||
stz abs
|
||||
stz abs,x
|
||||
stz zp
|
||||
stz zp,x
|
||||
trb abs
|
||||
trb zp
|
||||
tsb abs
|
||||
tsb zp
|
||||
wai [not present in rockwell 65c02]
|
||||
*/
|
||||
|
||||
/*
|
||||
rockwell 65c02 additions:
|
||||
bbr
|
||||
bbs
|
||||
rmb
|
||||
smb
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* All those NULLs are used to string together lists after this all gets
|
||||
hashed. */
|
||||
opcodeTableEntryType theOpcodes[] = {
|
||||
"adc", NULL, 0x61, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, 0,
|
||||
"and", NULL, 0x21, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, 0,
|
||||
opcodeTableEntryType theOpcodes[] = {
|
||||
|
||||
"adc", NULL, 0x61, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, m,
|
||||
"adc", NULL, 0x61, IMM_INDEX, IMM_INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"and", NULL, 0x21, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, m,
|
||||
"and", NULL, 0x21, IMM_INDEX, IMM_INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"asl", NULL, 0x02, DIR_X_1, DIR_X_1_CLASS_BITS, 1, 1, 0,
|
||||
"bbr", NULL, 0x0F, BIT_ZP_REL,ANY_OPND_BITS, 3, 3, r, /* r65c02 */
|
||||
"bbs", NULL, 0x8F, BIT_ZP_REL,ANY_OPND_BITS, 3, 3, r, /* r65c02 */
|
||||
"bcc", NULL, 0x90, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
"bcs", NULL, 0xB0, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
"beq", NULL, 0xF0, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
"bit", NULL, 0x24, DIR_1, DIR_1_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"bit", NULL, 0x24, DIR_1, DIR_1_CLASS_BITS, 1, 1, m,
|
||||
"bit", NULL, 0x24, DIR_X_2, DIR_X_2_CLASS_BITS|IMMEDIATE_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"bmi", NULL, 0x30, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
"bne", NULL, 0xD0, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
"bpl", NULL, 0x10, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
"bra", NULL, 0x80, RELATIVE, REL_CLASS_BITS, 1, 1, c | r, /* 65c02 */
|
||||
"brk", NULL, 0x00, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"bvc", NULL, 0x50, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
"bvs", NULL, 0x70, RELATIVE, REL_CLASS_BITS, 1, 1, 0,
|
||||
|
@ -147,48 +212,88 @@ opcodeTableEntryType theOpcodes[] = {
|
|||
"cld", NULL, 0xD8, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"cli", NULL, 0x58, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"clv", NULL, 0xB8, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"cmp", NULL, 0xC1, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"cmp", NULL, 0xC1, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, m,
|
||||
"cmp", NULL, 0xC1, IMM_INDEX, IMM_INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"cpx", NULL, 0xE0, IMM_DIR, IMM_DIR_CLASS_BITS, 1, 1, 0,
|
||||
"cpy", NULL, 0xC0, IMM_DIR, IMM_DIR_CLASS_BITS, 1, 1, 0,
|
||||
"dec", NULL, 0xC6, DIR_X_2, DIR_X_2_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"dec", NULL, 0xC6, DIR_X_2, DIR_X_2_CLASS_BITS, 1, 1, m,
|
||||
"dec", NULL, 0xC6, DIR_X_2, DIR_X_2_CLASS_BITS|A_REGISTER_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"dex", NULL, 0xCA, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"dey", NULL, 0x88, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"eor", NULL, 0x41, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, 0,
|
||||
"inc", NULL, 0xE6, DIR_X_2, DIR_X_2_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"eor", NULL, 0x41, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, m,
|
||||
"eor", NULL, 0x41, IMM_INDEX, IMM_INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"inc", NULL, 0xE6, DIR_X_2, DIR_X_2_CLASS_BITS, 1, 1, m,
|
||||
"inc", NULL, 0xE6, DIR_X_2, DIR_X_2_CLASS_BITS|A_REGISTER_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"inx", NULL, 0xE8, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"iny", NULL, 0xC8, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"jmp", NULL, 0x4C, DIR_INDIR, DIR_INDIR_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"jmp", NULL, 0x4C, DIR_INDIR, DIR_INDIR_CLASS_BITS, 1, 1, m,
|
||||
"jmp", NULL, 0x4C, DIR_INDIR, DIR_INDIR_CLASS_BITS|PRE_INDEXED_X_OPND_BIT|PRE_SELECTED_X_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"jsr", NULL, 0x20, DIR_2, DIR_2_CLASS_BITS, 1, 1, 0,
|
||||
"lda", NULL, 0xA1, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"lda", NULL, 0xA1, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, m,
|
||||
"lda", NULL, 0xA1, IMM_INDEX, IMM_INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"ldx", NULL, 0xA2, IMM_DIR_Y, IMM_DIR_Y_CLASS_BITS, 1, 1, 0,
|
||||
"ldy", NULL, 0xA0, IMM_DIR_X, IMM_DIR_X_CLASS_BITS, 1, 1, 0,
|
||||
"lsr", NULL, 0x42, DIR_X_1, DIR_X_1_CLASS_BITS, 1, 1, 0,
|
||||
"nop", NULL, 0xEA, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"ora", NULL, 0x01, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"ora", NULL, 0x01, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, m,
|
||||
"ora", NULL, 0x01, IMM_INDEX, IMM_INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"pha", NULL, 0x48, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"php", NULL, 0x08, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"phx", NULL, 0xDA, NONE, NONE_CLASS_BITS, 0, 0, c | r, /* 65c02 */
|
||||
"phy", NULL, 0x5A, NONE, NONE_CLASS_BITS, 0, 0, c | r, /* 65c02 */
|
||||
"pla", NULL, 0x68, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"plp", NULL, 0x28, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"plx", NULL, 0xFA, NONE, NONE_CLASS_BITS, 0, 0, c | r, /* 65c02 */
|
||||
"ply", NULL, 0x7A, NONE, NONE_CLASS_BITS, 0, 0, c | r, /* 65c02 */
|
||||
"rmb", NULL, 0x07, BIT_ZP, ANY_OPND_BITS, 2, 2, r, /* r65c02 */
|
||||
"rol", NULL, 0x22, DIR_X_1, DIR_X_1_CLASS_BITS, 1, 1, 0,
|
||||
"ror", NULL, 0x62, DIR_X_1, DIR_X_1_CLASS_BITS, 1, 1, 0,
|
||||
"rti", NULL, 0x40, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"rts", NULL, 0x60, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"sbc", NULL, 0xE1, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, 0,
|
||||
|
||||
"sbc", NULL, 0xE1, IMM_INDEX, IMM_INDEX_CLASS_BITS, 1, 1, m,
|
||||
"sbc", NULL, 0xE1, IMM_INDEX, IMM_INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"sec", NULL, 0x38, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"sed", NULL, 0xF8, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"sei", NULL, 0x78, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"sta", NULL, 0x81, INDEX, INDEX_CLASS_BITS, 1, 1, 0,
|
||||
"smb", NULL, 0x87, BIT_ZP, ANY_OPND_BITS, 2, 2, r, /* r65c02 */
|
||||
|
||||
"sta", NULL, 0x81, INDEX, INDEX_CLASS_BITS, 1, 1, m,
|
||||
"sta", NULL, 0x81, INDEX, INDEX_CLASS_BITS|INDIRECT_OPND_BIT, 1, 1, c | r,
|
||||
|
||||
"stp", NULL, 0xDB, NONE, NONE_CLASS_BITS, 0, 0, c, /* 65c02 */
|
||||
"stx", NULL, 0x86, DIR_Y, DIR_Y_CLASS_BITS, 1, 1, 0,
|
||||
"sty", NULL, 0x84, DIR_X_3, DIR_X_3_CLASS_BITS, 1, 1, 0,
|
||||
"stz", NULL, 0x64, DIR_STZ, DIR_X_2_CLASS_BITS, 1, 1, c | r, /* 65c02 */
|
||||
"tax", NULL, 0xAA, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"tay", NULL, 0xA8, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"trb", NULL, 0x14, DIR_1, DIR_1_CLASS_BITS, 1, 1, c | r, /* 65c02 */
|
||||
"tsb", NULL, 0x04, DIR_1, DIR_1_CLASS_BITS, 1, 1, c | r, /* 65c02 */
|
||||
"tsx", NULL, 0xBA, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"txa", NULL, 0x8A, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"txs", NULL, 0x9A, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"tya", NULL, 0x98, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
"wai", NULL, 0xCB, NONE, NONE_CLASS_BITS, 0, 0, c, /* 65c02 */
|
||||
/* new instructions */
|
||||
|
||||
NULL, NULL, 0x00, NONE, NONE_CLASS_BITS, 0, 0, 0,
|
||||
};
|
||||
|
||||
|
||||
int operandClassTable[] = { /* indexed by operandKindType */
|
||||
EXPRESSION_OPND_BIT,
|
||||
IMMEDIATE_OPND_BIT,
|
||||
|
@ -223,6 +328,9 @@ int (*instructionActionTable[])() = {
|
|||
actionsNone,
|
||||
actionsIndex,
|
||||
actionsImmIndex,
|
||||
actionsSTZ,
|
||||
actionsBitZPRelative,
|
||||
actionsBitZP,
|
||||
};
|
||||
|
||||
/* indexed by symbolUsageKindType */
|
||||
|
|
|
@ -1075,10 +1075,21 @@ typedef enum {
|
|||
NO_DASH_D_FILE_NAME_ERROR,
|
||||
BAD_COMMAND_LINE_DEFINE_ERROR,
|
||||
PERFORM_WITHOUT_SIDE_EFFECT_ERROR,
|
||||
BIT_VALUE_TOO_LARGE_ERROR,
|
||||
NO_DASH_P_PROCESSOR_ERROR,
|
||||
DASH_P_UNKNOWN_PROCESSOR,
|
||||
} errorType;
|
||||
|
||||
#define ERROR_LIMIT 300
|
||||
|
||||
/* 6502 processor type */
|
||||
enum {
|
||||
P6502 = 1,
|
||||
P65C02 = 2,
|
||||
P65C02R = 4,
|
||||
P65C02S = 6,
|
||||
};
|
||||
|
||||
/* Misc. macros: */
|
||||
|
||||
#define qfree(thing) if (freeFlag) free(thing);
|
||||
|
|
|
@ -48,7 +48,8 @@ typedef enum {
|
|||
others right too. */
|
||||
typedef enum {
|
||||
RELATIVE, DIR_1, DIR_2, DIR_INDIR, DIR_X_1, DIR_X_2, DIR_X_3,
|
||||
DIR_Y, IMM_DIR, IMM_DIR_X, IMM_DIR_Y, NONE, INDEX, IMM_INDEX
|
||||
DIR_Y, IMM_DIR, IMM_DIR_X, IMM_DIR_Y, NONE, INDEX, IMM_INDEX,
|
||||
DIR_STZ, BIT_ZP_REL, BIT_ZP,
|
||||
} addressClassType;
|
||||
|
||||
#define NO_OPND_BIT 0x0000
|
||||
|
@ -98,4 +99,4 @@ typedef enum {
|
|||
POST_INDEXED_Y_OPND_BIT | \
|
||||
EXPRESSION_OPND_BIT | PRE_SELECTED_X_OPND_BIT
|
||||
|
||||
#define MAX_NUMBER_OF_OPERANDS 1
|
||||
#define MAX_NUMBER_OF_OPERANDS 3
|
||||
|
|
Loading…
Reference in New Issue
Block a user