mirror of
https://github.com/cc65/cc65.git
synced 2025-02-27 14:29:52 +00:00
Working on the new backend
git-svn-id: svn://svn.cc65.org/cc65/trunk@701 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
9d1940a124
commit
88792854a6
@ -391,7 +391,7 @@ void g_defloclabel (unsigned label)
|
|||||||
/* Define a local label */
|
/* Define a local label */
|
||||||
{
|
{
|
||||||
if (CurSeg == SEG_CODE) {
|
if (CurSeg == SEG_CODE) {
|
||||||
AddCodeSegLabel (CS, LocalLabelName (label));
|
AddLocCodeLabel (CS, LocalLabelName (label));
|
||||||
} else {
|
} else {
|
||||||
AddDataSegLine (DS, "%s:", LocalLabelName (label));
|
AddDataSegLine (DS, "%s:", LocalLabelName (label));
|
||||||
}
|
}
|
||||||
@ -412,7 +412,7 @@ void g_defgloblabel (const char* Name)
|
|||||||
/* ##### */
|
/* ##### */
|
||||||
char Buf[64];
|
char Buf[64];
|
||||||
xsprintf (Buf, sizeof (Buf), "_%s", Name);
|
xsprintf (Buf, sizeof (Buf), "_%s", Name);
|
||||||
AddCodeSegLabel (CS, Buf);
|
AddExtCodeLabel (CS, Buf);
|
||||||
} else {
|
} else {
|
||||||
AddDataSegLine (DS, "_%s:", Name);
|
AddDataSegLine (DS, "_%s:", Name);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ CodeLabel* NewCodeLabel (const char* Name, unsigned Hash)
|
|||||||
L->Next = 0;
|
L->Next = 0;
|
||||||
L->Name = xstrdup (Name);
|
L->Name = xstrdup (Name);
|
||||||
L->Hash = Hash;
|
L->Hash = Hash;
|
||||||
|
L->Flags = 0;
|
||||||
L->Owner = 0;
|
L->Owner = 0;
|
||||||
InitCollection (&L->JumpFrom);
|
InitCollection (&L->JumpFrom);
|
||||||
|
|
||||||
|
@ -51,12 +51,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Label flags, bitmapped */
|
||||||
|
#define LF_DEF 0x0001U /* Label was defined */
|
||||||
|
#define LF_EXT 0x0002U /* Label is external */
|
||||||
|
|
||||||
/* Label structure */
|
/* Label structure */
|
||||||
typedef struct CodeLabel CodeLabel;
|
typedef struct CodeLabel CodeLabel;
|
||||||
struct CodeLabel {
|
struct CodeLabel {
|
||||||
CodeLabel* Next; /* Next in hash list */
|
CodeLabel* Next; /* Next in hash list */
|
||||||
char* Name; /* Label name */
|
char* Name; /* Label name */
|
||||||
unsigned Hash; /* Hash over the name */
|
unsigned short Hash; /* Hash over the name */
|
||||||
|
unsigned short Flags; /* Flag flags */
|
||||||
struct CodeEntry* Owner; /* Owner entry */
|
struct CodeEntry* Owner; /* Owner entry */
|
||||||
Collection JumpFrom; /* Entries that jump here */
|
Collection JumpFrom; /* Entries that jump here */
|
||||||
};
|
};
|
||||||
|
@ -390,11 +390,18 @@ void AddCodeSegLine (CodeSeg* S, const char* Format, ...)
|
|||||||
if (E) {
|
if (E) {
|
||||||
|
|
||||||
/* Transfer the labels if we have any */
|
/* Transfer the labels if we have any */
|
||||||
unsigned LabelCount = CollCount (&S->Labels);
|
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
unsigned LabelCount = CollCount (&S->Labels);
|
||||||
for (I = 0; I < LabelCount; ++I) {
|
for (I = 0; I < LabelCount; ++I) {
|
||||||
CollAppend (&E->Labels, CollAt (&S->Labels, I));
|
/* Get the label */
|
||||||
|
CodeLabel* L = CollAt (&S->Labels, I);
|
||||||
|
/* Mark it as defined */
|
||||||
|
L->Flags |= LF_DEF;
|
||||||
|
/* Move it to the code entry */
|
||||||
|
CollAppend (&E->Labels, L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Delete the transfered labels */
|
||||||
CollDeleteAll (&S->Labels);
|
CollDeleteAll (&S->Labels);
|
||||||
|
|
||||||
/* Add the entry to the list of code entries in this segment */
|
/* Add the entry to the list of code entries in this segment */
|
||||||
@ -405,8 +412,8 @@ void AddCodeSegLine (CodeSeg* S, const char* Format, ...)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AddCodeSegLabel (CodeSeg* S, const char* Name)
|
CodeLabel* AddCodeLabel (CodeSeg* S, const char* Name)
|
||||||
/* Add a label for the next instruction to follow */
|
/* Add a code label for the next instruction to follow */
|
||||||
{
|
{
|
||||||
/* Calculate the hash from the name */
|
/* Calculate the hash from the name */
|
||||||
unsigned Hash = HashStr (Name) % CS_LABEL_HASH_SIZE;
|
unsigned Hash = HashStr (Name) % CS_LABEL_HASH_SIZE;
|
||||||
@ -425,6 +432,30 @@ void AddCodeSegLabel (CodeSeg* S, const char* Name)
|
|||||||
|
|
||||||
/* We do now have a valid label. Remember it for later */
|
/* We do now have a valid label. Remember it for later */
|
||||||
CollAppend (&S->Labels, L);
|
CollAppend (&S->Labels, L);
|
||||||
|
|
||||||
|
/* Return the label */
|
||||||
|
return L;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AddExtCodeLabel (CodeSeg* S, const char* Name)
|
||||||
|
/* Add an external code label for the next instruction to follow */
|
||||||
|
{
|
||||||
|
/* Add the code label */
|
||||||
|
CodeLabel* L = AddCodeLabel (S, Name);
|
||||||
|
|
||||||
|
/* Mark it as external label */
|
||||||
|
L->Flags |= LF_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AddLocCodeLabel (CodeSeg* S, const char* Name)
|
||||||
|
/* Add a local code label for the next instruction to follow */
|
||||||
|
{
|
||||||
|
/* Add the code label */
|
||||||
|
AddCodeLabel (S, Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -450,23 +481,34 @@ void AddCodeSegHint (CodeSeg* S, unsigned Hint)
|
|||||||
|
|
||||||
|
|
||||||
void DelCodeSegAfter (CodeSeg* S, unsigned Last)
|
void DelCodeSegAfter (CodeSeg* S, unsigned Last)
|
||||||
/* Delete all entries after the given one */
|
/* Delete all entries including the given one */
|
||||||
{
|
{
|
||||||
unsigned I;
|
|
||||||
|
|
||||||
/* Get the number of entries in this segment */
|
/* Get the number of entries in this segment */
|
||||||
unsigned Count = CollCount (&S->Entries);
|
unsigned Count = CollCount (&S->Entries);
|
||||||
|
|
||||||
/* ### We need some more cleanup here wrt labels */
|
/* Must not be called with count zero */
|
||||||
|
CHECK (Count > 0 && Count >= Last);
|
||||||
|
|
||||||
/* Remove all entries after the given one */
|
/* Remove all entries after the given one */
|
||||||
for (I = Count-1; I > Last; --I) {
|
while (Last < Count) {
|
||||||
FreeCodeEntry (CollAt (&S->Entries, I));
|
|
||||||
CollDelete (&S->Entries, I);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete all waiting labels */
|
/* Get the next entry */
|
||||||
CollDeleteAll (&S->Labels);
|
CodeEntry* E = CollAt (&S->Entries, Count-1);
|
||||||
|
|
||||||
|
/* We have to transfer all labels to the code segment label pool */
|
||||||
|
unsigned LabelCount = CollCount (&E->Labels);
|
||||||
|
while (LabelCount--) {
|
||||||
|
CodeLabel* L = CollAt (&E->Labels, LabelCount);
|
||||||
|
L->Flags &= ~LF_DEF;
|
||||||
|
CollAppend (&S->Labels, L);
|
||||||
|
}
|
||||||
|
CollDeleteAll (&E->Labels);
|
||||||
|
|
||||||
|
/* Remove the code entry */
|
||||||
|
FreeCodeEntry (CollAt (&S->Entries, Count-1));
|
||||||
|
CollDelete (&S->Entries, Count-1);
|
||||||
|
--Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -565,24 +607,29 @@ void MergeCodeLabels (CodeSeg* S)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the label */
|
/* If the label is not an external label, we may remove the
|
||||||
|
* label completely.
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
if ((L->Flags & LF_EXT) == 0) {
|
||||||
FreeCodeLabel (L);
|
FreeCodeLabel (L);
|
||||||
|
|
||||||
/* Remove it from the list */
|
|
||||||
CollDelete (&E->Labels, J);
|
CollDelete (&E->Labels, J);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The reference label is the only remaining label. Check if there
|
/* The reference label is the only remaining label. If it is not an
|
||||||
* are any references to this label, and delete it if this is not
|
* external label, check if there are any references to this label,
|
||||||
* the case.
|
* and delete it if this is not the case.
|
||||||
*/
|
*/
|
||||||
if (CollCount (&RefLab->JumpFrom) == 0) {
|
#if 0
|
||||||
|
if ((RefLab->Flags & LF_EXT) == 0 && CollCount (&RefLab->JumpFrom) == 0) {
|
||||||
/* Delete the label */
|
/* Delete the label */
|
||||||
FreeCodeLabel (RefLab);
|
FreeCodeLabel (RefLab);
|
||||||
/* Remove it from the list */
|
/* Remove it from the list */
|
||||||
CollDelete (&E->Labels, 0);
|
CollDelete (&E->Labels, 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,14 +84,17 @@ void FreeCodeSeg (CodeSeg* S);
|
|||||||
void AddCodeSegLine (CodeSeg* S, const char* Format, ...) attribute ((format(printf,2,3)));
|
void AddCodeSegLine (CodeSeg* S, const char* Format, ...) attribute ((format(printf,2,3)));
|
||||||
/* Add a line to the given code segment */
|
/* Add a line to the given code segment */
|
||||||
|
|
||||||
void AddCodeSegLabel (CodeSeg* S, const char* Name);
|
void AddExtCodeLabel (CodeSeg* S, const char* Name);
|
||||||
/* Add a label for the next instruction to follow */
|
/* Add an external code label for the next instruction to follow */
|
||||||
|
|
||||||
|
void AddLocCodeLabel (CodeSeg* S, const char* Name);
|
||||||
|
/* Add a local code label for the next instruction to follow */
|
||||||
|
|
||||||
void AddCodeSegHint (CodeSeg* S, unsigned Hint);
|
void AddCodeSegHint (CodeSeg* S, unsigned Hint);
|
||||||
/* Add a hint for the preceeding instruction */
|
/* Add a hint for the preceeding instruction */
|
||||||
|
|
||||||
void DelCodeSegAfter (CodeSeg* S, unsigned Last);
|
void DelCodeSegAfter (CodeSeg* S, unsigned Last);
|
||||||
/* Delete all entries after the given one */
|
/* Delete all entries including the given one */
|
||||||
|
|
||||||
void OutputCodeSeg (FILE* F, const CodeSeg* S);
|
void OutputCodeSeg (FILE* F, const CodeSeg* S);
|
||||||
/* Output the code segment data to a file */
|
/* Output the code segment data to a file */
|
||||||
|
@ -76,10 +76,16 @@ all: depend
|
|||||||
@$(MAKE) -f make/gcc.mak all
|
@$(MAKE) -f make/gcc.mak all
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(EXE): $(OBJS) $(LIBS)
|
$(EXE): $(OBJS) $(LIBS) subs
|
||||||
$(CC) $(LDFLAGS) -o $(EXE) $(CFLAGS) $(OBJS) $(LIBS)
|
$(CC) $(LDFLAGS) -o $(EXE) $(CFLAGS) $(OBJS) $(LIBS)
|
||||||
@if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi
|
@if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi
|
||||||
|
|
||||||
|
.PHONY: subs
|
||||||
|
subs:
|
||||||
|
@for dir in $(COMMON) $(B6502); do \
|
||||||
|
$(MAKE) -C $$dir -f make/gcc.mak || exit 1; \
|
||||||
|
done
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ core *.map
|
rm -f *~ core *.map
|
||||||
|
|
||||||
|
@ -54,71 +54,79 @@
|
|||||||
|
|
||||||
/* Mapper table, mnemonic --> opcode */
|
/* Mapper table, mnemonic --> opcode */
|
||||||
static const OPCDesc OPCTable[OPC_COUNT] = {
|
static const OPCDesc OPCTable[OPC_COUNT] = {
|
||||||
{ "adc", OPC_ADC, CI_USE_A | CI_CHG_A },
|
{ "adc", OPC_ADC, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "and", OPC_AND, CI_USE_A | CI_CHG_A },
|
{ "and", OPC_AND, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "asl", OPC_ASL, CI_USE_A | CI_CHG_A },
|
{ "asl", OPC_ASL, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "bcc", OPC_BCC, CI_BRA },
|
{ "bcc", OPC_BCC, 2, CI_BRA },
|
||||||
{ "bcs", OPC_BCS, CI_BRA },
|
{ "bcs", OPC_BCS, 2, CI_BRA },
|
||||||
{ "beq", OPC_BEQ, CI_BRA },
|
{ "beq", OPC_BEQ, 2, CI_BRA },
|
||||||
{ "bit", OPC_BIT, CI_USE_A },
|
{ "bit", OPC_BIT, 0, CI_USE_A },
|
||||||
{ "bmi", OPC_BMI, CI_BRA },
|
{ "bmi", OPC_BMI, 2, CI_BRA },
|
||||||
{ "bne", OPC_BNE, CI_BRA },
|
{ "bne", OPC_BNE, 2, CI_BRA },
|
||||||
{ "bpl", OPC_BPL, CI_BRA },
|
{ "bpl", OPC_BPL, 2, CI_BRA },
|
||||||
{ "bra", OPC_BRA, CI_BRA },
|
{ "bra", OPC_BRA, 2, CI_BRA },
|
||||||
{ "brk", OPC_BRK, CI_BRA },
|
{ "brk", OPC_BRK, 1, CI_NONE },
|
||||||
{ "bvc", OPC_BVC, CI_BRA },
|
{ "bvc", OPC_BVC, 2, CI_BRA },
|
||||||
{ "bvs", OPC_BVS, CI_BRA },
|
{ "bvs", OPC_BVS, 2, CI_BRA },
|
||||||
{ "clc", OPC_CLC, CI_CHG_NONE },
|
{ "clc", OPC_CLC, 1, CI_CHG_NONE },
|
||||||
{ "cld", OPC_CLD, CI_CHG_NONE },
|
{ "cld", OPC_CLD, 1, CI_CHG_NONE },
|
||||||
{ "cli", OPC_CLI, CI_CHG_NONE },
|
{ "cli", OPC_CLI, 1, CI_CHG_NONE },
|
||||||
{ "clv", OPC_CLV, CI_CHG_NONE },
|
{ "clv", OPC_CLV, 1, CI_CHG_NONE },
|
||||||
{ "cmp", OPC_CMP, CI_USE_A },
|
{ "cmp", OPC_CMP, 0, CI_USE_A },
|
||||||
{ "cpx", OPC_CPX, CI_USE_X },
|
{ "cpx", OPC_CPX, 0, CI_USE_X },
|
||||||
{ "cpy", OPC_CPY, CI_USE_Y },
|
{ "cpy", OPC_CPY, 0, CI_USE_Y },
|
||||||
{ "dea", OPC_DEA, CI_USE_A | CI_CHG_A },
|
{ "dea", OPC_DEA, 1, CI_USE_A | CI_CHG_A },
|
||||||
{ "dec", OPC_DEC, CI_NONE },
|
{ "dec", OPC_DEC, 0, CI_NONE },
|
||||||
{ "dex", OPC_DEX, CI_USE_X | CI_CHG_X },
|
{ "dex", OPC_DEX, 1, CI_USE_X | CI_CHG_X },
|
||||||
{ "dey", OPC_DEY, CI_USE_Y | CI_CHG_Y },
|
{ "dey", OPC_DEY, 1, CI_USE_Y | CI_CHG_Y },
|
||||||
{ "eor", OPC_EOR, CI_USE_A | CI_CHG_A },
|
{ "eor", OPC_EOR, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "ina", OPC_INA, CI_USE_A | CI_CHG_A },
|
{ "ina", OPC_INA, 1, CI_USE_A | CI_CHG_A },
|
||||||
{ "inc", OPC_INC, CI_NONE },
|
{ "inc", OPC_INC, 0, CI_NONE },
|
||||||
{ "inx", OPC_INX, CI_USE_X | CI_CHG_X },
|
{ "inx", OPC_INX, 1, CI_USE_X | CI_CHG_X },
|
||||||
{ "iny", OPC_INY, CI_USE_Y | CI_CHG_Y },
|
{ "iny", OPC_INY, 1, CI_USE_Y | CI_CHG_Y },
|
||||||
{ "jmp", OPC_JMP, CI_BRA },
|
{ "jcc", OPC_JCC, 5, CI_BRA },
|
||||||
{ "jsr", OPC_JSR, CI_BRA },
|
{ "jcs", OPC_JCS, 5, CI_BRA },
|
||||||
{ "lda", OPC_LDA, CI_CHG_A },
|
{ "jeq", OPC_JEQ, 5, CI_BRA },
|
||||||
{ "ldx", OPC_LDX, CI_CHG_X },
|
{ "jmi", OPC_JMI, 5, CI_BRA },
|
||||||
{ "ldy", OPC_LDY, CI_CHG_Y },
|
{ "jmp", OPC_JMP, 3, CI_BRA },
|
||||||
{ "lsr", OPC_LSR, CI_USE_A | CI_CHG_A },
|
{ "jne", OPC_JNE, 5, CI_BRA },
|
||||||
{ "nop", OPC_NOP, CI_NONE },
|
{ "jpl", OPC_JPL, 5, CI_BRA },
|
||||||
{ "ora", OPC_ORA, CI_USE_A | CI_CHG_A },
|
{ "jsr", OPC_JSR, 3, CI_BRA },
|
||||||
{ "pha", OPC_PHA, CI_USE_A },
|
{ "jvc", OPC_JVC, 5, CI_BRA },
|
||||||
{ "php", OPC_PHP, CI_NONE },
|
{ "jvs", OPC_JVS, 5, CI_BRA },
|
||||||
{ "phx", OPC_PHX, CI_USE_X },
|
{ "lda", OPC_LDA, 0, CI_CHG_A },
|
||||||
{ "phy", OPC_PHY, CI_USE_Y },
|
{ "ldx", OPC_LDX, 0, CI_CHG_X },
|
||||||
{ "pla", OPC_PLA, CI_CHG_A },
|
{ "ldy", OPC_LDY, 0, CI_CHG_Y },
|
||||||
{ "plp", OPC_PLP, CI_NONE },
|
{ "lsr", OPC_LSR, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "plx", OPC_PLX, CI_CHG_X },
|
{ "nop", OPC_NOP, 1, CI_NONE },
|
||||||
{ "ply", OPC_PLY, CI_CHG_Y },
|
{ "ora", OPC_ORA, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "rol", OPC_ROL, CI_USE_A | CI_CHG_A },
|
{ "pha", OPC_PHA, 1, CI_USE_A },
|
||||||
{ "ror", OPC_ROR, CI_USE_A | CI_CHG_A },
|
{ "php", OPC_PHP, 1, CI_NONE },
|
||||||
{ "rti", OPC_RTI, CI_NONE },
|
{ "phx", OPC_PHX, 1, CI_USE_X },
|
||||||
{ "rts", OPC_RTS, CI_NONE },
|
{ "phy", OPC_PHY, 1, CI_USE_Y },
|
||||||
{ "sbc", OPC_SBC, CI_USE_A | CI_CHG_A },
|
{ "pla", OPC_PLA, 1, CI_CHG_A },
|
||||||
{ "sec", OPC_SEC, CI_NONE },
|
{ "plp", OPC_PLP, 1, CI_NONE },
|
||||||
{ "sed", OPC_SED, CI_NONE },
|
{ "plx", OPC_PLX, 1, CI_CHG_X },
|
||||||
{ "sei", OPC_SEI, CI_NONE },
|
{ "ply", OPC_PLY, 1, CI_CHG_Y },
|
||||||
{ "sta", OPC_STA, CI_USE_A },
|
{ "rol", OPC_ROL, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "stx", OPC_STX, CI_USE_X },
|
{ "ror", OPC_ROR, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "sty", OPC_STY, CI_USE_Y },
|
{ "rti", OPC_RTI, 1, CI_NONE },
|
||||||
{ "tax", OPC_TAX, CI_USE_A | CI_CHG_X },
|
{ "rts", OPC_RTS, 1, CI_NONE },
|
||||||
{ "tay", OPC_TAY, CI_USE_A | CI_CHG_Y },
|
{ "sbc", OPC_SBC, 0, CI_USE_A | CI_CHG_A },
|
||||||
{ "trb", OPC_TRB, CI_USE_A },
|
{ "sec", OPC_SEC, 1, CI_NONE },
|
||||||
{ "tsb", OPC_TSB, CI_USE_A },
|
{ "sed", OPC_SED, 1, CI_NONE },
|
||||||
{ "tsx", OPC_TSX, CI_CHG_X },
|
{ "sei", OPC_SEI, 1, CI_NONE },
|
||||||
{ "txa", OPC_TXA, CI_USE_X | CI_CHG_A },
|
{ "sta", OPC_STA, 0, CI_USE_A },
|
||||||
{ "txs", OPC_TXS, CI_USE_X },
|
{ "stx", OPC_STX, 0, CI_USE_X },
|
||||||
{ "tya", OPC_TYA, CI_USE_Y | CI_CHG_A }
|
{ "sty", OPC_STY, 0, CI_USE_Y },
|
||||||
|
{ "tax", OPC_TAX, 1, CI_USE_A | CI_CHG_X },
|
||||||
|
{ "tay", OPC_TAY, 1, CI_USE_A | CI_CHG_Y },
|
||||||
|
{ "trb", OPC_TRB, 0, CI_USE_A },
|
||||||
|
{ "tsb", OPC_TSB, 0, CI_USE_A },
|
||||||
|
{ "tsx", OPC_TSX, 1, CI_CHG_X },
|
||||||
|
{ "txa", OPC_TXA, 1, CI_USE_X | CI_CHG_A },
|
||||||
|
{ "txs", OPC_TXS, 1, CI_USE_X },
|
||||||
|
{ "tya", OPC_TYA, 1, CI_USE_Y | CI_CHG_A }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -168,9 +176,13 @@ const OPCDesc* FindOpcode (const char* M)
|
|||||||
unsigned GetInsnSize (opc_t OPC, am_t AM)
|
unsigned GetInsnSize (opc_t OPC, am_t AM)
|
||||||
/* Return the size of the given instruction */
|
/* Return the size of the given instruction */
|
||||||
{
|
{
|
||||||
/* On the 6502 (and 65C02), the instruction size is determined only by the
|
/* Get the opcode desc and check the size given there */
|
||||||
* addressing mode.
|
const OPCDesc* D = &OPCTable[OPC];
|
||||||
*/
|
if (D->Size != 0) {
|
||||||
|
return D->Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the addressing mode. */
|
||||||
switch (AM) {
|
switch (AM) {
|
||||||
case AM_IMP: return 1;
|
case AM_IMP: return 1;
|
||||||
case AM_ACC: return 1;
|
case AM_ACC: return 1;
|
||||||
@ -183,7 +195,6 @@ unsigned GetInsnSize (opc_t OPC, am_t AM)
|
|||||||
case AM_ZPX_IND: return 2;
|
case AM_ZPX_IND: return 2;
|
||||||
case AM_ZP_INDY: return 2;
|
case AM_ZP_INDY: return 2;
|
||||||
case AM_ZP_IND: return 2;
|
case AM_ZP_IND: return 2;
|
||||||
case AM_BRA: return 2;
|
|
||||||
default: FAIL ("Invalid addressing mode");
|
default: FAIL ("Invalid addressing mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,16 @@ typedef enum {
|
|||||||
OPC_INC,
|
OPC_INC,
|
||||||
OPC_INX,
|
OPC_INX,
|
||||||
OPC_INY,
|
OPC_INY,
|
||||||
|
OPC_JCC,
|
||||||
|
OPC_JCS,
|
||||||
|
OPC_JEQ,
|
||||||
|
OPC_JMI,
|
||||||
OPC_JMP,
|
OPC_JMP,
|
||||||
|
OPC_JNE,
|
||||||
|
OPC_JPL,
|
||||||
OPC_JSR,
|
OPC_JSR,
|
||||||
|
OPC_JVC,
|
||||||
|
OPC_JVS,
|
||||||
OPC_LDA,
|
OPC_LDA,
|
||||||
OPC_LDX,
|
OPC_LDX,
|
||||||
OPC_LDY,
|
OPC_LDY,
|
||||||
@ -134,6 +142,7 @@ typedef enum {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char Mnemo[4]; /* Mnemonic */
|
char Mnemo[4]; /* Mnemonic */
|
||||||
opc_t OPC; /* Opcode */
|
opc_t OPC; /* Opcode */
|
||||||
|
unsigned Size; /* Size, 0 means "check addressing mode" */
|
||||||
unsigned Info; /* Usage flags */
|
unsigned Info; /* Usage flags */
|
||||||
} OPCDesc;
|
} OPCDesc;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user