Merge remote-tracking branch 'upstream/master' into creativision

This commit is contained in:
Christian Groessler
2017-02-01 18:15:05 +01:00
404 changed files with 8404 additions and 3086 deletions

View File

@@ -2,16 +2,17 @@ ifneq ($(shell echo),)
CMD_EXE = 1
endif
PROGS = ar65 \
ca65 \
cc65 \
cl65 \
co65 \
da65 \
grc65 \
ld65 \
od65 \
sim65 \
PROGS = ar65 \
ca65 \
cc65 \
chrcvt65 \
cl65 \
co65 \
da65 \
grc65 \
ld65 \
od65 \
sim65 \
sp65
.PHONY: all mostlyclean clean install zip avail unavail bin $(PROGS)
@@ -23,6 +24,7 @@ datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..))
CA65_INC = $(datadir)/asminc
CC65_INC = $(datadir)/include
CL65_TGT = $(datadir)/target
LD65_LIB = $(datadir)/lib
LD65_OBJ = $(datadir)/lib
LD65_CFG = $(datadir)/cfg
@@ -62,8 +64,9 @@ endif
CFLAGS += -MMD -MP -O -I common \
-Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \
-DGIT_SHA=$(GIT_SHA) -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
-DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \
-DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
-DGIT_SHA=$(GIT_SHA)
LDLIBS += -lm

View File

@@ -121,7 +121,7 @@ int main (int argc, char* argv [])
break;
case 'V':
fprintf (stderr, "ar65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
break;
default:

View File

@@ -386,6 +386,16 @@ void DoConditionals (void)
CalcOverallIfCond ();
break;
case TOK_IFP4510:
D = AllocIf (".IFP4510", 1);
NextTok ();
if (IfCond) {
SetIfCond (D, GetCPU() == CPU_4510);
}
ExpectSep ();
CalcOverallIfCond ();
break;
case TOK_IFP816:
D = AllocIf (".IFP816", 1);
NextTok ();
@@ -457,6 +467,7 @@ int CheckConditionals (void)
case TOK_IFNDEF:
case TOK_IFNREF:
case TOK_IFP02:
case TOK_IFP4510:
case TOK_IFP816:
case TOK_IFPC02:
case TOK_IFPSC02:

View File

@@ -40,6 +40,7 @@
#include "expr.h"
#include "instr.h"
#include "nexttok.h"
#include "global.h"
@@ -53,6 +54,20 @@ void GetEA (EffAddr* A)
/* Parse an effective address, return the result in A */
{
unsigned long Restrictions;
token_t IndirectEnter;
token_t IndirectLeave;
const char* IndirectExpect;
/* Choose syntax for indirection */
if (BracketAsIndirect) {
IndirectEnter = TOK_LBRACK;
IndirectLeave = TOK_RBRACK;
IndirectExpect = "']' expected";
} else {
IndirectEnter = TOK_LPAREN;
IndirectLeave = TOK_RPAREN;
IndirectExpect = "')' expected";
}
/* Clear the output struct */
A->AddrModeSet = 0;
@@ -97,23 +112,7 @@ void GetEA (EffAddr* A)
NextTok ();
A->AddrModeSet = AM65_ACCU;
} else if (CurTok.Tok == TOK_LBRACK) {
/* [dir] or [dir],y */
NextTok ();
A->Expr = Expression ();
Consume (TOK_RBRACK, "']' expected");
if (CurTok.Tok == TOK_COMMA) {
/* [dir],y */
NextTok ();
Consume (TOK_Y, "`Y' expected");
A->AddrModeSet = AM65_DIR_IND_LONG_Y;
} else {
/* [dir] */
A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG;
}
} else if (CurTok.Tok == TOK_LPAREN) {
} else if (CurTok.Tok == IndirectEnter) {
/* One of the indirect modes */
NextTok ();
@@ -127,12 +126,12 @@ void GetEA (EffAddr* A)
/* (adr,x) */
NextTok ();
A->AddrModeSet = AM65_ABS_X_IND | AM65_DIR_X_IND;
ConsumeRParen ();
Consume (IndirectLeave, IndirectExpect);
} else if (CurTok.Tok == TOK_S) {
/* (rel,s),y */
NextTok ();
A->AddrModeSet = AM65_STACK_REL_IND_Y;
ConsumeRParen ();
Consume (IndirectLeave, IndirectExpect);
ConsumeComma ();
Consume (TOK_Y, "`Y' expected");
} else {
@@ -141,19 +140,46 @@ void GetEA (EffAddr* A)
} else {
/* (adr) or (adr),y */
ConsumeRParen ();
/* (adr), (adr),y or (adr),z */
Consume (IndirectLeave, IndirectExpect);
if (CurTok.Tok == TOK_COMMA) {
/* (adr),y */
NextTok ();
Consume (TOK_Y, "`Y' expected");
A->AddrModeSet = AM65_DIR_IND_Y;
switch (CurTok.Tok) {
case TOK_Z:
/* only set by scanner.c if in 4510-mode */
NextTok ();
A->AddrModeSet = AM65_DIR_IND;
break;
default:
Consume (TOK_Y, "`Y' expected");
A->AddrModeSet = AM65_DIR_IND_Y;
break;
}
} else {
/* (adr) */
A->AddrModeSet = AM65_ABS_IND | AM65_ABS_IND_LONG | AM65_DIR_IND;
A->AddrModeSet = (CPU == CPU_4510) ? AM65_ABS_IND
: AM65_ABS_IND | AM65_ABS_IND_LONG | AM65_DIR_IND;
}
}
} else if (CurTok.Tok == TOK_LBRACK) {
/* Never executed if BracketAsIndirect feature is enabled. */
/* [dir] or [dir],y */
NextTok ();
A->Expr = Expression ();
Consume (TOK_RBRACK, "']' expected");
if (CurTok.Tok == TOK_COMMA) {
/* [dir],y */
NextTok ();
Consume (TOK_Y, "`Y' expected");
A->AddrModeSet = AM65_DIR_IND_LONG_Y;
} else {
/* [dir] */
A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG;
}
} else {
/* Remaining stuff:

View File

@@ -144,7 +144,7 @@ static void AddNotifications (const Collection* LineInfos)
break;
case LI_TYPE_EXT:
Msg = "Assembler code generated from this line";
Msg = "Assembly code generated from this line";
break;
case LI_TYPE_MACRO:

View File

@@ -64,6 +64,7 @@ static const char* FeatureKeys[FEAT_COUNT] = {
"force_range",
"underline_in_numbers",
"addrsize",
"bracket_as_indirect",
};
@@ -121,6 +122,7 @@ feature_t SetFeature (const StrBuf* Key)
case FEAT_FORCE_RANGE: ForceRange = 1; break;
case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= 1; break;
case FEAT_ADDRSIZE: AddrSize = 1; break;
case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = 1; break;
default: /* Keep gcc silent */ break;
}

View File

@@ -66,6 +66,7 @@ typedef enum {
FEAT_FORCE_RANGE,
FEAT_UNDERLINE_IN_NUMBERS,
FEAT_ADDRSIZE,
FEAT_BRACKET_AS_INDIRECT,
/* Special value: Number of features available */
FEAT_COUNT

View File

@@ -83,4 +83,5 @@ unsigned char CComments = 0; /* Allow C like comments */
unsigned char ForceRange = 0; /* Force values into expected range */
unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */
unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */
unsigned char BracketAsIndirect = 0; /* Use '[]' not '()' for indirection */

View File

@@ -85,6 +85,7 @@ extern unsigned char CComments; /* Allow C like comments */
extern unsigned char ForceRange; /* Force values into expected range */
extern unsigned char UnderlineInNumbers; /* Allow underlines in numbers */
extern unsigned char AddrSize; /* Allow .ADDRSIZE function */
extern unsigned char BracketAsIndirect; /* Use '[]' not '()' for indirection */

View File

@@ -73,6 +73,9 @@ static void PutPCRel8 (const InsDesc* Ins);
static void PutPCRel16 (const InsDesc* Ins);
/* Handle branches with an 16 bit distance and PER */
static void PutPCRel4510 (const InsDesc* Ins);
/* Handle branches with a 16 bit distance for 4510 */
static void PutBlockMove (const InsDesc* Ins);
/* Handle the blockmove instructions (65816) */
@@ -125,6 +128,9 @@ static void PutRTS (const InsDesc* Ins attribute ((unused)));
static void PutAll (const InsDesc* Ins);
/* Handle all other instructions */
static void Put4510 (const InsDesc* Ins);
/* Handle instructions of 4510 not matching any EATab */
static void PutSweet16 (const InsDesc* Ins);
/* Handle a generic sweet16 instruction */
@@ -376,7 +382,7 @@ static const struct {
/* Instruction table for the 65C02 */
static const struct {
unsigned Count;
InsDesc Ins[98];
InsDesc Ins[100];
} InsTab65C02 = {
sizeof (InsTab65C02.Ins) / sizeof (InsTab65C02.Ins[0]),
{
@@ -467,6 +473,7 @@ static const struct {
{ "SMB6", 0x0000004, 0xE7, 1, PutAll },
{ "SMB7", 0x0000004, 0xF7, 1, PutAll },
{ "STA", 0x000A66C, 0x80, 0, PutAll },
{ "STP", 0x0000001, 0xdb, 0, PutAll },
{ "STX", 0x000010c, 0x82, 1, PutAll },
{ "STY", 0x000002c, 0x80, 1, PutAll },
{ "STZ", 0x000006c, 0x04, 5, PutAll },
@@ -477,7 +484,151 @@ static const struct {
{ "TSX", 0x0000001, 0xba, 0, PutAll },
{ "TXA", 0x0000001, 0x8a, 0, PutAll },
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
{ "TYA", 0x0000001, 0x98, 0, PutAll }
{ "TYA", 0x0000001, 0x98, 0, PutAll },
{ "WAI", 0x0000001, 0xcb, 0, PutAll }
}
};
/* Instruction table for the 4510 */
static const struct {
unsigned Count;
InsDesc Ins[133];
} InsTab4510 = {
sizeof (InsTab4510.Ins) / sizeof (InsTab4510.Ins[0]),
{
{ "ADC", 0x080A66C, 0x60, 0, PutAll },
{ "AND", 0x080A66C, 0x20, 0, PutAll },
{ "ASL", 0x000006e, 0x02, 1, PutAll },
{ "ASR", 0x0000026, 0x43, 0, Put4510 },
{ "ASW", 0x0000008, 0xcb, 6, PutAll },
{ "BBR0", 0x0000000, 0x0F, 0, PutBitBranch },
{ "BBR1", 0x0000000, 0x1F, 0, PutBitBranch },
{ "BBR2", 0x0000000, 0x2F, 0, PutBitBranch },
{ "BBR3", 0x0000000, 0x3F, 0, PutBitBranch },
{ "BBR4", 0x0000000, 0x4F, 0, PutBitBranch },
{ "BBR5", 0x0000000, 0x5F, 0, PutBitBranch },
{ "BBR6", 0x0000000, 0x6F, 0, PutBitBranch },
{ "BBR7", 0x0000000, 0x7F, 0, PutBitBranch },
{ "BBS0", 0x0000000, 0x8F, 0, PutBitBranch },
{ "BBS1", 0x0000000, 0x9F, 0, PutBitBranch },
{ "BBS2", 0x0000000, 0xAF, 0, PutBitBranch },
{ "BBS3", 0x0000000, 0xBF, 0, PutBitBranch },
{ "BBS4", 0x0000000, 0xCF, 0, PutBitBranch },
{ "BBS5", 0x0000000, 0xDF, 0, PutBitBranch },
{ "BBS6", 0x0000000, 0xEF, 0, PutBitBranch },
{ "BBS7", 0x0000000, 0xFF, 0, PutBitBranch },
{ "BCC", 0x0020000, 0x90, 0, PutPCRel8 },
{ "BCS", 0x0020000, 0xb0, 0, PutPCRel8 },
{ "BEQ", 0x0020000, 0xf0, 0, PutPCRel8 },
{ "BIT", 0x0A0006C, 0x00, 2, PutAll },
{ "BMI", 0x0020000, 0x30, 0, PutPCRel8 },
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BSR", 0x0040000, 0x63, 0, PutPCRel4510 },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll },
{ "CLD", 0x0000001, 0xd8, 0, PutAll },
{ "CLE", 0x0000001, 0x02, 0, PutAll },
{ "CLI", 0x0000001, 0x58, 0, PutAll },
{ "CLV", 0x0000001, 0xb8, 0, PutAll },
{ "CMP", 0x080A66C, 0xc0, 0, PutAll },
{ "CPX", 0x080000C, 0xe0, 1, PutAll },
{ "CPY", 0x080000C, 0xc0, 1, PutAll },
{ "CPZ", 0x080000C, 0xd0, 1, Put4510 },
{ "DEA", 0x0000001, 0x00, 3, PutAll }, /* == DEC */
{ "DEC", 0x000006F, 0x00, 3, PutAll },
{ "DEW", 0x0000004, 0xc3, 9, PutAll },
{ "DEX", 0x0000001, 0xca, 0, PutAll },
{ "DEY", 0x0000001, 0x88, 0, PutAll },
{ "DEZ", 0x0000001, 0x3B, 0, PutAll },
{ "EOM", 0x0000001, 0xea, 0, PutAll },
{ "EOR", 0x080A66C, 0x40, 0, PutAll },
{ "INA", 0x0000001, 0x00, 4, PutAll }, /* == INC */
{ "INC", 0x000006f, 0x00, 4, PutAll },
{ "INW", 0x0000004, 0xe3, 9, PutAll },
{ "INX", 0x0000001, 0xe8, 0, PutAll },
{ "INY", 0x0000001, 0xc8, 0, PutAll },
{ "INZ", 0x0000001, 0x1B, 0, PutAll },
{ "JMP", 0x0010808, 0x4c, 6, PutAll },
{ "JSR", 0x0010808, 0x20, 7, Put4510 },
{ "LBCC", 0x0040000, 0x93, 0, PutPCRel4510 },
{ "LBCS", 0x0040000, 0xb3, 0, PutPCRel4510 },
{ "LBEQ", 0x0040000, 0xf3, 0, PutPCRel4510 },
{ "LBMI", 0x0040000, 0x33, 0, PutPCRel4510 },
{ "LBNE", 0x0040000, 0xd3, 0, PutPCRel4510 },
{ "LBPL", 0x0040000, 0x13, 0, PutPCRel4510 },
{ "LBRA", 0x0040000, 0x83, 0, PutPCRel4510 },
{ "LBVC", 0x0040000, 0x53, 0, PutPCRel4510 },
{ "LBVS", 0x0040000, 0x73, 0, PutPCRel4510 },
{ "LDA", 0x090A66C, 0xa0, 0, Put4510 },
{ "LDX", 0x080030C, 0xa2, 1, PutAll },
{ "LDY", 0x080006C, 0xa0, 1, PutAll },
{ "LDZ", 0x0800048, 0xa3, 1, Put4510 },
{ "LSR", 0x000006F, 0x42, 1, PutAll },
{ "MAP", 0x0000001, 0x5C, 0, PutAll },
{ "NEG", 0x0000001, 0x42, 0, PutAll },
{ "NOP", 0x0000001, 0xea, 0, PutAll }, /* == EOM */
{ "ORA", 0x080A66C, 0x00, 0, PutAll },
{ "PHA", 0x0000001, 0x48, 0, PutAll },
{ "PHD", 0x8000008, 0xf4, 1, PutAll }, /* == PHW */
{ "PHP", 0x0000001, 0x08, 0, PutAll },
{ "PHW", 0x8000008, 0xf4, 1, PutAll },
{ "PHX", 0x0000001, 0xda, 0, PutAll },
{ "PHY", 0x0000001, 0x5a, 0, PutAll },
{ "PHZ", 0x0000001, 0xdb, 0, PutAll },
{ "PLA", 0x0000001, 0x68, 0, PutAll },
{ "PLP", 0x0000001, 0x28, 0, PutAll },
{ "PLX", 0x0000001, 0xfa, 0, PutAll },
{ "PLY", 0x0000001, 0x7a, 0, PutAll },
{ "PLZ", 0x0000001, 0xfb, 0, PutAll },
{ "RMB0", 0x0000004, 0x07, 1, PutAll },
{ "RMB1", 0x0000004, 0x17, 1, PutAll },
{ "RMB2", 0x0000004, 0x27, 1, PutAll },
{ "RMB3", 0x0000004, 0x37, 1, PutAll },
{ "RMB4", 0x0000004, 0x47, 1, PutAll },
{ "RMB5", 0x0000004, 0x57, 1, PutAll },
{ "RMB6", 0x0000004, 0x67, 1, PutAll },
{ "RMB7", 0x0000004, 0x77, 1, PutAll },
{ "ROL", 0x000006F, 0x22, 1, PutAll },
{ "ROR", 0x000006F, 0x62, 1, PutAll },
{ "ROW", 0x0000008, 0xeb, 6, PutAll },
{ "RTI", 0x0000001, 0x40, 0, PutAll },
{ "RTN", 0x0800000, 0x62, 1, PutAll },
{ "RTS", 0x0000001, 0x60, 0, PutAll },
{ "SBC", 0x080A66C, 0xe0, 0, PutAll },
{ "SEC", 0x0000001, 0x38, 0, PutAll },
{ "SED", 0x0000001, 0xf8, 0, PutAll },
{ "SEE", 0x0000001, 0x03, 0, PutAll },
{ "SEI", 0x0000001, 0x78, 0, PutAll },
{ "SMB0", 0x0000004, 0x87, 1, PutAll },
{ "SMB1", 0x0000004, 0x97, 1, PutAll },
{ "SMB2", 0x0000004, 0xA7, 1, PutAll },
{ "SMB3", 0x0000004, 0xB7, 1, PutAll },
{ "SMB4", 0x0000004, 0xC7, 1, PutAll },
{ "SMB5", 0x0000004, 0xD7, 1, PutAll },
{ "SMB6", 0x0000004, 0xE7, 1, PutAll },
{ "SMB7", 0x0000004, 0xF7, 1, PutAll },
{ "STA", 0x010A66C, 0x80, 0, Put4510 },
{ "STX", 0x000030c, 0x82, 1, Put4510 },
{ "STY", 0x000006c, 0x80, 1, Put4510 },
{ "STZ", 0x000006c, 0x04, 5, PutAll },
{ "TAB", 0x0000001, 0x5b, 0, PutAll },
{ "TAX", 0x0000001, 0xaa, 0, PutAll },
{ "TAY", 0x0000001, 0xa8, 0, PutAll },
{ "TAZ", 0x0000001, 0x4b, 0, PutAll },
{ "TBA", 0x0000001, 0x7b, 0, PutAll },
{ "TRB", 0x000000c, 0x10, 1, PutAll },
{ "TSB", 0x000000c, 0x00, 1, PutAll },
{ "TSX", 0x0000001, 0xba, 0, PutAll },
{ "TSY", 0x0000001, 0x0b, 0, PutAll },
{ "TXA", 0x0000001, 0x8a, 0, PutAll },
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
{ "TYA", 0x0000001, 0x98, 0, PutAll },
{ "TYS", 0x0000001, 0x2b, 0, PutAll },
{ "TZA", 0x0000001, 0x6b, 0, PutAll },
}
};
@@ -784,6 +935,7 @@ static const InsTable* InsTabs[CPU_COUNT] = {
(const InsTable*) &InsTabSweet16,
(const InsTable*) &InsTabHuC6280,
0, /* Mitsubishi 740 */
(const InsTable*) &InsTab4510,
};
const InsTable* InsTab = (const InsTable*) &InsTab6502;
@@ -795,73 +947,73 @@ static unsigned char EATab[12][AM65I_COUNT] = {
0x00, 0x00, 0x05, 0x0D, 0x0F, 0x15, 0x1D, 0x1F,
0x00, 0x19, 0x12, 0x00, 0x07, 0x11, 0x17, 0x01,
0x00, 0x00, 0x00, 0x03, 0x13, 0x09, 0x00, 0x09,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 1 */
0x08, 0x08, 0x04, 0x0C, 0x00, 0x14, 0x1C, 0x00,
0x14, 0x1C, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80
0x00, 0x00, 0x80, 0x00
},
{ /* Table 2 */
0x00, 0x00, 0x24, 0x2C, 0x0F, 0x34, 0x3C, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 3 */
0x3A, 0x3A, 0xC6, 0xCE, 0x00, 0xD6, 0xDE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 4 */
0x1A, 0x1A, 0xE6, 0xEE, 0x00, 0xF6, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 5 */
0x00, 0x00, 0x60, 0x98, 0x00, 0x70, 0x9E, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 6 */
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x90
0x00, 0x00, 0x90, 0x00
},
{ /* Table 7 */
{ /* Table 7 (Subroutine opcodes) */
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 8 */
0x00, 0x40, 0x01, 0x41, 0x00, 0x09, 0x49, 0x00,
0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 9 */
0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x30, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 10 (NOPs) */
0xea, 0x00, 0x04, 0x0c, 0x00, 0x14, 0x1c, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00
},
{ /* Table 11 (LAX) */
0x08, 0x08, 0x04, 0x0C, 0x00, 0x14, 0x1C, 0x00,
0x14, 0x1C, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x80
0x00, 0x00, 0x80, 0x00
},
};
@@ -906,6 +1058,7 @@ unsigned char ExtBytes[AM65I_COUNT] = {
2, /* Blockmove (65816) */
7, /* Block transfer (HuC6280) */
2, /* Absolute Indirect long */
2, /* Immidiate word */
};
/* Table that encodes the additional bytes for each SWEET16 instruction */
@@ -1031,7 +1184,7 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A)
** limit the expression to the maximum possible value.
*/
if (A->AddrMode == AM65I_IMM_ACCU || A->AddrMode == AM65I_IMM_INDEX ||
A->AddrMode == AM65I_IMM_IMPLICIT) {
A->AddrMode == AM65I_IMM_IMPLICIT || A->AddrMode == AM65I_IMM_IMPLICIT_WORD) {
if (ForceRange && A->Expr) {
A->Expr = MakeBoundedExpr (A->Expr, ExtBytes[A->AddrMode]);
}
@@ -1134,6 +1287,14 @@ static void PutPCRel16 (const InsDesc* Ins)
static void PutPCRel4510 (const InsDesc* Ins)
/* Handle branches with a 16 bit distance */
{
/* 16 bit branch opcode is 8 bit branch opcode or'ed with 0x03 */
EmitPCRel (Ins->BaseCode, GenBranchExpr (2), 2);
}
static void PutBlockMove (const InsDesc* Ins)
/* Handle the blockmove instructions (65816) */
{
@@ -1381,6 +1542,53 @@ static void PutAll (const InsDesc* Ins)
static void Put4510 (const InsDesc* Ins)
/* Handle all other instructions, with modifications for 4510 */
{
/* The 4510 uses all 256 possible opcodes, so the last ones were crammed
** in where an opcode was still undefined. As a result, some of those
** don't follow any rules for encoding the addressmodes. So the EATab
** approach does not work always. In this function, the wrongly calculated
** opcode is replaced by the correct one "on the fly". Suggestions for a
** better approach are welcome.
**
** These are:
** $47 -> $44 : ASR $12
** $57 -> $54 : ASR $12,X
** $93 -> $82 : STA ($12,SP),Y
** $9c -> $8b : STY $1234,X
** $9e -> $9b : STX $1234,Y
** $af -> $ab : LDZ $1234
** $bf -> $bb : LDZ $1234,X
** $b3 -> $e2 : LDA ($12,SP),Y
** $d0 -> $c2 : CPZ #$00
** $fc -> $23 : JSR ($1234,X)
*/
EffAddr A;
/* Evaluate the addressing mode used */
if (EvalEA (Ins, &A)) {
switch (A.Opcode) {
case 0x47: A.Opcode = 0x44; break;
case 0x57: A.Opcode = 0x54; break;
case 0x93: A.Opcode = 0x82; break;
case 0x9C: A.Opcode = 0x8B; break;
case 0x9E: A.Opcode = 0x9B; break;
case 0xAF: A.Opcode = 0xAB; break;
case 0xBF: A.Opcode = 0xBB; break;
case 0xB3: A.Opcode = 0xE2; break;
case 0xD0: A.Opcode = 0xC2; break;
case 0xFC: A.Opcode = 0x23; break;
default: /* Keep opcode as it is */ break;
}
/* No error, output code */
EmitCode (&A);
}
}
/*****************************************************************************/
/* Handler functions for SWEET16 */
/*****************************************************************************/

View File

@@ -85,6 +85,7 @@
#define AM65_BLOCKMOVE 0x01000000UL
#define AM65_BLOCKXFER 0x02000000UL
#define AM65_ABS_IND_LONG 0x04000000UL
#define AM65_IMM_IMPLICIT_WORD 0x08000000UL /* PHW #$1234 (4510 only) */
/* Bitmask for all ZP operations that have correspondent ABS ops */
#define AM65_SET_ZP (AM65_DIR | AM65_DIR_X | AM65_DIR_Y | AM65_DIR_IND | AM65_DIR_X_IND)
@@ -102,13 +103,14 @@
#define AM65_ALL_FAR (AM65_ABS_LONG | AM65_ABS_LONG_X)
/* Bitmask for all immediate operations */
#define AM65_ALL_IMM (AM65_IMM_ACCU | AM65_IMM_INDEX | AM65_IMM_IMPLICIT)
#define AM65_ALL_IMM (AM65_IMM_ACCU | AM65_IMM_INDEX | AM65_IMM_IMPLICIT | AM65_IMM_IMPLICIT_WORD)
/* Bit numbers and count */
#define AM65I_IMM_ACCU 21
#define AM65I_IMM_INDEX 22
#define AM65I_IMM_IMPLICIT 23
#define AM65I_COUNT 27
#define AM65I_IMM_IMPLICIT_WORD 27
#define AM65I_COUNT 28

View File

@@ -368,6 +368,14 @@ void NewAsmLine (void)
/* Start a new line using the current line info */
AsmLineInfo = StartLine (&CurTok.Pos, LI_TYPE_ASM, 0);
/* If the first LineInfo in the list came from a .dbg line, then we want
** errors and warnings to show it as an additional note, not as the primary
** line. Therefore, swap the first two LineInfo items.
*/
if (GetLineInfoType (CollAtUnchecked (&CurLineInfo, 0)) == LI_TYPE_EXT) {
CollMove (&CurLineInfo, 1, 0);
}
}

View File

@@ -205,6 +205,10 @@ static void SetSys (const char* Sys)
AbEnd ("Cannot use `module' as a target for the assembler");
break;
case TGT_ATARI2600:
NewSymbol ("__ATARI2600__", 1);
break;
case TGT_ATARI5200:
NewSymbol ("__ATARI5200__", 1);
break;
@@ -226,6 +230,10 @@ static void SetSys (const char* Sys)
CBMSystem ("__C64__");
break;
case TGT_C65:
CBMSystem ("__C65__");
break;
case TGT_VIC20:
CBMSystem ("__VIC20__");
break;
@@ -623,7 +631,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the assembler version */
{
fprintf (stderr, "ca65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}

View File

@@ -618,16 +618,16 @@ static void DoCase (void)
static void DoCharMap (void)
/* Allow custome character mappings */
/* Allow custom character mappings */
{
long Index;
long Code;
/* Read the index as numerical value */
Index = ConstExpression ();
if (Index <= 0 || Index > 255) {
if (Index < 0 || Index > 255) {
/* Value out of range */
ErrorSkip ("Range error");
ErrorSkip ("Index range error");
return;
}
@@ -638,7 +638,7 @@ static void DoCharMap (void)
Code = ConstExpression ();
if (Code < 0 || Code > 255) {
/* Value out of range */
ErrorSkip ("Range error");
ErrorSkip ("Code range error");
return;
}
@@ -1530,6 +1530,14 @@ static void DoP816 (void)
static void DoP4510 (void)
/* Switch to 4510 CPU */
{
SetCPU (CPU_4510);
}
static void DoPageLength (void)
/* Set the page length for the listing */
{
@@ -2033,6 +2041,7 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccKeepToken, DoConditionals }, /* .IFNDEF */
{ ccKeepToken, DoConditionals }, /* .IFNREF */
{ ccKeepToken, DoConditionals }, /* .IFP02 */
{ ccKeepToken, DoConditionals }, /* .IFP4510 */
{ ccKeepToken, DoConditionals }, /* .IFP816 */
{ ccKeepToken, DoConditionals }, /* .IFPC02 */
{ ccKeepToken, DoConditionals }, /* .IFPSC02 */
@@ -2063,6 +2072,7 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccNone, DoOrg },
{ ccNone, DoOut },
{ ccNone, DoP02 },
{ ccNone, DoP4510 },
{ ccNone, DoP816 },
{ ccNone, DoPageLength },
{ ccNone, DoUnexpected }, /* .PARAMCOUNT */

View File

@@ -216,6 +216,7 @@ struct DotKeyword {
{ ".IFNDEF", TOK_IFNDEF },
{ ".IFNREF", TOK_IFNREF },
{ ".IFP02", TOK_IFP02 },
{ ".IFP4510", TOK_IFP4510 },
{ ".IFP816", TOK_IFP816 },
{ ".IFPC02", TOK_IFPC02 },
{ ".IFPSC02", TOK_IFPSC02 },
@@ -251,6 +252,7 @@ struct DotKeyword {
{ ".ORG", TOK_ORG },
{ ".OUT", TOK_OUT },
{ ".P02", TOK_P02 },
{ ".P4510", TOK_P4510 },
{ ".P816", TOK_P816 },
{ ".PAGELEN", TOK_PAGELENGTH },
{ ".PAGELENGTH", TOK_PAGELENGTH },
@@ -408,7 +410,7 @@ static void IFNextChar (CharSource* S)
/* If we come here, we have a new input line. To avoid problems
** with strange line terminators, remove all whitespace from the
** end of the line, the add a single newline.
** end of the line, then add a single newline.
*/
Len = SB_GetLen (&S->V.File.Line);
while (Len > 0 && IsSpace (SB_AtUnchecked (&S->V.File.Line, Len-1))) {
@@ -1109,60 +1111,76 @@ Again:
/* Check for special names. Bail out if we have identified the type of
** the token. Go on if the token is an identifier.
*/
if (SB_GetLen (&CurTok.SVal) == 1) {
switch (toupper (SB_AtUnchecked (&CurTok.SVal, 0))) {
switch (SB_GetLen (&CurTok.SVal)) {
case 1:
switch (toupper (SB_AtUnchecked (&CurTok.SVal, 0))) {
case 'A':
if (C == ':') {
NextChar ();
CurTok.Tok = TOK_OVERRIDE_ABS;
} else {
CurTok.Tok = TOK_A;
}
return;
case 'F':
if (C == ':') {
NextChar ();
CurTok.Tok = TOK_OVERRIDE_FAR;
case 'A':
if (C == ':') {
NextChar ();
CurTok.Tok = TOK_OVERRIDE_ABS;
} else {
CurTok.Tok = TOK_A;
}
return;
}
break;
case 'S':
if (CPU == CPU_65816) {
CurTok.Tok = TOK_S;
case 'F':
if (C == ':') {
NextChar ();
CurTok.Tok = TOK_OVERRIDE_FAR;
return;
}
break;
case 'S':
if ((CPU == CPU_4510) || (CPU == CPU_65816)) {
CurTok.Tok = TOK_S;
return;
}
break;
case 'X':
CurTok.Tok = TOK_X;
return;
}
break;
case 'X':
CurTok.Tok = TOK_X;
return;
case 'Y':
CurTok.Tok = TOK_Y;
return;
case 'Z':
if (C == ':') {
NextChar ();
CurTok.Tok = TOK_OVERRIDE_ZP;
case 'Y':
CurTok.Tok = TOK_Y;
return;
}
break;
default:
break;
}
case 'Z':
if (C == ':') {
NextChar ();
CurTok.Tok = TOK_OVERRIDE_ZP;
return;
} else {
if (CPU == CPU_4510) {
CurTok.Tok = TOK_Z;
return;
}
}
break;
} else if (CPU == CPU_SWEET16 &&
(CurTok.IVal = Sweet16Reg (&CurTok.SVal)) >= 0) {
default:
break;
}
break;
case 2:
if ((CPU == CPU_4510) &&
(toupper (SB_AtUnchecked (&CurTok.SVal, 0)) == 'S') &&
(toupper (SB_AtUnchecked (&CurTok.SVal, 1)) == 'P')) {
/* A sweet16 register number in sweet16 mode */
CurTok.Tok = TOK_REG;
return;
CurTok.Tok = TOK_S;
return;
}
/* FALL THROUGH */
default:
if (CPU == CPU_SWEET16 &&
(CurTok.IVal = Sweet16Reg (&CurTok.SVal)) >= 0) {
/* A sweet16 register number in sweet16 mode */
CurTok.Tok = TOK_REG;
return;
}
}
/* Check for define style macro */

View File

@@ -66,6 +66,7 @@ typedef enum token_t {
TOK_A, /* A)ccumulator */
TOK_X, /* X register */
TOK_Y, /* Y register */
TOK_Z, /* Z register */
TOK_S, /* S register */
TOK_REG, /* Sweet16 R.. register (in sweet16 mode) */
@@ -192,6 +193,7 @@ typedef enum token_t {
TOK_IFNDEF,
TOK_IFNREF,
TOK_IFP02,
TOK_IFP4510,
TOK_IFP816,
TOK_IFPC02,
TOK_IFPSC02,
@@ -222,6 +224,7 @@ typedef enum token_t {
TOK_ORG,
TOK_OUT,
TOK_P02,
TOK_P4510,
TOK_P816,
TOK_PAGELENGTH,
TOK_PARAMCOUNT,

View File

@@ -58,6 +58,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sim65", "sim65.vcxproj", "{
{71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chrcvt65", "chrcvt65.vcxproj", "{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}"
ProjectSection(ProjectDependencies) = postProject
{71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -112,6 +117,10 @@ Global
{002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.Build.0 = Debug|Win32
{002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.ActiveCfg = Release|Win32
{002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.Build.0 = Release|Win32
{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Debug|Win32.ActiveCfg = Debug|Win32
{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Debug|Win32.Build.0 = Debug|Win32
{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Release|Win32.ActiveCfg = Release|Win32
{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -41,12 +41,14 @@
/* cc65 */
#include "asmlabel.h"
#include "codegen.h"
#include "codeseg.h"
#include "datatype.h"
#include "error.h"
#include "expr.h"
#include "function.h"
#include "litpool.h"
#include "scanner.h"
#include "segments.h"
#include "stackptr.h"
#include "symtab.h"
#include "asmstmt.h"
@@ -422,6 +424,15 @@ void AsmStatement (void)
/* Skip the ASM */
NextToken ();
/* An optional volatile qualifier disables optimization for
** the entire function [same as #pragma optimize(push, off)].
*/
if (CurTok.Tok == TOK_VOLATILE) {
/* Don't optimize the Current code Segment */
CS->Code->Optimize = 0;
NextToken ();
}
/* Need left parenthesis */
if (!ConsumeLParen ()) {
return;

View File

@@ -55,6 +55,7 @@
#include "global.h"
#include "segments.h"
#include "stackptr.h"
#include "stdfunc.h"
#include "textseg.h"
#include "util.h"
#include "codegen.h"
@@ -4241,7 +4242,7 @@ void g_initauto (unsigned Label, unsigned Size)
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0));
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) Size);
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
AddCodeLine ("bne %s", LocalLabelName (CodeLabel));
}
}
@@ -4266,10 +4267,10 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size)
AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, InitLabel, 0));
AddCodeLine ("sta %s,y", GetLabelName (CF_STATIC, VarLabel, 0));
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) Size);
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
AddCodeLine ("bne %s", LocalLabelName (CodeLabel));
} else {
/* Use the easy way here: memcpy */
/* Use the easy way here: memcpy() */
g_getimmed (CF_STATIC, VarLabel, 0);
AddCodeLine ("jsr pushax");
g_getimmed (CF_STATIC, InitLabel, 0);

View File

@@ -911,6 +911,8 @@ void ListOptSteps (FILE* F)
/* List all optimization steps */
{
unsigned I;
fprintf (F, "any\n");
for (I = 0; I < OPTFUNC_COUNT; ++I) {
fprintf (F, "%s\n", OptFuncs[I]->Name);
}

View File

@@ -66,11 +66,12 @@ IntStack WarningsAreErrors = INTSTACK(0); /* Treat warnings as errors */
/* Warn about: */
IntStack WarnConstComparison= INTSTACK(1); /* - constant comparison results */
IntStack WarnNoEffect = INTSTACK(1); /* - statements without an effect */
IntStack WarnRemapZero = INTSTACK(1); /* - remapping character code zero */
IntStack WarnStructParam = INTSTACK(1); /* - structs passed by val */
IntStack WarnUnknownPragma = INTSTACK(1); /* - unknown #pragmas */
IntStack WarnUnusedLabel = INTSTACK(1); /* - unused labels */
IntStack WarnUnusedParam = INTSTACK(1); /* - unused parameters */
IntStack WarnUnusedVar = INTSTACK(1); /* - unused variables */
IntStack WarnUnknownPragma = INTSTACK(1); /* - unknown #pragmas */
/* Map the name of a warning to the intstack that holds its state */
typedef struct WarnMapEntry WarnMapEntry;
@@ -79,10 +80,11 @@ struct WarnMapEntry {
const char* Name;
};
static WarnMapEntry WarnMap[] = {
/* Keep sorted, even if this isn't used for now */
{ &WarningsAreErrors, "error" },
/* Keep names sorted, even if it isn't used for now */
{ &WarnConstComparison, "const-comparison" },
{ &WarningsAreErrors, "error" },
{ &WarnNoEffect, "no-effect" },
{ &WarnRemapZero, "remap-zero" },
{ &WarnStructParam, "struct-param" },
{ &WarnUnknownPragma, "unknown-pragma" },
{ &WarnUnusedLabel, "unused-label" },

View File

@@ -65,11 +65,12 @@ extern IntStack WarningsAreErrors; /* Treat warnings as errors */
/* Warn about: */
extern IntStack WarnConstComparison; /* - constant comparison results */
extern IntStack WarnNoEffect; /* - statements without an effect */
extern IntStack WarnRemapZero; /* - remapping character code zero */
extern IntStack WarnStructParam; /* - structs passed by val */
extern IntStack WarnUnknownPragma; /* - unknown #pragmas */
extern IntStack WarnUnusedLabel; /* - unused labels */
extern IntStack WarnUnusedParam; /* - unused parameters */
extern IntStack WarnUnusedVar; /* - unused variables */
extern IntStack WarnUnknownPragma; /* - unknown #pragmas */

View File

@@ -161,6 +161,10 @@ static void SetSys (const char* Sys)
AbEnd ("Cannot use `module' as a target for the compiler");
break;
case TGT_ATARI2600:
DefineNumericMacro ("__ATARI2600__", 1);
break;
case TGT_ATARI5200:
DefineNumericMacro ("__ATARI5200__", 1);
break;
@@ -746,7 +750,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the compiler version */
{
fprintf (stderr, "cc65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit (EXIT_SUCCESS);
}

View File

@@ -452,13 +452,8 @@ static void CharMapPragma (StrBuf* B)
if (!GetNumber (B, &Index)) {
return;
}
if (Index < 1 || Index > 255) {
if (Index == 0) {
/* For groepaz */
Error ("Remapping 0 is not allowed");
} else {
Error ("Character index out of range");
}
if (Index < 0 || Index > 255) {
Error ("Character index out of range");
return;
}
@@ -471,16 +466,23 @@ static void CharMapPragma (StrBuf* B)
if (!GetNumber (B, &C)) {
return;
}
if (C < 1 || C > 255) {
if (C == 0) {
/* For groepaz */
Error ("Remapping 0 is not allowed");
} else {
Error ("Character code out of range");
}
if (C < 0 || C > 255) {
Error ("Character code out of range");
return;
}
/* Warn about remapping character code 0x00
** (except when remapping it back to itself).
*/
if (Index + C != 0 && IS_Get (&WarnRemapZero)) {
if (Index == 0) {
Warning ("Remapping from 0 is dangerous with string functions");
}
else if (C == 0) {
Warning ("Remapping to 0 can make string functions stop unexpectedly");
}
}
/* Remap the character */
TgtTranslateSet ((unsigned) Index, (unsigned char) C);
}

View File

@@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
/* (C) 1998-2002, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */

View File

@@ -267,6 +267,7 @@ static int ParseChar (void)
{
int C;
int HadError;
int Count;
/* Check for escape chars */
if (CurC == '\\') {
@@ -336,19 +337,14 @@ static int ParseChar (void)
case '6':
case '7':
/* Octal constant */
HadError = 0;
Count = 1;
C = HexVal (CurC);
while (IsODigit (NextC)) {
if ((C << 3) >= 256) {
if (!HadError) {
Error ("Octal character constant out of range");
HadError = 1;
}
} else {
C = (C << 3) | HexVal (NextC);
}
while (IsODigit (NextC) && Count++ < 3) {
C = (C << 3) | HexVal (NextC);
NextChar ();
}
if (C >= 256)
Error ("Octal character constant out of range");
break;
default:
Error ("Illegal character constant");

View File

@@ -185,6 +185,19 @@ static void ParseArg (ArgDesc* Arg, Type* Type)
void AddCmpCodeIfSizeNot256 (const char* Code, long Size)
/* Add a line of Assembly code that compares an index register
** only if it isn't comparing to #<256. (If the next line
** is "bne", then this will avoid a redundant line.)
*/
{
if (Size != 256) {
AddCodeLine (Code, (unsigned int)Size);
}
}
/*****************************************************************************/
/* memcpy */
/*****************************************************************************/
@@ -272,7 +285,6 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
if (Arg3.Expr.IVal <= 127) {
AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
if (Reg2) {
AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
@@ -290,7 +302,6 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
} else {
AddCodeLine ("ldy #$00");
AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
if (Reg2) {
AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
@@ -303,7 +314,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
}
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
@@ -366,7 +377,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
} else {
AddCodeLine ("ldx #$00");
@@ -376,7 +387,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
AddCodeLine ("inx");
AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
@@ -440,7 +451,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
AddCodeLine ("lda (sp),y");
AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
} else {
AddCodeLine ("ldx #$00");
@@ -450,7 +461,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
AddCodeLine ("iny");
AddCodeLine ("inx");
AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
@@ -487,7 +498,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
AddCodeLine ("lda (sp),y");
AddCodeLine ("sta (ptr1),y");
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
@@ -631,7 +642,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
}
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
@@ -661,7 +672,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
g_defcodelabel (Label);
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
/* memset returns the address, so the result is actually identical
@@ -697,7 +708,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
g_defcodelabel (Label);
AddCodeLine ("sta (ptr1),y");
AddCodeLine ("iny");
AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}

View File

@@ -50,6 +50,12 @@
void AddCmpCodeIfSizeNot256 (const char* Code, long Size);
/* Add a line of Assembly code that compares an index register
** only if it isn't comparing to #<256. (If the next line
** is "bne", then this will avoid a redundant line.)
*/
int FindStdFunc (const char* Name);
/* Determine if the given function is a known standard function that may be
** called in a special way. If so, return the index, otherwise return -1.
@@ -61,5 +67,4 @@ void HandleStdFunc (int Index, struct FuncDesc* F, ExprDesc* lval);
/* End of stdfunc.h */
#endif

View File

@@ -144,13 +144,8 @@ void SwitchStatement (void)
/* Create a loop so we may use break. */
AddLoop (ExitLabel, 0);
/* Make sure a curly brace follows */
if (CurTok.Tok != TOK_LCURLY) {
Error ("`{' expected");
}
/* Parse the following statement, which will actually be a compound
** statement because of the curly brace at the current input position
/* Parse the following statement, which may actually be a compound
** statement if there is a curly brace at the current input position
*/
HaveBreak = Statement (&RCurlyBrace);
@@ -199,7 +194,7 @@ void SwitchStatement (void)
/* Free the case value tree */
FreeCaseNodeColl (SwitchData.Nodes);
/* If the case statement was (correctly) terminated by a closing curly
/* If the case statement was terminated by a closing curly
** brace, skip it now.
*/
if (RCurlyBrace) {

View File

@@ -237,7 +237,7 @@ void TypeConversion (ExprDesc* Expr, Type* NewType)
switch (TypeCmp (NewType, Expr->Type)) {
case TC_INCOMPATIBLE:
Error ("Incompatible pointer types");
Error ("Incompatible pointer types at '%s'", (Expr->Sym? Expr->Sym->Name : "Unknown"));
break;
case TC_QUAL_DIFF:

87
src/chrcvt65.vcxproj Normal file
View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1C7A3FEF-DD0B-4B10-BC33-C3BE29BF67CC}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>chrcvt65</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)..\bin\</OutDir>
<IntDir>$(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\bin\</OutDir>
<IntDir>$(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CONSOLE;_DEBUG</PreprocessorDefinitions>
<AdditionalIncludeDirectories>common</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(IntDir)..\..\common\$(Configuration)\common.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CONSOLE;NDEBUG</PreprocessorDefinitions>
<AdditionalIncludeDirectories>common</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>$(IntDir)..\..\common\$(Configuration)\common.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="chrcvt65\error.c" />
<ClCompile Include="chrcvt65\main.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="chrcvt65\error.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -2,7 +2,7 @@
/* */
/* error.c */
/* */
/* Error handling for the chrcvt vector font converter */
/* Error handling for the chrcvt65 vector font converter */
/* */
/* */
/* */

View File

@@ -2,7 +2,7 @@
/* */
/* error.h */
/* */
/* Error handling for the chrcvt vector font converter */
/* Error handling for the chrcvt65 vector font converter */
/* */
/* */
/* */

View File

@@ -2,7 +2,7 @@
/* */
/* main.c */
/* */
/* Main program of the chrcvt vector font converter */
/* Main program of the chrcvt65 vector font converter */
/* */
/* */
/* */
@@ -46,7 +46,7 @@
#include "xmalloc.h"
#include "version.h"
/* chrcvt */
/* chrcvt65 */
#include "error.h"
@@ -219,8 +219,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the assembler version */
{
fprintf (stderr,
"%s V%s - (C) Copyright 2009, Ullrich von Bassewitz\n",
ProgName, GetVersionAsString ());
"%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}
@@ -482,7 +482,7 @@ int main (int argc, char* argv [])
unsigned I;
/* Initialize the cmdline module */
InitCmdLine (&argc, &argv, "chrcvt");
InitCmdLine (&argc, &argv, "chrcvt65");
/* Check the parameters */
I = 1;

View File

@@ -73,6 +73,7 @@
#include "filetype.h"
#include "fname.h"
#include "mmodel.h"
#include "searchpath.h"
#include "strbuf.h"
#include "target.h"
#include "version.h"
@@ -759,6 +760,7 @@ static void Usage (void)
" --o65-model model\t\tOverride the o65 model\n"
" --obj file\t\t\tLink this object file\n"
" --obj-path path\t\tSpecify an object file search path\n"
" --print-target-path\t\tPrint the target file path\n"
" --register-space b\t\tSet space available for register variables\n"
" --register-vars\t\tEnable register variables\n"
" --rodata-name seg\t\tSet the name of the RODATA segment\n"
@@ -1126,6 +1128,23 @@ static void OptObjPath (const char* Opt attribute ((unused)), const char* Arg)
static void OptPrintTargetPath (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the target file path */
{
SearchPaths* TargetPath = NewSearchPath ();
AddSubSearchPathFromEnv (TargetPath, "CC65_HOME", "target");
#if defined(CL65_TGT) && !defined(_WIN32)
AddSearchPath (TargetPath, STRINGIZE (CL65_TGT));
#endif
AddSubSearchPathFromWinBin (TargetPath, "target");
printf ("%s\n", GetSearchPath (TargetPath, 0));
exit (EXIT_SUCCESS);
}
static void OptRegisterSpace (const char* Opt attribute ((unused)), const char* Arg)
/* Handle the --register-space option */
{
@@ -1214,7 +1233,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print version number */
{
fprintf (stderr, "cl65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}
@@ -1240,56 +1260,57 @@ int main (int argc, char* argv [])
{
/* Program long options */
static const LongOpt OptTab[] = {
{ "--add-source", 0, OptAddSource },
{ "--asm-args", 1, OptAsmArgs },
{ "--asm-define", 1, OptAsmDefine },
{ "--asm-include-dir", 1, OptAsmIncludeDir },
{ "--bin-include-dir", 1, OptBinIncludeDir },
{ "--bss-label", 1, OptBssLabel },
{ "--bss-name", 1, OptBssName },
{ "--cc-args", 1, OptCCArgs },
{ "--cfg-path", 1, OptCfgPath },
{ "--check-stack", 0, OptCheckStack },
{ "--code-label", 1, OptCodeLabel },
{ "--code-name", 1, OptCodeName },
{ "--codesize", 1, OptCodeSize },
{ "--config", 1, OptConfig },
{ "--cpu", 1, OptCPU },
{ "--create-dep", 1, OptCreateDep },
{ "--create-full-dep", 1, OptCreateFullDep },
{ "--data-label", 1, OptDataLabel },
{ "--data-name", 1, OptDataName },
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--feature", 1, OptFeature },
{ "--force-import", 1, OptForceImport },
{ "--help", 0, OptHelp },
{ "--include-dir", 1, OptIncludeDir },
{ "--ld-args", 1, OptLdArgs },
{ "--lib", 1, OptLib },
{ "--lib-path", 1, OptLibPath },
{ "--list-targets", 0, OptListTargets },
{ "--listing", 1, OptListing },
{ "--list-bytes", 1, OptListBytes },
{ "--mapfile", 1, OptMapFile },
{ "--memory-model", 1, OptMemoryModel },
{ "--module", 0, OptModule },
{ "--module-id", 1, OptModuleId },
{ "--o65-model", 1, OptO65Model },
{ "--obj", 1, OptObj },
{ "--obj-path", 1, OptObjPath },
{ "--register-space", 1, OptRegisterSpace },
{ "--register-vars", 0, OptRegisterVars },
{ "--rodata-name", 1, OptRodataName },
{ "--signed-chars", 0, OptSignedChars },
{ "--standard", 1, OptStandard },
{ "--start-addr", 1, OptStartAddr },
{ "--static-locals", 0, OptStaticLocals },
{ "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
{ "--zeropage-label", 1, OptZeropageLabel },
{ "--zeropage-name", 1, OptZeropageName },
{ "--add-source", 0, OptAddSource },
{ "--asm-args", 1, OptAsmArgs },
{ "--asm-define", 1, OptAsmDefine },
{ "--asm-include-dir", 1, OptAsmIncludeDir },
{ "--bin-include-dir", 1, OptBinIncludeDir },
{ "--bss-label", 1, OptBssLabel },
{ "--bss-name", 1, OptBssName },
{ "--cc-args", 1, OptCCArgs },
{ "--cfg-path", 1, OptCfgPath },
{ "--check-stack", 0, OptCheckStack },
{ "--code-label", 1, OptCodeLabel },
{ "--code-name", 1, OptCodeName },
{ "--codesize", 1, OptCodeSize },
{ "--config", 1, OptConfig },
{ "--cpu", 1, OptCPU },
{ "--create-dep", 1, OptCreateDep },
{ "--create-full-dep", 1, OptCreateFullDep },
{ "--data-label", 1, OptDataLabel },
{ "--data-name", 1, OptDataName },
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--feature", 1, OptFeature },
{ "--force-import", 1, OptForceImport },
{ "--help", 0, OptHelp },
{ "--include-dir", 1, OptIncludeDir },
{ "--ld-args", 1, OptLdArgs },
{ "--lib", 1, OptLib },
{ "--lib-path", 1, OptLibPath },
{ "--list-targets", 0, OptListTargets },
{ "--listing", 1, OptListing },
{ "--list-bytes", 1, OptListBytes },
{ "--mapfile", 1, OptMapFile },
{ "--memory-model", 1, OptMemoryModel },
{ "--module", 0, OptModule },
{ "--module-id", 1, OptModuleId },
{ "--o65-model", 1, OptO65Model },
{ "--obj", 1, OptObj },
{ "--obj-path", 1, OptObjPath },
{ "--print-target-path", 0, OptPrintTargetPath},
{ "--register-space", 1, OptRegisterSpace },
{ "--register-vars", 0, OptRegisterVars },
{ "--rodata-name", 1, OptRodataName },
{ "--signed-chars", 0, OptSignedChars },
{ "--standard", 1, OptStandard },
{ "--start-addr", 1, OptStartAddr },
{ "--static-locals", 0, OptStaticLocals },
{ "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
{ "--zeropage-label", 1, OptZeropageLabel },
{ "--zeropage-name", 1, OptZeropageName },
};
char* CmdPath;

View File

@@ -263,7 +263,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the assembler version */
{
fprintf (stderr, "co65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}

View File

@@ -161,7 +161,7 @@ void CollAppend (Collection* C, void* Item)
{
/* Insert the item at the end of the current list */
CollInsert (C, Item, C->Count);
}
}
#endif
@@ -341,22 +341,23 @@ void CollReplaceExpand (Collection* C, void* Item, unsigned Index)
void CollMove (Collection* C, unsigned OldIndex, unsigned NewIndex)
/* Move an item from one position in the collection to another. OldIndex
** is the current position of the item, NewIndex is the new index after
** is the current position of the item, NewIndex is the new index before
** the function has done it's work. Existing entries with indices NewIndex
** and up are moved one position upwards.
** and up might be moved one position upwards.
*/
{
/* Get the item and remove it from the collection */
/* Get the item; and, remove it from the collection */
void* Item = CollAt (C, OldIndex);
CollDelete (C, OldIndex);
/* Correct NewIndex if needed */
if (NewIndex >= OldIndex) {
if (NewIndex > OldIndex) {
/* Position has changed with removal */
--NewIndex;
}
/* Now insert it at the new position */
/* Now, insert it at the new position */
CollInsert (C, Item, NewIndex);
}

View File

@@ -268,9 +268,9 @@ void CollReplaceExpand (Collection* C, void* Item, unsigned Index);
void CollMove (Collection* C, unsigned OldIndex, unsigned NewIndex);
/* Move an item from one position in the collection to another. OldIndex
** is the current position of the item, NewIndex is the new index after
** is the current position of the item, NewIndex is the new index before
** the function has done it's work. Existing entries with indices NewIndex
** and up are moved one position upwards.
** and up might be moved one position upwards.
*/
void CollMoveMultiple (Collection* C, unsigned Start, unsigned Count, unsigned Target);

View File

@@ -61,6 +61,7 @@ const char* CPUNames[CPU_COUNT] = {
"sweet16",
"huc6280",
"m740",
"4510",
};
/* Tables with CPU instruction sets */
@@ -74,6 +75,7 @@ const unsigned CPUIsets[CPU_COUNT] = {
CPU_ISET_SWEET16,
CPU_ISET_6502 | CPU_ISET_65SC02 | CPU_ISET_65C02 | CPU_ISET_HUC6280,
CPU_ISET_6502 | CPU_ISET_M740,
CPU_ISET_6502 | CPU_ISET_65SC02 | CPU_ISET_65C02 | CPU_ISET_4510,
};

View File

@@ -56,6 +56,7 @@ typedef enum {
CPU_SWEET16,
CPU_HUC6280, /* Used in PC engine */
CPU_M740, /* Mitsubishi 740 series MCUs */
CPU_4510, /* CPU of C65 */
CPU_COUNT /* Number of different CPUs */
} cpu_t;
@@ -70,6 +71,7 @@ enum {
CPU_ISET_SWEET16 = 1 << CPU_SWEET16,
CPU_ISET_HUC6280 = 1 << CPU_HUC6280,
CPU_ISET_M740 = 1 << CPU_M740,
CPU_ISET_4510 = 1 << CPU_4510,
};
/* CPU used */

View File

@@ -238,6 +238,18 @@ void PopSearchPath (SearchPaths* P)
char* GetSearchPath (SearchPaths* P, unsigned Index)
/* Return the search path at the given index, if the index is valid, return an
** empty string otherwise.
*/
{
if (Index < CollCount (P))
return CollAtUnchecked (P, Index);
return "";
}
char* SearchFile (const SearchPaths* P, const char* File)
/* Search for a file in a list of directories. Return a pointer to a malloced
** area that contains the complete path, if found, return 0 otherwise.

View File

@@ -94,6 +94,11 @@ int PushSearchPath (SearchPaths* P, const char* NewPath);
void PopSearchPath (SearchPaths* P);
/* Remove a search path from the head of an existing search path list */
char* GetSearchPath (SearchPaths* P, unsigned Index);
/* Return the search path at the given index, if the index is valid, return an
** empty string otherwise.
*/
char* SearchFile (const SearchPaths* P, const char* File);
/* Search for a file in a list of directories. Return a pointer to a malloced
** area that contains the complete path, if found, return 0 otherwise.

View File

@@ -139,12 +139,13 @@ struct TargetEntry {
};
/* Table that maps target names to ids. Sorted alphabetically for bsearch.
** Allows mupltiple entries for one target id (target name aliases).
** Allows multiple entries for one target id (target name aliases).
*/
static const TargetEntry TargetMap[] = {
{ "apple2", TGT_APPLE2 },
{ "apple2enh", TGT_APPLE2ENH },
{ "atari", TGT_ATARI },
{ "atari2600", TGT_ATARI2600 },
{ "atari5200", TGT_ATARI5200 },
{ "atarixl", TGT_ATARIXL },
{ "atmos", TGT_ATMOS },
@@ -152,6 +153,7 @@ static const TargetEntry TargetMap[] = {
{ "c128", TGT_C128 },
{ "c16", TGT_C16 },
{ "c64", TGT_C64 },
{ "c65", TGT_C65 },
{ "cbm510", TGT_CBM510 },
{ "cbm610", TGT_CBM610 },
{ "creativision", TGT_CREATIVISION},
@@ -171,7 +173,6 @@ static const TargetEntry TargetMap[] = {
{ "sim6502", TGT_SIM6502 },
{ "sim65c02", TGT_SIM65C02 },
{ "supervision", TGT_SUPERVISION },
{ "vc20", TGT_VIC20 },
{ "vic20", TGT_VIC20 },
};
#define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0]))
@@ -182,6 +183,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = {
{ "none", CPU_6502, BINFMT_BINARY, CTNone },
{ "module", CPU_6502, BINFMT_O65, CTNone },
{ "atari", CPU_6502, BINFMT_BINARY, CTAtari },
{ "atari2600", CPU_6502, BINFMT_BINARY, CTNone },
{ "atari5200", CPU_6502, BINFMT_BINARY, CTAtari },
{ "atarixl", CPU_6502, BINFMT_BINARY, CTAtari },
{ "vic20", CPU_6502, BINFMT_BINARY, CTPET },
@@ -201,13 +203,16 @@ static const TargetProperties PropertyTable[TGT_COUNT] = {
{ "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone },
{ "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone },
{ "lunix", CPU_6502, BINFMT_O65, CTNone },
{ "lynx", CPU_65C02, BINFMT_BINARY, CTNone },
{ "atmos", CPU_6502, BINFMT_BINARY, CTNone },
{ "nes", CPU_6502, BINFMT_BINARY, CTNone },
{ "supervision", CPU_65SC02, BINFMT_BINARY, CTNone },
{ "lynx", CPU_65SC02, BINFMT_BINARY, CTNone },
{ "sim6502", CPU_6502, BINFMT_BINARY, CTNone },
{ "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone },
{ "pce", CPU_HUC6280, BINFMT_BINARY, CTNone },
{ "gamate", CPU_6502, BINFMT_BINARY, CTNone },
{ "supervision", CPU_65SC02, BINFMT_BINARY, CTNone },
{ "c65", CPU_4510, BINFMT_BINARY, CTPET },
};
/* Target system */

View File

@@ -55,6 +55,7 @@ typedef enum {
TGT_NONE,
TGT_MODULE,
TGT_ATARI,
TGT_ATARI2600,
TGT_ATARI5200,
TGT_ATARIXL,
TGT_VIC20,
@@ -81,6 +82,7 @@ typedef enum {
TGT_PCENGINE,
TGT_GAMATE,
TGT_SUPERVISION,
TGT_C65,
TGT_COUNT /* Number of target systems */
} target_t;

View File

@@ -124,6 +124,6 @@ void TgtTranslateStrBuf (StrBuf* Buf)
void TgtTranslateSet (unsigned Index, unsigned char C)
/* Set the translation code for the given character */
{
CHECK (Index > 0 && Index < sizeof (Tab));
CHECK (Index < sizeof (Tab));
Tab[Index] = C;
}

View File

@@ -86,6 +86,7 @@
<ClCompile Include="da65\infofile.c" />
<ClCompile Include="da65\labels.c" />
<ClCompile Include="da65\main.c" />
<ClCompile Include="da65\opc4510.c" />
<ClCompile Include="da65\opc6502.c" />
<ClCompile Include="da65\opc6502x.c" />
<ClCompile Include="da65\opc65816.c" />
@@ -109,6 +110,7 @@
<ClInclude Include="da65\handler.h" />
<ClInclude Include="da65\infofile.h" />
<ClInclude Include="da65\labels.h" />
<ClInclude Include="da65\opc4510.h" />
<ClInclude Include="da65\opc6502.h" />
<ClInclude Include="da65\opc6502x.h" />
<ClInclude Include="da65\opc65816.h" />

View File

@@ -36,6 +36,7 @@
#include <stdarg.h>
/* common */
#include "xmalloc.h"
#include "xsprintf.h"
/* da65 */
@@ -226,6 +227,13 @@ void OH_Immediate (const OpcDesc* D)
void OH_ImmediateWord (const OpcDesc* D)
{
OneLine (D, "#$%04X", GetCodeWord (PC+1));
}
void OH_Direct (const OpcDesc* D)
{
/* Get the operand */
@@ -348,6 +356,23 @@ void OH_RelativeLong (const OpcDesc* D attribute ((unused)))
void OH_RelativeLong4510 (const OpcDesc* D attribute ((unused)))
{
/* Get the operand */
signed short Offs = GetCodeWord (PC+1);
/* Calculate the target address */
unsigned Addr = (((int) PC+2) + Offs) & 0xFFFF;
/* Generate a label in pass 1 */
GenerateLabel (D->Flags, Addr);
/* Output the line */
OneLine (D, "%s", GetAddrArg (D->Flags, Addr));
}
void OH_DirectIndirect (const OpcDesc* D)
{
/* Get the operand */
@@ -376,6 +401,20 @@ void OH_DirectIndirectY (const OpcDesc* D)
void OH_DirectIndirectZ (const OpcDesc* D)
{
/* Get the operand */
unsigned Addr = GetCodeByte (PC+1);
/* Generate a label in pass 1 */
GenerateLabel (D->Flags, Addr);
/* Output the line */
OneLine (D, "(%s),z", GetAddrArg (D->Flags, Addr));
}
void OH_DirectXIndirect (const OpcDesc* D)
{
/* Get the operand */
@@ -406,6 +445,8 @@ void OH_AbsoluteIndirect (const OpcDesc* D)
void OH_BitBranch (const OpcDesc* D)
{
char* BranchLabel;
/* Get the operands */
unsigned char TestAddr = GetCodeByte (PC+1);
signed char BranchOffs = GetCodeByte (PC+2);
@@ -421,8 +462,16 @@ void OH_BitBranch (const OpcDesc* D)
GenerateLabel (D->Flags, TestAddr);
GenerateLabel (flLabel, BranchAddr);
/* Make a copy of an operand, so that
** the other operand can't overwrite it.
** [GetAddrArg() uses a statically-stored buffer.]
*/
BranchLabel = xstrdup (GetAddrArg (flLabel, BranchAddr));
/* Output the line */
OneLine (D, "%s,%s", GetAddrArg (D->Flags, TestAddr), GetAddrArg (flLabel, BranchAddr));
OneLine (D, "%s,%s", GetAddrArg (D->Flags, TestAddr), BranchLabel);
xfree (BranchLabel);
}
@@ -499,7 +548,16 @@ void OH_DirectIndirectLongX (const OpcDesc* D attribute ((unused)))
void OH_StackRelativeIndirectY (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
/* Output the line */
OneLine (D, "($%02X,s),y", GetCodeByte (PC+1));
}
void OH_StackRelativeIndirectY4510 (const OpcDesc* D attribute ((unused)))
{
/* Output the line */
OneLine (D, "($%02X,sp),y", GetCodeByte (PC+1));
}
@@ -518,8 +576,10 @@ void OH_DirectIndirectLongY (const OpcDesc* D attribute ((unused)))
void OH_BlockMove (const OpcDesc* D attribute ((unused)))
void OH_BlockMove (const OpcDesc* D)
{
char* DstLabel;
/* Get source operand */
unsigned Src = GetCodeWord (PC+1);
/* Get destination operand */
@@ -529,11 +589,19 @@ void OH_BlockMove (const OpcDesc* D attribute ((unused)))
GenerateLabel (D->Flags, Src);
GenerateLabel (D->Flags, Dst);
/* Make a copy of an operand, so that
** the other operand can't overwrite it.
** [GetAddrArg() uses a statically-stored buffer.]
*/
DstLabel = xstrdup (GetAddrArg (D->Flags, Dst));
/* Output the line */
OneLine (D, "%s%s,%s%s,#$%02X",
OneLine (D, "%s%s,%s%s,$%04X",
GetAbsOverride (D->Flags, Src), GetAddrArg (D->Flags, Src),
GetAbsOverride (D->Flags, Dst), GetAddrArg (D->Flags, Dst),
GetAbsOverride (D->Flags, Dst), DstLabel,
GetCodeWord (PC+5));
xfree (DstLabel);
}
@@ -662,3 +730,14 @@ void OH_JmpAbsoluteIndirect (const OpcDesc* D)
}
SeparatorLine ();
}
void OH_JmpAbsoluteXIndirect (const OpcDesc* D)
{
OH_AbsoluteXIndirect (D);
if (NewlineAfterJMP) {
LineFeed ();
}
SeparatorLine ();
}

View File

@@ -57,6 +57,7 @@ void OH_Illegal (const OpcDesc* D attribute ((unused)));
void OH_Accumulator (const OpcDesc*);
void OH_Implicit (const OpcDesc*);
void OH_Immediate (const OpcDesc*);
void OH_ImmediateWord (const OpcDesc*);
void OH_Direct (const OpcDesc*);
void OH_DirectX (const OpcDesc*);
void OH_DirectY (const OpcDesc*);
@@ -67,8 +68,10 @@ void OH_AbsoluteLong (const OpcDesc*);
void OH_AbsoluteLongX (const OpcDesc*);
void OH_Relative (const OpcDesc*);
void OH_RelativeLong (const OpcDesc*);
void OH_RelativeLong4510 (const OpcDesc*);
void OH_DirectIndirect (const OpcDesc*);
void OH_DirectIndirectY (const OpcDesc*);
void OH_DirectIndirectZ (const OpcDesc*);
void OH_DirectXIndirect (const OpcDesc*);
void OH_AbsoluteIndirect (const OpcDesc*);
@@ -82,6 +85,7 @@ void OH_ImmediateAbsoluteX (const OpcDesc*);
void OH_StackRelative (const OpcDesc*);
void OH_DirectIndirectLongX (const OpcDesc*);
void OH_StackRelativeIndirectY (const OpcDesc*);
void OH_StackRelativeIndirectY4510 (const OpcDesc*);
void OH_DirectIndirectLong (const OpcDesc*);
void OH_DirectIndirectLongY (const OpcDesc*);
void OH_BlockMove (const OpcDesc*);
@@ -94,11 +98,12 @@ void OH_AccumulatorBit (const OpcDesc*);
void OH_AccumulatorBitBranch (const OpcDesc*);
void OH_JmpDirectIndirect (const OpcDesc* D);
void OH_SpecialPage (const OpcDesc*);
/* Handlers for special instructions */
void OH_Rts (const OpcDesc*);
void OH_JmpAbsolute (const OpcDesc*);
void OH_JmpAbsoluteIndirect (const OpcDesc* D);
void OH_JmpAbsoluteXIndirect (const OpcDesc* D);

View File

@@ -340,7 +340,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the disassembler version */
{
fprintf (stderr, "da65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}

306
src/da65/opc4510.c Normal file
View File

@@ -0,0 +1,306 @@
/*****************************************************************************/
/* */
/* opc4510.c */
/* */
/* 4510 opcode description table */
/* */
/* */
/* */
/* (C) 2003-2011, 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. */
/* */
/*****************************************************************************/
/* da65 */
#include "handler.h"
#include "opc4510.h"
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Descriptions for all opcodes */
const OpcDesc OpcTable_4510[256] = {
{ "brk", 1, flNone, OH_Implicit }, /* $00 */
{ "ora", 2, flUseLabel, OH_DirectXIndirect }, /* $01 */
{ "cle", 1, flNone, OH_Implicit }, /* $02 */
{ "see", 1, flNone, OH_Implicit }, /* $03 */
{ "tsb", 2, flUseLabel, OH_Direct }, /* $04 */
{ "ora", 2, flUseLabel, OH_Direct }, /* $05 */
{ "asl", 2, flUseLabel, OH_Direct }, /* $06 */
{ "rmb0", 2, flUseLabel, OH_Direct }, /* $07 */
{ "php", 1, flNone, OH_Implicit }, /* $08 */
{ "ora", 2, flNone, OH_Immediate }, /* $09 */
{ "asl", 1, flNone, OH_Accumulator }, /* $0a */
{ "tsy", 1, flNone, OH_Implicit }, /* $0b */
{ "tsb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0c */
{ "ora", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0d */
{ "asl", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $0e */
{ "bbr0", 3, flUseLabel, OH_BitBranch }, /* $0f */
{ "bpl", 2, flLabel, OH_Relative }, /* $10 */
{ "ora", 2, flUseLabel, OH_DirectIndirectY }, /* $11 */
{ "ora", 2, flUseLabel, OH_DirectIndirectZ }, /* $12 */
{ "lbpl", 3, flLabel, OH_RelativeLong4510 }, /* $13 */
{ "trb", 2, flUseLabel, OH_Direct }, /* $14 */
{ "ora", 2, flUseLabel, OH_DirectX }, /* $15 */
{ "asl", 2, flUseLabel, OH_DirectX }, /* $16 */
{ "rmb1", 2, flUseLabel, OH_Direct }, /* $17 */
{ "clc", 1, flNone, OH_Implicit }, /* $18 */
{ "ora", 3, flUseLabel, OH_AbsoluteY }, /* $19 */
{ "inc", 1, flNone, OH_Accumulator }, /* $1a */
{ "inz", 1, flNone, OH_Implicit }, /* $1b */
{ "trb", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $1c */
{ "ora", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1d */
{ "asl", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $1e */
{ "bbr1", 3, flUseLabel, OH_BitBranch }, /* $1f */
{ "jsr", 3, flLabel, OH_Absolute }, /* $20 */
{ "and", 2, flUseLabel, OH_DirectXIndirect }, /* $21 */
{ "jsr", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $22 */
{ "jsr", 3, flLabel, OH_JmpAbsoluteXIndirect }, /* $23 */
{ "bit", 2, flUseLabel, OH_Direct }, /* $24 */
{ "and", 2, flUseLabel, OH_Direct }, /* $25 */
{ "rol", 2, flUseLabel, OH_Direct }, /* $26 */
{ "rmb2", 2, flUseLabel, OH_Direct }, /* $27 */
{ "plp", 1, flNone, OH_Implicit }, /* $28 */
{ "and", 2, flNone, OH_Immediate }, /* $29 */
{ "rol", 1, flNone, OH_Accumulator }, /* $2a */
{ "tys", 1, flNone, OH_Implicit }, /* $2b */
{ "bit", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2c */
{ "and", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2d */
{ "rol", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $2e */
{ "bbr2", 3, flUseLabel, OH_BitBranch }, /* $2f */
{ "bmi", 2, flLabel, OH_Relative }, /* $30 */
{ "and", 2, flUseLabel, OH_DirectIndirectY }, /* $31 */
{ "and", 2, flUseLabel, OH_DirectIndirectZ }, /* $32 */
{ "lbmi", 3, flLabel, OH_RelativeLong4510 }, /* $33 */
{ "bit", 2, flUseLabel, OH_DirectX }, /* $34 */
{ "and", 2, flUseLabel, OH_DirectX }, /* $35 */
{ "rol", 2, flUseLabel, OH_DirectX }, /* $36 */
{ "rmb3", 2, flUseLabel, OH_Direct }, /* $37 */
{ "sec", 1, flNone, OH_Implicit }, /* $38 */
{ "and", 3, flUseLabel, OH_AbsoluteY }, /* $39 */
{ "dec", 1, flNone, OH_Accumulator }, /* $3a */
{ "dez", 1, flNone, OH_Implicit }, /* $3b */
{ "bit", 3, flUseLabel, OH_AbsoluteX }, /* $3c */
{ "and", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3d */
{ "rol", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $3e */
{ "bbr3", 3, flUseLabel, OH_BitBranch }, /* $3f */
{ "rti", 1, flNone, OH_Rts }, /* $40 */
{ "eor", 2, flUseLabel, OH_DirectXIndirect }, /* $41 */
{ "neg", 1, flNone, OH_Implicit }, /* $42 */
{ "asr", 1, flNone, OH_Accumulator }, /* $43 */
{ "asr", 2, flUseLabel, OH_Direct }, /* $44 */
{ "eor", 2, flUseLabel, OH_Direct }, /* $45 */
{ "lsr", 2, flUseLabel, OH_Direct }, /* $46 */
{ "rmb4", 2, flUseLabel, OH_Direct }, /* $47 */
{ "pha", 1, flNone, OH_Implicit }, /* $48 */
{ "eor", 2, flNone, OH_Immediate }, /* $49 */
{ "lsr", 1, flNone, OH_Accumulator }, /* $4a */
{ "taz", 1, flNone, OH_Implicit }, /* $4b */
{ "jmp", 3, flLabel, OH_JmpAbsolute }, /* $4c */
{ "eor", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4d */
{ "lsr", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $4e */
{ "bbr4", 3, flUseLabel, OH_BitBranch }, /* $4f */
{ "bvc", 2, flLabel, OH_Relative }, /* $50 */
{ "eor", 2, flUseLabel, OH_DirectIndirectY }, /* $51 */
{ "eor", 2, flUseLabel, OH_DirectIndirectZ }, /* $52 */
{ "lbvc", 3, flLabel, OH_RelativeLong4510 }, /* $53 */
{ "asr", 2, flUseLabel, OH_DirectX }, /* $54 */
{ "eor", 2, flUseLabel, OH_DirectX }, /* $55 */
{ "lsr", 2, flUseLabel, OH_DirectX }, /* $56 */
{ "rmb5", 2, flUseLabel, OH_Direct }, /* $57 */
{ "cli", 1, flNone, OH_Implicit }, /* $58 */
{ "eor", 3, flUseLabel, OH_AbsoluteY }, /* $59 */
{ "phy", 1, flNone, OH_Implicit }, /* $5a */
{ "tab", 1, flNone, OH_Implicit }, /* $5b */
{ "map", 1, flNone, OH_Implicit }, /* $5c */
{ "eor", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5d */
{ "lsr", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $5e */
{ "bbr5", 3, flUseLabel, OH_BitBranch }, /* $5f */
{ "rts", 1, flNone, OH_Rts }, /* $60 */
{ "adc", 2, flUseLabel, OH_DirectXIndirect }, /* $61 */
{ "rtn", 2, flNone, OH_Immediate }, /* $62 */
{ "bsr", 3, flLabel, OH_RelativeLong4510 }, /* $63 */
{ "stz", 2, flUseLabel, OH_Direct }, /* $64 */
{ "adc", 2, flUseLabel, OH_Direct }, /* $65 */
{ "ror", 2, flUseLabel, OH_Direct }, /* $66 */
{ "rmb6", 2, flUseLabel, OH_Direct, }, /* $67 */
{ "pla", 1, flNone, OH_Implicit }, /* $68 */
{ "adc", 2, flNone, OH_Immediate }, /* $69 */
{ "ror", 1, flNone, OH_Accumulator }, /* $6a */
{ "tza", 1, flNone, OH_Implicit }, /* $6b */
{ "jmp", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $6c */
{ "adc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $6d */
{ "ror", 3, flUseLabel, OH_Absolute }, /* $6e */
{ "bbr6", 3, flUseLabel, OH_BitBranch }, /* $6f */
{ "bvs", 2, flLabel, OH_Relative }, /* $70 */
{ "adc", 2, flUseLabel, OH_DirectIndirectY }, /* $71 */
{ "adc", 2, flUseLabel, OH_DirectIndirectZ }, /* $72 */
{ "lbvs", 3, flLabel, OH_RelativeLong4510 }, /* $73 */
{ "stz", 2, flUseLabel, OH_DirectX }, /* $74 */
{ "adc", 2, flUseLabel, OH_DirectX }, /* $75 */
{ "ror", 2, flUseLabel, OH_DirectX }, /* $76 */
{ "rmb7", 2, flUseLabel, OH_Direct }, /* $77 */
{ "sei", 1, flNone, OH_Implicit }, /* $78 */
{ "adc", 3, flUseLabel, OH_AbsoluteY }, /* $79 */
{ "ply", 1, flNone, OH_Implicit }, /* $7a */
{ "tba", 1, flNone, OH_Implicit }, /* $7b */
{ "jmp", 3, flLabel, OH_AbsoluteXIndirect }, /* $7c */
{ "adc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7d */
{ "ror", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7e */
{ "bbr7", 3, flUseLabel, OH_BitBranch }, /* $7f */
{ "bra", 2, flLabel, OH_Relative }, /* $80 */
{ "sta", 2, flUseLabel, OH_DirectXIndirect }, /* $81 */
{ "sta", 2, flNone, OH_StackRelativeIndirectY4510}, /* $82 */
{ "lbra", 3, flLabel, OH_RelativeLong4510 }, /* $83 */
{ "sty", 2, flUseLabel, OH_Direct }, /* $84 */
{ "sta", 2, flUseLabel, OH_Direct }, /* $85 */
{ "stx", 2, flUseLabel, OH_Direct }, /* $86 */
{ "smb0", 2, flUseLabel, OH_Direct }, /* $87 */
{ "dey", 1, flNone, OH_Implicit }, /* $88 */
{ "bit", 2, flNone, OH_Immediate }, /* $89 */
{ "txa", 1, flNone, OH_Implicit }, /* $8a */
{ "sty", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $8b */
{ "sty", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8c */
{ "sta", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8d */
{ "stx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $8e */
{ "bbs0", 3, flUseLabel, OH_BitBranch }, /* $8f */
{ "bcc", 2, flLabel, OH_Relative }, /* $90 */
{ "sta", 2, flUseLabel, OH_DirectIndirectY }, /* $91 */
{ "sta", 2, flUseLabel, OH_DirectIndirectZ }, /* $92 */
{ "lbcc", 3, flLabel, OH_RelativeLong4510 }, /* $93 */
{ "sty", 2, flUseLabel, OH_DirectX }, /* $94 */
{ "sta", 2, flUseLabel, OH_DirectX }, /* $95 */
{ "stx", 2, flUseLabel, OH_DirectY }, /* $96 */
{ "smb1", 2, flUseLabel, OH_Direct }, /* $97 */
{ "tya", 1, flNone, OH_Implicit }, /* $98 */
{ "sta", 3, flUseLabel, OH_AbsoluteY }, /* $99 */
{ "txs", 1, flNone, OH_Implicit }, /* $9a */
{ "stx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $9b */
{ "stz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $9c */
{ "sta", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9d */
{ "stz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $9e */
{ "bbs1", 3, flUseLabel, OH_BitBranch }, /* $9f */
{ "ldy", 2, flNone, OH_Immediate }, /* $a0 */
{ "lda", 2, flUseLabel, OH_DirectXIndirect }, /* $a1 */
{ "ldx", 2, flNone, OH_Immediate }, /* $a2 */
{ "ldz", 2, flNone, OH_Immediate }, /* $a3 */
{ "ldy", 2, flUseLabel, OH_Direct }, /* $a4 */
{ "lda", 2, flUseLabel, OH_Direct }, /* $a5 */
{ "ldx", 2, flUseLabel, OH_Direct }, /* $a6 */
{ "smb2", 2, flUseLabel, OH_Direct }, /* $a7 */
{ "tay", 1, flNone, OH_Implicit }, /* $a8 */
{ "lda", 2, flNone, OH_Immediate }, /* $a9 */
{ "tax", 1, flNone, OH_Implicit }, /* $aa */
{ "ldz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ab */
{ "ldy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ac */
{ "lda", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ad */
{ "ldx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ae */
{ "bbs2", 3, flUseLabel, OH_BitBranch }, /* $af */
{ "bcs", 2, flLabel, OH_Relative }, /* $b0 */
{ "lda", 2, flUseLabel, OH_DirectIndirectY }, /* $b1 */
{ "lda", 2, flUseLabel, OH_DirectIndirectZ }, /* $b2 */
{ "lbcs", 3, flLabel, OH_RelativeLong4510 }, /* $b3 */
{ "ldy", 2, flUseLabel, OH_DirectX }, /* $b4 */
{ "lda", 2, flUseLabel, OH_DirectX }, /* $b5 */
{ "ldx", 2, flUseLabel, OH_DirectY }, /* $b6 */
{ "smb3", 2, flUseLabel, OH_Direct }, /* $b7 */
{ "clv", 1, flNone, OH_Implicit }, /* $b8 */
{ "lda", 3, flUseLabel, OH_AbsoluteY }, /* $b9 */
{ "tsx", 1, flNone, OH_Implicit }, /* $ba */
{ "ldz", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bb */
{ "ldy", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bc */
{ "lda", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $bd */
{ "ldx", 3, flUseLabel|flAbsOverride, OH_AbsoluteY }, /* $be */
{ "bbs3", 3, flUseLabel, OH_BitBranch }, /* $bf */
{ "cpy", 2, flNone, OH_Immediate }, /* $c0 */
{ "cmp", 2, flUseLabel, OH_DirectXIndirect }, /* $c1 */
{ "cpz", 2, flNone, OH_Immediate }, /* $c2 */
{ "dew", 2, flUseLabel, OH_Direct }, /* $c3 */
{ "cpy", 2, flUseLabel, OH_Direct }, /* $c4 */
{ "cmp", 2, flUseLabel, OH_Direct }, /* $c5 */
{ "dec", 2, flUseLabel, OH_Direct }, /* $c6 */
{ "smb4", 2, flUseLabel, OH_Direct }, /* $c7 */
{ "iny", 1, flNone, OH_Implicit }, /* $c8 */
{ "cmp", 2, flNone, OH_Immediate }, /* $c9 */
{ "dex", 1, flNone, OH_Implicit }, /* $ca */
{ "asw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cb */
{ "cpy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cc */
{ "cmp", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cd */
{ "dec", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ce */
{ "bbs4", 3, flUseLabel, OH_BitBranch }, /* $cf */
{ "bne", 2, flLabel, OH_Relative }, /* $d0 */
{ "cmp", 2, flUseLabel, OH_DirectIndirectY }, /* $d1 */
{ "cmp", 2, flUseLabel, OH_DirectIndirectZ }, /* $d2 */
{ "lbne", 3, flLabel, OH_RelativeLong4510 }, /* $d3 */
{ "cpz", 2, flUseLabel, OH_Direct }, /* $d4 */
{ "cmp", 2, flUseLabel, OH_DirectX }, /* $d5 */
{ "dec", 2, flUseLabel, OH_DirectX }, /* $d6 */
{ "smb5", 2, flUseLabel, OH_Direct }, /* $d7 */
{ "cld", 1, flNone, OH_Implicit }, /* $d8 */
{ "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */
{ "phx", 1, flNone, OH_Implicit }, /* $da */
{ "phz", 1, flNone, OH_Implicit }, /* $db */
{ "cpz", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $dc */
{ "cmp", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $dd */
{ "dec", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $de */
{ "bbs5", 3, flUseLabel, OH_BitBranch }, /* $df */
{ "cpx", 2, flNone, OH_Immediate }, /* $e0 */
{ "sbc", 2, flUseLabel, OH_DirectXIndirect }, /* $e1 */
{ "lda", 2, flNone, OH_StackRelativeIndirectY4510}, /* $e2 */
{ "inw", 2, flUseLabel, OH_Direct }, /* $e3 */
{ "cpx", 2, flUseLabel, OH_Direct }, /* $e4 */
{ "sbc", 2, flUseLabel, OH_Direct }, /* $e5 */
{ "inc", 2, flUseLabel, OH_Direct }, /* $e6 */
{ "smb6", 2, flUseLabel, OH_Direct }, /* $e7 */
{ "inx", 1, flNone, OH_Implicit }, /* $e8 */
{ "sbc", 2, flNone, OH_Immediate }, /* $e9 */
{ "eom", 1, flNone, OH_Implicit }, /* $ea */
{ "row", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $eb */
{ "cpx", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ec */
{ "sbc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ed */
{ "inc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ee */
{ "bbs6", 3, flUseLabel, OH_BitBranch }, /* $ef */
{ "beq", 2, flLabel, OH_Relative }, /* $f0 */
{ "sbc", 2, flUseLabel, OH_DirectIndirectY }, /* $f1 */
{ "sbc", 2, flUseLabel, OH_DirectIndirectZ }, /* $f2 */
{ "lbeq", 3, flLabel, OH_RelativeLong4510 }, /* $f3 */
{ "phw", 3, flNone, OH_ImmediateWord }, /* $f4 */
{ "sbc", 2, flUseLabel, OH_DirectX }, /* $f5 */
{ "inc", 2, flUseLabel, OH_DirectX }, /* $f6 */
{ "smb7", 2, flUseLabel, OH_Direct }, /* $f7 */
{ "sed", 1, flNone, OH_Implicit }, /* $f8 */
{ "sbc", 3, flUseLabel, OH_AbsoluteY }, /* $f9 */
{ "plx", 1, flNone, OH_Implicit }, /* $fa */
{ "plz", 1, flNone, OH_Implicit }, /* $fb */
{ "phw", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $fc */
{ "sbc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fd */
{ "inc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $fe */
{ "bbs7", 3, flUseLabel, OH_BitBranch }, /* $ff */
};

58
src/da65/opc4510.h Normal file
View File

@@ -0,0 +1,58 @@
/*****************************************************************************/
/* */
/* opc4510.h */
/* */
/* 4510 opcode description table */
/* */
/* */
/* */
/* (C) 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 OPC4510_H
#define OPC4510_H
#include "opcdesc.h"
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Descriptions for all opcodes */
extern const OpcDesc OpcTable_4510[256];
/* End of opc4510.h */
#endif

View File

@@ -250,7 +250,7 @@ const OpcDesc OpcTable_65C02[256] = {
{ "iny", 1, flNone, OH_Implicit }, /* $c8 */
{ "cmp", 2, flNone, OH_Immediate }, /* $c9 */
{ "dex", 1, flNone, OH_Implicit }, /* $ca */
{ "", 1, flIllegal, OH_Illegal, }, /* $cb */
{ "wai", 1, flNone, OH_Implicit }, /* $cb */
{ "cpy", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cc */
{ "cmp", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $cd */
{ "dec", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $ce */
@@ -266,7 +266,7 @@ const OpcDesc OpcTable_65C02[256] = {
{ "cld", 1, flNone, OH_Implicit }, /* $d8 */
{ "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */
{ "phx", 1, flNone, OH_Implicit }, /* $da */
{ "", 1, flIllegal, OH_Illegal, }, /* $db */
{ "stp", 1, flNone, OH_Implicit }, /* $db */
{ "", 1, flIllegal, OH_Illegal, }, /* $dc */
{ "cmp", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $dd */
{ "dec", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $de */

View File

@@ -54,7 +54,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "tsb", 2, flUseLabel, OH_Direct }, /* $04 */
{ "ora", 2, flUseLabel, OH_Direct }, /* $05 */
{ "asl", 2, flUseLabel, OH_Direct }, /* $06 */
{ "rmb0", 1, flUseLabel, OH_Direct, }, /* $07 */
{ "rmb0", 2, flUseLabel, OH_Direct, }, /* $07 */
{ "php", 1, flNone, OH_Implicit }, /* $08 */
{ "ora", 2, flNone, OH_Immediate }, /* $09 */
{ "asl", 1, flNone, OH_Accumulator }, /* $0a */
@@ -70,7 +70,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "trb", 2, flUseLabel, OH_Direct }, /* $14 */
{ "ora", 2, flUseLabel, OH_DirectX }, /* $15 */
{ "asl", 2, flUseLabel, OH_DirectX }, /* $16 */
{ "rmb1", 1, flUseLabel, OH_Direct, }, /* $17 */
{ "rmb1", 2, flUseLabel, OH_Direct, }, /* $17 */
{ "clc", 1, flNone, OH_Implicit }, /* $18 */
{ "ora", 3, flUseLabel, OH_AbsoluteY }, /* $19 */
{ "inc", 1, flNone, OH_Accumulator }, /* $1a */
@@ -86,7 +86,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "bit", 2, flUseLabel, OH_Direct }, /* $24 */
{ "and", 2, flUseLabel, OH_Direct }, /* $25 */
{ "rol", 2, flUseLabel, OH_Direct }, /* $26 */
{ "rmb2", 1, flUseLabel, OH_Direct, }, /* $27 */
{ "rmb2", 2, flUseLabel, OH_Direct, }, /* $27 */
{ "plp", 1, flNone, OH_Implicit }, /* $28 */
{ "and", 2, flNone, OH_Immediate }, /* $29 */
{ "rol", 1, flNone, OH_Accumulator }, /* $2a */
@@ -102,7 +102,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "bit", 2, flUseLabel, OH_DirectX }, /* $34 */
{ "and", 2, flUseLabel, OH_DirectX }, /* $35 */
{ "rol", 2, flUseLabel, OH_DirectX }, /* $36 */
{ "rmb3", 1, flUseLabel, OH_Direct, }, /* $37 */
{ "rmb3", 2, flUseLabel, OH_Direct, }, /* $37 */
{ "sec", 1, flNone, OH_Implicit }, /* $38 */
{ "and", 3, flUseLabel, OH_AbsoluteY }, /* $39 */
{ "dec", 1, flNone, OH_Accumulator }, /* $3a */
@@ -114,11 +114,11 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "rti", 1, flNone, OH_Rts }, /* $40 */
{ "eor", 2, flUseLabel, OH_DirectXIndirect }, /* $41 */
{ "say", 1, flNone, OH_Implicit, }, /* $42 */
{ "tmai", 2, flNone, OH_Immediate, }, /* $43 */
{ "tma", 2, flNone, OH_Immediate, }, /* $43 */
{ "bsr", 2, flLabel, OH_Relative, }, /* $44 */
{ "eor", 2, flUseLabel, OH_Direct }, /* $45 */
{ "lsr", 2, flUseLabel, OH_Direct }, /* $46 */
{ "rmb4", 1, flUseLabel, OH_Direct, }, /* $47 */
{ "rmb4", 2, flUseLabel, OH_Direct, }, /* $47 */
{ "pha", 1, flNone, OH_Implicit }, /* $48 */
{ "eor", 2, flNone, OH_Immediate }, /* $49 */
{ "lsr", 1, flNone, OH_Accumulator }, /* $4a */
@@ -130,11 +130,11 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "bvc", 2, flLabel, OH_Relative }, /* $50 */
{ "eor", 2, flUseLabel, OH_DirectIndirectY }, /* $51 */
{ "eor", 2, flUseLabel, OH_DirectIndirect }, /* $52 */
{ "tami", 2, flNone, OH_Immediate, }, /* $53 */
{ "tam", 2, flNone, OH_Immediate, }, /* $53 */
{ "csl", 1, flNone, OH_Implicit, }, /* $54 */
{ "eor", 2, flUseLabel, OH_DirectX }, /* $55 */
{ "lsr", 2, flUseLabel, OH_DirectX }, /* $56 */
{ "rmb5", 1, flUseLabel, OH_Direct, }, /* $57 */
{ "rmb5", 2, flUseLabel, OH_Direct, }, /* $57 */
{ "cli", 1, flNone, OH_Implicit }, /* $58 */
{ "eor", 3, flUseLabel, OH_AbsoluteY }, /* $59 */
{ "phy", 1, flNone, OH_Implicit }, /* $5a */
@@ -150,7 +150,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "stz", 2, flUseLabel, OH_Direct }, /* $64 */
{ "adc", 2, flUseLabel, OH_Direct }, /* $65 */
{ "ror", 2, flUseLabel, OH_Direct }, /* $66 */
{ "rmb6", 1, flUseLabel, OH_Direct, }, /* $67 */
{ "rmb6", 2, flUseLabel, OH_Direct, }, /* $67 */
{ "pla", 1, flNone, OH_Implicit }, /* $68 */
{ "adc", 2, flNone, OH_Immediate }, /* $69 */
{ "ror", 1, flNone, OH_Accumulator }, /* $6a */
@@ -166,12 +166,12 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "stz", 2, flUseLabel, OH_DirectX }, /* $74 */
{ "adc", 2, flUseLabel, OH_DirectX }, /* $75 */
{ "ror", 2, flUseLabel, OH_DirectX }, /* $76 */
{ "rmb7", 1, flUseLabel, OH_Direct, }, /* $77 */
{ "rmb7", 2, flUseLabel, OH_Direct, }, /* $77 */
{ "sei", 1, flNone, OH_Implicit }, /* $78 */
{ "adc", 3, flUseLabel, OH_AbsoluteY }, /* $79 */
{ "ply", 1, flNone, OH_Implicit }, /* $7a */
{ "", 1, flIllegal, OH_Illegal, }, /* $7b */
{ "jmp", 3, flLabel, OH_AbsoluteXIndirect }, /* $7c */
{ "jmp", 3, flLabel, OH_JmpAbsoluteXIndirect }, /* $7c */
{ "adc", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7d */
{ "ror", 3, flUseLabel|flAbsOverride, OH_AbsoluteX }, /* $7e */
{ "bbr7", 3, flUseLabel, OH_BitBranch }, /* $7f */
@@ -182,7 +182,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "sty", 2, flUseLabel, OH_Direct }, /* $84 */
{ "sta", 2, flUseLabel, OH_Direct }, /* $85 */
{ "stx", 2, flUseLabel, OH_Direct }, /* $86 */
{ "smb0", 1, flUseLabel, OH_Direct, }, /* $87 */
{ "smb0", 2, flUseLabel, OH_Direct, }, /* $87 */
{ "dey", 1, flNone, OH_Implicit }, /* $88 */
{ "bit", 2, flNone, OH_Immediate }, /* $89 */
{ "txa", 1, flNone, OH_Implicit }, /* $8a */
@@ -198,7 +198,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "sty", 2, flUseLabel, OH_DirectX }, /* $94 */
{ "sta", 2, flUseLabel, OH_DirectX }, /* $95 */
{ "stx", 2, flUseLabel, OH_DirectY }, /* $96 */
{ "smb1", 1, flUseLabel, OH_Direct, }, /* $97 */
{ "smb1", 2, flUseLabel, OH_Direct, }, /* $97 */
{ "tya", 1, flNone, OH_Implicit }, /* $98 */
{ "sta", 3, flUseLabel, OH_AbsoluteY }, /* $99 */
{ "txs", 1, flNone, OH_Implicit }, /* $9a */
@@ -214,7 +214,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "ldy", 2, flUseLabel, OH_Direct }, /* $a4 */
{ "lda", 2, flUseLabel, OH_Direct }, /* $a5 */
{ "ldx", 2, flUseLabel, OH_Direct }, /* $a6 */
{ "smb2", 1, flUseLabel, OH_Direct, }, /* $a7 */
{ "smb2", 2, flUseLabel, OH_Direct, }, /* $a7 */
{ "tay", 1, flNone, OH_Implicit }, /* $a8 */
{ "lda", 2, flNone, OH_Immediate }, /* $a9 */
{ "tax", 1, flNone, OH_Implicit }, /* $aa */
@@ -230,7 +230,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "ldy", 2, flUseLabel, OH_DirectX }, /* $b4 */
{ "lda", 2, flUseLabel, OH_DirectX }, /* $b5 */
{ "ldx", 2, flUseLabel, OH_DirectY }, /* $b6 */
{ "smb3", 1, flUseLabel, OH_Direct, }, /* $b7 */
{ "smb3", 2, flUseLabel, OH_Direct, }, /* $b7 */
{ "clv", 1, flNone, OH_Implicit }, /* $b8 */
{ "lda", 3, flUseLabel, OH_AbsoluteY }, /* $b9 */
{ "tsx", 1, flNone, OH_Implicit }, /* $ba */
@@ -246,7 +246,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "cpy", 2, flUseLabel, OH_Direct }, /* $c4 */
{ "cmp", 2, flUseLabel, OH_Direct }, /* $c5 */
{ "dec", 2, flUseLabel, OH_Direct }, /* $c6 */
{ "smb4", 1, flUseLabel, OH_Direct, }, /* $c7 */
{ "smb4", 2, flUseLabel, OH_Direct, }, /* $c7 */
{ "iny", 1, flNone, OH_Implicit }, /* $c8 */
{ "cmp", 2, flNone, OH_Immediate }, /* $c9 */
{ "dex", 1, flNone, OH_Implicit }, /* $ca */
@@ -262,7 +262,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "csh", 1, flNone, OH_Implicit, }, /* $d4 */
{ "cmp", 2, flUseLabel, OH_DirectX }, /* $d5 */
{ "dec", 2, flUseLabel, OH_DirectX }, /* $d6 */
{ "smb5", 1, flUseLabel, OH_Direct, }, /* $d7 */
{ "smb5", 2, flUseLabel, OH_Direct, }, /* $d7 */
{ "cld", 1, flNone, OH_Implicit }, /* $d8 */
{ "cmp", 3, flUseLabel, OH_AbsoluteY }, /* $d9 */
{ "phx", 1, flNone, OH_Implicit }, /* $da */
@@ -278,7 +278,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "cpx", 2, flUseLabel, OH_Direct }, /* $e4 */
{ "sbc", 2, flUseLabel, OH_Direct }, /* $e5 */
{ "inc", 2, flUseLabel, OH_Direct }, /* $e6 */
{ "smb6", 1, flUseLabel, OH_Direct, }, /* $e7 */
{ "smb6", 2, flUseLabel, OH_Direct, }, /* $e7 */
{ "inx", 1, flNone, OH_Implicit }, /* $e8 */
{ "sbc", 2, flNone, OH_Immediate }, /* $e9 */
{ "nop", 1, flNone, OH_Implicit }, /* $ea */
@@ -294,7 +294,7 @@ const OpcDesc OpcTable_HuC6280[256] = {
{ "set", 1, flNone, OH_Implicit, }, /* $f4 */
{ "sbc", 2, flUseLabel, OH_DirectX }, /* $f5 */
{ "inc", 2, flUseLabel, OH_DirectX }, /* $f6 */
{ "smb7", 1, flUseLabel, OH_Direct, }, /* $f7 */
{ "smb7", 2, flUseLabel, OH_Direct, }, /* $f7 */
{ "sed", 1, flNone, OH_Implicit }, /* $f8 */
{ "sbc", 3, flUseLabel, OH_AbsoluteY }, /* $f9 */
{ "plx", 1, flNone, OH_Implicit }, /* $fa */

View File

@@ -35,6 +35,7 @@
/* da65 */
#include "error.h"
#include "opc4510.h"
#include "opc6502.h"
#include "opc6502x.h"
#include "opc65816.h"
@@ -73,6 +74,7 @@ void SetOpcTable (cpu_t CPU)
case CPU_65C02: OpcTable = OpcTable_65C02; break;
case CPU_HUC6280: OpcTable = OpcTable_HuC6280; break;
case CPU_M740: OpcTable = OpcTable_M740; break;
case CPU_4510: OpcTable = OpcTable_4510; break;
default: Error ("Unsupported CPU");
}
}

View File

@@ -166,7 +166,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the program version */
{
fprintf (stderr, "grc65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}

View File

@@ -169,18 +169,6 @@ static void BinWriteMem (BinDesc* D, MemoryArea* M)
PrintNumVal ("Address", Addr);
PrintNumVal ("FileOffs", (unsigned long) ftell (D->F));
/* Check if the alignment for the segment from the linker config is
** a multiple for that of the segment.
*/
if ((S->RunAlignment % S->Seg->Alignment) != 0) {
/* Segment requires another alignment than configured
** in the linker.
*/
Warning ("Segment `%s' is not aligned properly. Resulting "
"executable may not be functional.",
GetString (S->Name));
}
/* If this is the run memory area, we must apply run alignment. If
** this is not the run memory area but the load memory area (which
** means that both are different), we must apply load alignment.

View File

@@ -1855,6 +1855,20 @@ unsigned CfgProcess (void)
/* This is the run (and maybe load) memory area. Handle
** alignment and explict start address and offset.
*/
/* Check if the alignment for the segment from the linker
** config. is a multiple for that of the segment.
*/
if ((S->RunAlignment % S->Seg->Alignment) != 0) {
/* Segment requires another alignment than configured
** in the linker.
*/
CfgWarning (GetSourcePos (S->LI),
"Segment `%s' isn't aligned properly; the"
" resulting executable might not be functional.",
GetString (S->Name));
}
if (S->Flags & SF_ALIGN) {
/* Align the address */
unsigned long NewAddr = AlignAddr (Addr, S->RunAlignment);
@@ -1865,8 +1879,8 @@ unsigned CfgProcess (void)
*/
if (M->FillLevel == 0 && NewAddr > Addr) {
CfgWarning (GetSourcePos (S->LI),
"First segment in memory area `%s' does "
"already need fill bytes for alignment",
"The first segment in memory area `%s' "
"needs fill bytes for alignment.",
GetString (M->Name));
}

View File

@@ -543,7 +543,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the assembler version */
{
fprintf (stderr, "ld65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}

View File

@@ -505,7 +505,7 @@ void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name)
}
/* Not found or no identifier */
CfgError (&CfgErrorPos, "%s expected", Name);
CfgError (&CfgErrorPos, "%s expected, got '%s'", Name, SB_GetConstBuf(&CfgSVal));
}

View File

@@ -209,6 +209,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the assembler version */
{
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}

View File

@@ -67,6 +67,8 @@ static unsigned HaveNMIRequest;
/* IRQ request active */
static unsigned HaveIRQRequest;
/* flag to print cycles at program termination */
int PrintCycles;
/*****************************************************************************/

View File

@@ -99,6 +99,8 @@ unsigned ExecuteInsn (void);
unsigned long GetCycles (void);
/* Return the total number of clock cycles executed */
extern int PrintCycles;
/* flag to print cycles at program termination */
/* End of 6502.h */

View File

@@ -61,7 +61,7 @@
const char* ProgramFile;
/* exit simulator after MaxCycles Cycles */
unsigned long MaxCycles = 0;
unsigned long MaxCycles;
/*****************************************************************************/
/* Code */
@@ -74,12 +74,14 @@ static void Usage (void)
printf ("Usage: %s [options] file [arguments]\n"
"Short options:\n"
" -h\t\t\tHelp (this text)\n"
" -c\t\t\tPrint amount of executed CPU cycles\n"
" -v\t\t\tIncrease verbosity\n"
" -V\t\t\tPrint the simulator version number\n"
" -x <num>\t\tExit simulator after <num> cycles\n"
"\n"
"Long options:\n"
" --help\t\tHelp (this text)\n"
" --cycles\t\tPrint amount of executed CPU cycles\n"
" --verbose\t\tIncrease verbosity\n"
" --version\t\tPrint the simulator version number\n",
ProgName);
@@ -106,11 +108,21 @@ static void OptVerbose (const char* Opt attribute ((unused)),
static void OptCycles (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Set flag to print amount of cycles at the end */
{
PrintCycles = 1;
}
static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print the simulator version */
{
fprintf (stderr, "sim65 V%s\n", GetVersionAsString ());
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}
static void OptQuitXIns (const char* Opt attribute ((unused)),
@@ -166,6 +178,7 @@ int main (int argc, char* argv[])
/* Program long options */
static const LongOpt OptTab[] = {
{ "--help", 0, OptHelp },
{ "--cycles", 0, OptCycles },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
};
@@ -196,6 +209,10 @@ int main (int argc, char* argv[])
OptHelp (Arg, 0);
break;
case 'c':
OptCycles (Arg, 0);
break;
case 'v':
OptVerbose (Arg, 0);
break;

View File

@@ -156,6 +156,9 @@ static void PVArgs (CPURegs* Regs)
static void PVExit (CPURegs* Regs)
{
Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC);
if (PrintCycles) {
Print (stdout, 0, "%lu cycles\n", GetCycles ());
}
exit (Regs->AC);
}

View File

@@ -92,6 +92,7 @@ static void Usage (void)
"\n"
"Long options:\n"
" --convert-to fmt[,attrlist]\tConvert into target format\n"
" --dump-palette\t\tDump palette as table\n"
" --help\t\t\tHelp (this text)\n"
" --list-conversions\t\tList all possible conversions\n"
" --pop\t\t\t\tRestore the original loaded image\n"
@@ -273,7 +274,7 @@ static void OptSlice (const char* Opt attribute ((unused)), const char* Arg)
static void OptVerbose (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Increase versbosity */
/* Increase verbosity */
{
++Verbosity;
}
@@ -285,6 +286,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the assembler version */
{
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
exit(EXIT_SUCCESS);
}
@@ -397,6 +399,11 @@ int main (int argc, char* argv [])
++I;
}
/* Do we have an input file? */
if (I == 1) {
Error ("No input file");
}
/* Cleanup data */
SetWorkBitmap (C);
FreeBitmap (B);