Merge branch 'master' into sane_makefile_output
This commit is contained in:
15
src/Makefile
15
src/Makefile
@@ -178,4 +178,19 @@ $(eval $(call OBJS_template,common))
|
||||
|
||||
$(foreach prog,$(PROGS),$(eval $(call PROG_template,$(prog))))
|
||||
|
||||
|
||||
.PHONY: dbginfo dbgsh test
|
||||
|
||||
test: dbginfo dbgsh
|
||||
|
||||
$(eval $(call OBJS_template,dbginfo))
|
||||
|
||||
dbginfo: $(dbginfo_OBJS)
|
||||
|
||||
../wrk/dbgsh$(EXE_SUFFIX): $(dbginfo_OBJS) ../wrk/common/common.a
|
||||
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
||||
|
||||
dbgsh: ../wrk/dbgsh$(EXE_SUFFIX)
|
||||
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
@@ -394,6 +394,16 @@ void DoConditionals (void)
|
||||
CalcOverallIfCond ();
|
||||
break;
|
||||
|
||||
case TOK_IFP02X:
|
||||
D = AllocIf (".IFP02X", 1);
|
||||
NextTok ();
|
||||
if (IfCond) {
|
||||
SetIfCond (D, GetCPU() == CPU_6502X);
|
||||
}
|
||||
ExpectSep ();
|
||||
CalcOverallIfCond ();
|
||||
break;
|
||||
|
||||
case TOK_IFP4510:
|
||||
D = AllocIf (".IFP4510", 1);
|
||||
NextTok ();
|
||||
@@ -485,6 +495,7 @@ int CheckConditionals (void)
|
||||
case TOK_IFNDEF:
|
||||
case TOK_IFNREF:
|
||||
case TOK_IFP02:
|
||||
case TOK_IFP02X:
|
||||
case TOK_IFP4510:
|
||||
case TOK_IFP816:
|
||||
case TOK_IFPC02:
|
||||
|
||||
@@ -169,8 +169,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[56];
|
||||
} InsTab6502 = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTab6502.Ins) / sizeof (InsTab6502.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x080A26C, 0x60, 0, PutAll },
|
||||
{ "AND", 0x080A26C, 0x20, 0, PutAll },
|
||||
{ "ASL", 0x000006e, 0x02, 1, PutAll },
|
||||
@@ -227,6 +229,7 @@ static const struct {
|
||||
{ "TXA", 0x0000001, 0x8a, 0, PutAll },
|
||||
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
|
||||
{ "TYA", 0x0000001, 0x98, 0, PutAll }
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -235,8 +238,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[75];
|
||||
} InsTab6502X = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTab6502X.Ins) / sizeof (InsTab6502X.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x080A26C, 0x60, 0, PutAll },
|
||||
{ "ALR", 0x0800000, 0x4B, 0, PutAll }, /* X */
|
||||
{ "ANC", 0x0800000, 0x0B, 0, PutAll }, /* X */
|
||||
@@ -312,6 +317,7 @@ static const struct {
|
||||
{ "TXA", 0x0000001, 0x8a, 0, PutAll },
|
||||
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
|
||||
{ "TYA", 0x0000001, 0x98, 0, PutAll }
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -324,8 +330,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[71];
|
||||
} InsTab6502DTV = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTab6502DTV.Ins) / sizeof (InsTab6502DTV.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x080A26C, 0x60, 0, PutAll },
|
||||
{ "ALR", 0x0800000, 0x4B, 0, PutAll }, /* X */
|
||||
{ "ANC", 0x0800000, 0x0B, 0, PutAll }, /* X */
|
||||
@@ -397,6 +405,7 @@ static const struct {
|
||||
{ "TXA", 0x0000001, 0x8a, 0, PutAll },
|
||||
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
|
||||
{ "TYA", 0x0000001, 0x98, 0, PutAll }
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -405,8 +414,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[66];
|
||||
} InsTab65SC02 = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTab65SC02.Ins) / sizeof (InsTab65SC02.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x080A66C, 0x60, 0, PutAll },
|
||||
{ "AND", 0x080A66C, 0x20, 0, PutAll },
|
||||
{ "ASL", 0x000006e, 0x02, 1, PutAll },
|
||||
@@ -473,6 +484,7 @@ static const struct {
|
||||
{ "TXA", 0x0000001, 0x8a, 0, PutAll },
|
||||
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
|
||||
{ "TYA", 0x0000001, 0x98, 0, PutAll }
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -481,8 +493,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[100];
|
||||
} InsTab65C02 = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTab65C02.Ins) / sizeof (InsTab65C02.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x080A66C, 0x60, 0, PutAll },
|
||||
{ "AND", 0x080A66C, 0x20, 0, PutAll },
|
||||
{ "ASL", 0x000006e, 0x02, 1, PutAll },
|
||||
@@ -583,6 +597,7 @@ static const struct {
|
||||
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
|
||||
{ "TYA", 0x0000001, 0x98, 0, PutAll },
|
||||
{ "WAI", 0x0000001, 0xcb, 0, PutAll }
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -591,8 +606,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[133];
|
||||
} InsTab4510 = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTab4510.Ins) / sizeof (InsTab4510.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x080A66C, 0x60, 0, PutAll },
|
||||
{ "AND", 0x080A66C, 0x20, 0, PutAll },
|
||||
{ "ASL", 0x000006e, 0x02, 1, PutAll },
|
||||
@@ -726,6 +743,7 @@ static const struct {
|
||||
{ "TYA", 0x0000001, 0x98, 0, PutAll },
|
||||
{ "TYS", 0x0000001, 0x2b, 0, PutAll },
|
||||
{ "TZA", 0x0000001, 0x6b, 0, PutAll },
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -734,8 +752,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[100];
|
||||
} InsTab65816 = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTab65816.Ins) / sizeof (InsTab65816.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x0b8f6fc, 0x60, 0, PutAll },
|
||||
{ "AND", 0x0b8f6fc, 0x20, 0, PutAll },
|
||||
{ "ASL", 0x000006e, 0x02, 1, PutAll },
|
||||
@@ -836,6 +856,7 @@ static const struct {
|
||||
{ "WDM", 0x0800004, 0x42, 6, PutAll },
|
||||
{ "XBA", 0x0000001, 0xeb, 0, PutAll },
|
||||
{ "XCE", 0x0000001, 0xfb, 0, PutAll }
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -844,8 +865,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[26];
|
||||
} InsTabSweet16 = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTabSweet16.Ins) / sizeof (InsTabSweet16.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADD", AMSW16_REG, 0xA0, 0, PutSweet16 },
|
||||
{ "BC", AMSW16_BRA, 0x03, 0, PutSweet16Branch },
|
||||
{ "BK", AMSW16_IMP, 0x0A, 0, PutSweet16 },
|
||||
@@ -872,6 +895,7 @@ static const struct {
|
||||
{ "STD", AMSW16_IND, 0x70, 0, PutSweet16 },
|
||||
{ "STP", AMSW16_IND, 0x90, 0, PutSweet16 },
|
||||
{ "SUB", AMSW16_REG, 0xB0, 0, PutSweet16 },
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -880,8 +904,10 @@ static const struct {
|
||||
unsigned Count;
|
||||
InsDesc Ins[135];
|
||||
} InsTabHuC6280 = {
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
sizeof (InsTabHuC6280.Ins) / sizeof (InsTabHuC6280.Ins[0]),
|
||||
{
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "ADC", 0x080A66C, 0x60, 0, PutAll },
|
||||
{ "AND", 0x080A66C, 0x20, 0, PutAll },
|
||||
{ "ASL", 0x000006e, 0x02, 1, PutAll },
|
||||
@@ -1017,6 +1043,7 @@ static const struct {
|
||||
{ "TXA", 0x0000001, 0x8a, 0, PutAll },
|
||||
{ "TXS", 0x0000001, 0x9a, 0, PutAll },
|
||||
{ "TYA", 0x0000001, 0x98, 0, PutAll }
|
||||
/* END SORTED.SH */
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -350,6 +350,10 @@ static void SetSys (const char* Sys)
|
||||
NewSymbol ("__RP6502__", 1);
|
||||
break;
|
||||
|
||||
case TGT_AGAT:
|
||||
NewSymbol ("__AGAT__", 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
AbEnd ("Invalid target name: '%s'", Sys);
|
||||
|
||||
|
||||
@@ -1562,6 +1562,14 @@ static void DoP02 (void)
|
||||
|
||||
|
||||
|
||||
static void DoP02X (void)
|
||||
/* Switch to 6502 CPU */
|
||||
{
|
||||
SetCPU (CPU_6502X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void DoPC02 (void)
|
||||
/* Switch to 65C02 CPU */
|
||||
{
|
||||
@@ -2057,70 +2065,72 @@ struct CtrlDesc {
|
||||
void (*Handler) (void); /* Command handler */
|
||||
};
|
||||
|
||||
/* NOTE: .AND, .BITAND, .BITNOT, .BITOR, .BITXOR, .MOD, .NOT, .OR, .SHL, .SHR
|
||||
and .XOR do NOT go into this table */
|
||||
#define PSEUDO_COUNT (sizeof (CtrlCmdTab) / sizeof (CtrlCmdTab [0]))
|
||||
static CtrlDesc CtrlCmdTab [] = {
|
||||
{ ccNone, DoA16 },
|
||||
{ ccNone, DoA8 },
|
||||
{ ccNone, DoA16 }, /* .A16 */
|
||||
{ ccNone, DoA8 }, /* .A8 */
|
||||
{ ccNone, DoAddr }, /* .ADDR */
|
||||
{ ccNone, DoUnexpected }, /* .ADDRSIZE */
|
||||
{ ccNone, DoAlign },
|
||||
{ ccNone, DoASCIIZ },
|
||||
{ ccNone, DoAlign }, /* .ALIGN */
|
||||
{ ccNone, DoASCIIZ }, /* .ASCIIZ */
|
||||
{ ccNone, DoUnexpected }, /* .ASIZE */
|
||||
{ ccNone, DoAssert },
|
||||
{ ccNone, DoAutoImport },
|
||||
{ ccNone, DoAssert }, /* .ASSERT */
|
||||
{ ccNone, DoAutoImport }, /* .AUTOIMPORT */
|
||||
{ ccNone, DoUnexpected }, /* .BANK */
|
||||
{ ccNone, DoUnexpected }, /* .BANKBYTE */
|
||||
{ ccNone, DoBankBytes },
|
||||
{ ccNone, DoBankBytes }, /* .BANKBYTES */
|
||||
{ ccNone, DoUnexpected }, /* .BLANK */
|
||||
{ ccNone, DoBss },
|
||||
{ ccNone, DoByte },
|
||||
{ ccNone, DoCase },
|
||||
{ ccNone, DoCharMap },
|
||||
{ ccNone, DoCode },
|
||||
{ ccNone, DoBss }, /* .BSS */
|
||||
{ ccNone, DoByte }, /* .BYT, .BYTE */
|
||||
{ ccNone, DoCase }, /* .CASE */
|
||||
{ ccNone, DoCharMap }, /* .CHARMAP */
|
||||
{ ccNone, DoCode }, /* .CODE */
|
||||
{ ccNone, DoUnexpected, }, /* .CONCAT */
|
||||
{ ccNone, DoConDes },
|
||||
{ ccNone, DoConDes }, /* .CONDES */
|
||||
{ ccNone, DoUnexpected }, /* .CONST */
|
||||
{ ccNone, DoConstructor },
|
||||
{ ccNone, DoConstructor }, /* .CONSTRUCTOR */
|
||||
{ ccNone, DoUnexpected }, /* .CPU */
|
||||
{ ccNone, DoData },
|
||||
{ ccNone, DoDbg, },
|
||||
{ ccNone, DoDByt },
|
||||
{ ccNone, DoDebugInfo },
|
||||
{ ccKeepToken, DoDefine },
|
||||
{ ccNone, DoData }, /* .DATA */
|
||||
{ ccNone, DoDbg, }, /* .DBG */
|
||||
{ ccNone, DoDByt }, /* .DBYT */
|
||||
{ ccNone, DoDebugInfo }, /* .DEBUGINFO */
|
||||
{ ccKeepToken, DoDefine }, /* .DEF, .DEFINE */
|
||||
{ ccNone, DoUnexpected }, /* .DEFINED */
|
||||
{ ccNone, DoUnexpected }, /* .DEFINEDMACRO */
|
||||
{ ccNone, DoDelMac },
|
||||
{ ccNone, DoDestructor },
|
||||
{ ccNone, DoDWord },
|
||||
{ ccNone, DoDelMac }, /* .DELMAC, .DELMACRO */
|
||||
{ ccNone, DoDestructor }, /* .DESTRUCTOR */
|
||||
{ ccNone, DoDWord }, /* .DWORD */
|
||||
{ ccKeepToken, DoConditionals }, /* .ELSE */
|
||||
{ ccKeepToken, DoConditionals }, /* .ELSEIF */
|
||||
{ ccKeepToken, DoEnd },
|
||||
{ ccKeepToken, DoEnd }, /* .END */
|
||||
{ ccNone, DoUnexpected }, /* .ENDENUM */
|
||||
{ ccKeepToken, DoConditionals }, /* .ENDIF */
|
||||
{ ccNone, DoUnexpected }, /* .ENDMACRO */
|
||||
{ ccNone, DoEndProc },
|
||||
{ ccNone, DoUnexpected }, /* .ENDREPEAT */
|
||||
{ ccNone, DoEndScope },
|
||||
{ ccNone, DoUnexpected }, /* .ENDMAC, .ENDMACRO */
|
||||
{ ccNone, DoEndProc }, /* .ENDPROC */
|
||||
{ ccNone, DoUnexpected }, /* .ENDREP, .ENDREPEAT */
|
||||
{ ccNone, DoEndScope }, /* .ENDSCOPE */
|
||||
{ ccNone, DoUnexpected }, /* .ENDSTRUCT */
|
||||
{ ccNone, DoUnexpected }, /* .ENDUNION */
|
||||
{ ccNone, DoEnum },
|
||||
{ ccNone, DoError },
|
||||
{ ccNone, DoExitMacro },
|
||||
{ ccNone, DoExport },
|
||||
{ ccNone, DoExportZP },
|
||||
{ ccNone, DoFarAddr },
|
||||
{ ccNone, DoFatal },
|
||||
{ ccNone, DoFeature },
|
||||
{ ccNone, DoFileOpt },
|
||||
{ ccNone, DoForceImport },
|
||||
{ ccNone, DoEnum }, /* .ENUM */
|
||||
{ ccNone, DoError }, /* .ERROR */
|
||||
{ ccNone, DoExitMacro }, /* .EXITMAC, .EXITMACRO */
|
||||
{ ccNone, DoExport }, /* .EXPORT */
|
||||
{ ccNone, DoExportZP }, /* .EXPORTZP */
|
||||
{ ccNone, DoFarAddr }, /* .FARADDR */
|
||||
{ ccNone, DoFatal }, /* .FATAL */
|
||||
{ ccNone, DoFeature }, /* .FEATURE */
|
||||
{ ccNone, DoFileOpt }, /* .FOPT, .FILEOPT */
|
||||
{ ccNone, DoForceImport }, /* .FORCEIMPORT */
|
||||
{ ccNone, DoUnexpected }, /* .FORCEWORD */
|
||||
{ ccNone, DoGlobal },
|
||||
{ ccNone, DoGlobalZP },
|
||||
{ ccNone, DoGlobal }, /* .GLOBAL */
|
||||
{ ccNone, DoGlobalZP }, /* .GLOBALZP */
|
||||
{ ccNone, DoUnexpected }, /* .HIBYTE */
|
||||
{ ccNone, DoHiBytes },
|
||||
{ ccNone, DoHiBytes }, /* .HIBYTES */
|
||||
{ ccNone, DoUnexpected }, /* .HIWORD */
|
||||
{ ccNone, DoI16 },
|
||||
{ ccNone, DoI8 },
|
||||
{ ccNone, DoI16 }, /* .I16 */
|
||||
{ ccNone, DoI8 }, /* .I8 */
|
||||
{ ccNone, DoUnexpected }, /* .IDENT */
|
||||
{ ccKeepToken, DoConditionals }, /* .IF */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFBLANK */
|
||||
@@ -2131,81 +2141,83 @@ static CtrlDesc CtrlCmdTab [] = {
|
||||
{ ccKeepToken, DoConditionals }, /* .IFNDEF */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFNREF */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFP02 */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFP02X */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFP4510 */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFP816 */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFPC02 */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFPDTV */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFPSC02 */
|
||||
{ ccKeepToken, DoConditionals }, /* .IFREF */
|
||||
{ ccNone, DoImport },
|
||||
{ ccNone, DoImportZP },
|
||||
{ ccNone, DoIncBin },
|
||||
{ ccNone, DoInclude },
|
||||
{ ccNone, DoInterruptor },
|
||||
{ ccNone, DoImport }, /* .IMPORT */
|
||||
{ ccNone, DoImportZP }, /* .IMPORTZP */
|
||||
{ ccNone, DoIncBin }, /* .INCBIN */
|
||||
{ ccNone, DoInclude }, /* .INCLUDE */
|
||||
{ ccNone, DoInterruptor }, /* .INTERRUPTPOR */
|
||||
{ ccNone, DoUnexpected }, /* .ISIZE */
|
||||
{ ccNone, DoUnexpected }, /* .ISMNEMONIC */
|
||||
{ ccNone, DoInvalid }, /* .LEFT */
|
||||
{ ccNone, DoLineCont },
|
||||
{ ccNone, DoList },
|
||||
{ ccNone, DoListBytes },
|
||||
{ ccNone, DoLiteral },
|
||||
{ ccNone, DoLineCont }, /* .LINECONT */
|
||||
{ ccNone, DoList }, /* .LIST */
|
||||
{ ccNone, DoListBytes }, /* .LISTBYTES */
|
||||
{ ccNone, DoLiteral }, /* .LITERAL */
|
||||
{ ccNone, DoUnexpected }, /* .LOBYTE */
|
||||
{ ccNone, DoLoBytes },
|
||||
{ ccNone, DoLoBytes }, /* .LOBYTES */
|
||||
{ ccNone, DoUnexpected }, /* .LOCAL */
|
||||
{ ccNone, DoLocalChar },
|
||||
{ ccNone, DoLocalChar }, /* .LOCALCHAR */
|
||||
{ ccNone, DoUnexpected }, /* .LOWORD */
|
||||
{ ccNone, DoMacPack },
|
||||
{ ccNone, DoMacro },
|
||||
{ ccNone, DoMacPack }, /* .MACPACK */
|
||||
{ ccNone, DoMacro }, /* .MAC, .MACRO */
|
||||
{ ccNone, DoUnexpected }, /* .MATCH */
|
||||
{ ccNone, DoUnexpected }, /* .MAX */
|
||||
{ ccNone, DoInvalid }, /* .MID */
|
||||
{ ccNone, DoUnexpected }, /* .MIN */
|
||||
{ ccNone, DoNull },
|
||||
{ ccNone, DoOrg },
|
||||
{ ccNone, DoOut },
|
||||
{ ccNone, DoP02 },
|
||||
{ ccNone, DoP4510 },
|
||||
{ ccNone, DoP816 },
|
||||
{ ccNone, DoPageLength },
|
||||
{ ccNone, DoNull }, /* .NULL */
|
||||
{ ccNone, DoOrg }, /* .ORG */
|
||||
{ ccNone, DoOut }, /* .OUT */
|
||||
{ ccNone, DoP02 }, /* .P02 */
|
||||
{ ccNone, DoP02X }, /* .P02X */
|
||||
{ ccNone, DoP4510 }, /* .P4510 */
|
||||
{ ccNone, DoP816 }, /* .P816 */
|
||||
{ ccNone, DoPageLength }, /* .PAGELEN, .PAGELENGTH */
|
||||
{ ccNone, DoUnexpected }, /* .PARAMCOUNT */
|
||||
{ ccNone, DoPC02 },
|
||||
{ ccNone, DoPDTV },
|
||||
{ ccNone, DoPopCharmap },
|
||||
{ ccNone, DoPopCPU },
|
||||
{ ccNone, DoPopSeg },
|
||||
{ ccNone, DoProc },
|
||||
{ ccNone, DoPSC02 },
|
||||
{ ccNone, DoPushCharmap },
|
||||
{ ccNone, DoPushCPU },
|
||||
{ ccNone, DoPushSeg },
|
||||
{ ccNone, DoUnexpected }, /* .REFERENCED */
|
||||
{ ccNone, DoReferTo }, /* .REFERTO */
|
||||
{ ccNone, DoReloc },
|
||||
{ ccNone, DoRepeat },
|
||||
{ ccNone, DoRes },
|
||||
{ ccNone, DoPC02 }, /* .PSC02 */
|
||||
{ ccNone, DoPDTV }, /* .PDTV */
|
||||
{ ccNone, DoPopCharmap }, /* .POPCHARMAP */
|
||||
{ ccNone, DoPopCPU }, /* .POPCPU */
|
||||
{ ccNone, DoPopSeg }, /* .POPSEG */
|
||||
{ ccNone, DoProc }, /* .PROC */
|
||||
{ ccNone, DoPSC02 }, /* .PSC02 */
|
||||
{ ccNone, DoPushCharmap }, /* .PUSHCHARMAP */
|
||||
{ ccNone, DoPushCPU }, /* .PUSHCPU */
|
||||
{ ccNone, DoPushSeg }, /* .PUSHSEG */
|
||||
{ ccNone, DoUnexpected }, /* .REF, .REFERENCED */
|
||||
{ ccNone, DoReferTo }, /* .REFTO, .REFERTO */
|
||||
{ ccNone, DoReloc }, /* .RELOC */
|
||||
{ ccNone, DoRepeat }, /* .REPEAT */
|
||||
{ ccNone, DoRes }, /* .RES */
|
||||
{ ccNone, DoInvalid }, /* .RIGHT */
|
||||
{ ccNone, DoROData },
|
||||
{ ccNone, DoScope },
|
||||
{ ccNone, DoSegment },
|
||||
{ ccNone, DoROData }, /* .RODATA */
|
||||
{ ccNone, DoScope }, /* .SCOPE */
|
||||
{ ccNone, DoSegment }, /* .SEGMENT */
|
||||
{ ccNone, DoUnexpected }, /* .SET */
|
||||
{ ccNone, DoSetCPU },
|
||||
{ ccNone, DoSetCPU }, /* .SETCPU */
|
||||
{ ccNone, DoUnexpected }, /* .SIZEOF */
|
||||
{ ccNone, DoSmart },
|
||||
{ ccNone, DoSmart }, /* .SMART */
|
||||
{ ccNone, DoUnexpected }, /* .SPRINTF */
|
||||
{ ccNone, DoUnexpected }, /* .STRAT */
|
||||
{ ccNone, DoUnexpected }, /* .STRING */
|
||||
{ ccNone, DoUnexpected }, /* .STRLEN */
|
||||
{ ccNone, DoStruct },
|
||||
{ ccNone, DoTag },
|
||||
{ ccNone, DoStruct }, /* .STRUCT */
|
||||
{ ccNone, DoTag }, /* .TAG */
|
||||
{ ccNone, DoUnexpected }, /* .TCOUNT */
|
||||
{ ccNone, DoUnexpected }, /* .TIME */
|
||||
{ ccKeepToken, DoUnDef },
|
||||
{ ccNone, DoUnion },
|
||||
{ ccKeepToken, DoUnDef }, /* .UNDEF, .UNDEFINE */
|
||||
{ ccNone, DoUnion }, /* .UNION */
|
||||
{ ccNone, DoUnexpected }, /* .VERSION */
|
||||
{ ccNone, DoWarning },
|
||||
{ ccNone, DoWord },
|
||||
{ ccNone, DoWarning }, /* .WARNING */
|
||||
{ ccNone, DoWord }, /* .WORD */
|
||||
{ ccNone, DoUnexpected }, /* .XMATCH */
|
||||
{ ccNone, DoZeropage },
|
||||
{ ccNone, DoZeropage }, /* .ZEROPAGE */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -131,10 +131,12 @@ static int C = 0; /* Current input character */
|
||||
int ForcedEnd = 0;
|
||||
|
||||
/* List of dot keywords with the corresponding tokens */
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
struct DotKeyword {
|
||||
const char* Key; /* MUST be first field */
|
||||
token_t Tok;
|
||||
} DotKeywords [] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ ".A16", TOK_A16 },
|
||||
{ ".A8", TOK_A8 },
|
||||
{ ".ADDR", TOK_ADDR },
|
||||
@@ -219,6 +221,7 @@ struct DotKeyword {
|
||||
{ ".IFNDEF", TOK_IFNDEF },
|
||||
{ ".IFNREF", TOK_IFNREF },
|
||||
{ ".IFP02", TOK_IFP02 },
|
||||
{ ".IFP02X", TOK_IFP02X },
|
||||
{ ".IFP4510", TOK_IFP4510 },
|
||||
{ ".IFP816", TOK_IFP816 },
|
||||
{ ".IFPC02", TOK_IFPC02 },
|
||||
@@ -257,6 +260,7 @@ struct DotKeyword {
|
||||
{ ".ORG", TOK_ORG },
|
||||
{ ".OUT", TOK_OUT },
|
||||
{ ".P02", TOK_P02 },
|
||||
{ ".P02X", TOK_P02X },
|
||||
{ ".P4510", TOK_P4510 },
|
||||
{ ".P816", TOK_P816 },
|
||||
{ ".PAGELEN", TOK_PAGELENGTH },
|
||||
@@ -306,6 +310,7 @@ struct DotKeyword {
|
||||
{ ".XMATCH", TOK_XMATCH },
|
||||
{ ".XOR", TOK_BOOLXOR },
|
||||
{ ".ZEROPAGE", TOK_ZEROPAGE },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@ typedef enum token_t {
|
||||
TOK_IFNDEF,
|
||||
TOK_IFNREF,
|
||||
TOK_IFP02,
|
||||
TOK_IFP02X,
|
||||
TOK_IFP4510,
|
||||
TOK_IFP816,
|
||||
TOK_IFPC02,
|
||||
@@ -226,6 +227,7 @@ typedef enum token_t {
|
||||
TOK_ORG,
|
||||
TOK_OUT,
|
||||
TOK_P02,
|
||||
TOK_P02X,
|
||||
TOK_P4510,
|
||||
TOK_P816,
|
||||
TOK_PAGELENGTH,
|
||||
|
||||
@@ -90,7 +90,9 @@ struct FuncInfo {
|
||||
** routines are marked to use only the A register. The remainder is ignored
|
||||
** anyway.
|
||||
*/
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const FuncInfo FuncInfoTable[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "addeq0sp", SLV_TOP | REG_AX, PSTATE_ALL | REG_AXY },
|
||||
{ "addeqysp", SLV_IND | REG_AXY, PSTATE_ALL | REG_AXY },
|
||||
{ "addysp", REG_SP | REG_Y, PSTATE_ALL | REG_SP },
|
||||
@@ -190,12 +192,12 @@ static const FuncInfo FuncInfoTable[] = {
|
||||
{ "ldeaxysp", SLV_IND | REG_Y, PSTATE_ALL | REG_EAXY },
|
||||
{ "leaa0sp", REG_SP | REG_A, PSTATE_ALL | REG_AX },
|
||||
{ "leaaxsp", REG_SP | REG_AX, PSTATE_ALL | REG_AX },
|
||||
{ "leave00", REG_SP, PSTATE_ALL | REG_SP | REG_AXY },
|
||||
{ "leave0", REG_SP, PSTATE_ALL | REG_SP | REG_XY },
|
||||
{ "leave", REG_SP, PSTATE_ALL | REG_SP | REG_Y },
|
||||
{ "leavey00", REG_SP, PSTATE_ALL | REG_SP | REG_AXY },
|
||||
{ "leavey0", REG_SP, PSTATE_ALL | REG_SP | REG_XY },
|
||||
{ "leave0", REG_SP, PSTATE_ALL | REG_SP | REG_XY },
|
||||
{ "leave00", REG_SP, PSTATE_ALL | REG_SP | REG_AXY },
|
||||
{ "leavey", REG_SP | REG_Y, PSTATE_ALL | REG_SP | REG_Y },
|
||||
{ "leavey0", REG_SP, PSTATE_ALL | REG_SP | REG_XY },
|
||||
{ "leavey00", REG_SP, PSTATE_ALL | REG_SP | REG_AXY },
|
||||
{ "lsubeq", REG_EAXY | REG_PTR1_LO, PSTATE_ALL | REG_EAXY | REG_PTR1_HI },
|
||||
{ "lsubeq0sp", SLV_TOP | REG_EAX, PSTATE_ALL | REG_EAXY },
|
||||
{ "lsubeq1", REG_Y | REG_PTR1_LO, PSTATE_ALL | REG_EAXY | REG_PTR1_HI },
|
||||
@@ -376,11 +378,14 @@ static const FuncInfo FuncInfoTable[] = {
|
||||
{ "tosxoreax", SLV_TOP | REG_EAX, PSTATE_ALL | REG_SP | REG_EAXY | REG_TMP1 },
|
||||
{ "tsteax", REG_EAX, PSTATE_ALL | REG_Y },
|
||||
{ "utsteax", REG_EAX, PSTATE_ALL | REG_Y },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
#define FuncInfoCount (sizeof(FuncInfoTable) / sizeof(FuncInfoTable[0]))
|
||||
|
||||
/* Table with names of zero page locations used by the compiler */
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const ZPInfo ZPInfoTable[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ 0, "ptr1", 2, REG_PTR1_LO, REG_PTR1 },
|
||||
{ 0, "ptr1+1", 1, REG_PTR1_HI, REG_PTR1 },
|
||||
{ 0, "ptr2", 2, REG_PTR2_LO, REG_PTR2 },
|
||||
@@ -398,6 +403,7 @@ static const ZPInfo ZPInfoTable[] = {
|
||||
{ 0, "tmp2", 1, REG_NONE, REG_NONE },
|
||||
{ 0, "tmp3", 1, REG_NONE, REG_NONE },
|
||||
{ 0, "tmp4", 1, REG_NONE, REG_NONE },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
#define ZPInfoCount (sizeof(ZPInfoTable) / sizeof(ZPInfoTable[0]))
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@ struct OptFunc {
|
||||
|
||||
|
||||
/* A list of all the function descriptions */
|
||||
/* CAUTION: should be sorted by "name" */
|
||||
/* BEGIN DECL SORTED_CODEOPT.SH */
|
||||
static OptFunc DOpt65C02BitOps = { Opt65C02BitOps, "Opt65C02BitOps", 66, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOpt65C02Ind = { Opt65C02Ind, "Opt65C02Ind", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOpt65C02Stores = { Opt65C02Stores, "Opt65C02Stores", 100, 0, 0, 0, 0, 0 };
|
||||
@@ -152,18 +154,13 @@ static OptFunc DOptJumpTarget3 = { OptJumpTarget3, "OptJumpTarget3", 100, 0,
|
||||
static OptFunc DOptLoad1 = { OptLoad1, "OptLoad1", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptLoad2 = { OptLoad2, "OptLoad2", 200, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptLoad3 = { OptLoad3, "OptLoad3", 0, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptLoadStoreLoad= { OptLoadStoreLoad,"OptLoadStoreLoad", 0, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptLongAssign = { OptLongAssign, "OptLongAssign", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptLongCopy = { OptLongCopy, "OptLongCopy", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptNegAX1 = { OptNegAX1, "OptNegAX1", 165, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptNegAX2 = { OptNegAX2, "OptNegAX2", 200, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPrecalc = { OptPrecalc, "OptPrecalc", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad1 = { OptPtrLoad1, "OptPtrLoad1", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad2 = { OptPtrLoad2, "OptPtrLoad2", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad3 = { OptPtrLoad3, "OptPtrLoad3", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad4 = { OptPtrLoad4, "OptPtrLoad4", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad5 = { OptPtrLoad5, "OptPtrLoad5", 50, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad6 = { OptPtrLoad6, "OptPtrLoad6", 60, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad7 = { OptPtrLoad7, "OptPtrLoad7", 140, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad11 = { OptPtrLoad11, "OptPtrLoad11", 92, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad12 = { OptPtrLoad12, "OptPtrLoad12", 50, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad13 = { OptPtrLoad13, "OptPtrLoad13", 65, 0, 0, 0, 0, 0 };
|
||||
@@ -173,6 +170,12 @@ static OptFunc DOptPtrLoad16 = { OptPtrLoad16, "OptPtrLoad16", 100, 0,
|
||||
static OptFunc DOptPtrLoad17 = { OptPtrLoad17, "OptPtrLoad17", 190, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad18 = { OptPtrLoad18, "OptPtrLoad18", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad19 = { OptPtrLoad19, "OptPtrLoad19", 65, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad2 = { OptPtrLoad2, "OptPtrLoad2", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad3 = { OptPtrLoad3, "OptPtrLoad3", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad4 = { OptPtrLoad4, "OptPtrLoad4", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad5 = { OptPtrLoad5, "OptPtrLoad5", 50, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad6 = { OptPtrLoad6, "OptPtrLoad6", 60, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrLoad7 = { OptPtrLoad7, "OptPtrLoad7", 140, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrStore1 = { OptPtrStore1, "OptPtrStore1", 65, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrStore2 = { OptPtrStore2, "OptPtrStore2", 65, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptPtrStore3 = { OptPtrStore3, "OptPtrStore3", 100, 0, 0, 0, 0, 0 };
|
||||
@@ -202,7 +205,6 @@ static OptFunc DOptStore3 = { OptStore3, "OptStore3", 120, 0,
|
||||
static OptFunc DOptStore4 = { OptStore4, "OptStore4", 50, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptStore5 = { OptStore5, "OptStore5", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptStoreLoad = { OptStoreLoad, "OptStoreLoad", 0, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptLoadStoreLoad= { OptLoadStoreLoad,"OptLoadStoreLoad", 0, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptSub1 = { OptSub1, "OptSub1", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptSub2 = { OptSub2, "OptSub2", 100, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptSub3 = { OptSub3, "OptSub3", 100, 0, 0, 0, 0, 0 };
|
||||
@@ -214,10 +216,13 @@ static OptFunc DOptTransfers3 = { OptTransfers3, "OptTransfers3", 65, 0,
|
||||
static OptFunc DOptTransfers4 = { OptTransfers4, "OptTransfers4", 65, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptUnusedLoads = { OptUnusedLoads, "OptUnusedLoads", 0, 0, 0, 0, 0, 0 };
|
||||
static OptFunc DOptUnusedStores = { OptUnusedStores, "OptUnusedStores", 0, 0, 0, 0, 0, 0 };
|
||||
/* END DECL SORTED_CODEOPT.SH */
|
||||
|
||||
|
||||
/* Table containing all the steps in alphabetical order */
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static OptFunc* OptFuncs[] = {
|
||||
/* BEGIN SORTED_CODEOPT.SH */
|
||||
&DOpt65C02BitOps,
|
||||
&DOpt65C02Ind,
|
||||
&DOpt65C02Stores,
|
||||
@@ -268,6 +273,7 @@ static OptFunc* OptFuncs[] = {
|
||||
&DOptLoad1,
|
||||
&DOptLoad2,
|
||||
&DOptLoad3,
|
||||
&DOptLoadStoreLoad,
|
||||
&DOptLongAssign,
|
||||
&DOptLongCopy,
|
||||
&DOptNegAX1,
|
||||
@@ -318,7 +324,6 @@ static OptFunc* OptFuncs[] = {
|
||||
&DOptStore4,
|
||||
&DOptStore5,
|
||||
&DOptStoreLoad,
|
||||
&DOptLoadStoreLoad,
|
||||
&DOptSub1,
|
||||
&DOptSub2,
|
||||
&DOptSub3,
|
||||
@@ -330,6 +335,7 @@ static OptFunc* OptFuncs[] = {
|
||||
&DOptTransfers4,
|
||||
&DOptUnusedLoads,
|
||||
&DOptUnusedStores,
|
||||
/* END SORTED_CODEOPT.SH */
|
||||
};
|
||||
#define OPTFUNC_COUNT (sizeof(OptFuncs) / sizeof(OptFuncs[0]))
|
||||
|
||||
|
||||
@@ -1225,6 +1225,12 @@ static int CmpHarmless (const void* Key, const void* Entry)
|
||||
}
|
||||
|
||||
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const char* const Tab[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
"_abs",
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
int HarmlessCall (const CodeEntry* E, int PushedBytes)
|
||||
/* Check if this is a call to a harmless subroutine that will not interrupt
|
||||
@@ -1252,10 +1258,6 @@ int HarmlessCall (const CodeEntry* E, int PushedBytes)
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
static const char* const Tab[] = {
|
||||
"_abs",
|
||||
};
|
||||
|
||||
void* R = bsearch (E->Arg,
|
||||
Tab,
|
||||
sizeof (Tab) / sizeof (Tab[0]),
|
||||
|
||||
@@ -496,6 +496,14 @@ void Compile (const char* FileName)
|
||||
while (PreprocessNextLine ())
|
||||
{ /* Nothing */ }
|
||||
|
||||
/* Output macros if requested by the user */
|
||||
if (DumpPredefMacros) {
|
||||
OutputPredefMacros ();
|
||||
}
|
||||
if (DumpUserMacros) {
|
||||
OutputUserMacros ();
|
||||
}
|
||||
|
||||
/* Close the output file */
|
||||
CloseOutputFile ();
|
||||
|
||||
|
||||
@@ -1464,7 +1464,9 @@ static unsigned Opt_a_tosxor (StackOpData* D)
|
||||
|
||||
/* The first column of these two tables must be sorted in lexical order */
|
||||
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const OptFuncDesc FuncTable[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "___bzero", Opt___bzero, REG_NONE, OP_X_ZERO | OP_A_KNOWN },
|
||||
{ "staspidx", Opt_staspidx, REG_NONE, OP_NONE },
|
||||
{ "staxspidx", Opt_staxspidx, REG_AX, OP_NONE },
|
||||
@@ -1485,9 +1487,12 @@ static const OptFuncDesc FuncTable[] = {
|
||||
{ "tosuleax", Opt_tosuleax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT },
|
||||
{ "tosultax", Opt_tosultax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT },
|
||||
{ "tosxorax", Opt_tosxorax, REG_NONE, OP_NONE },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const OptFuncDesc FuncRegATable[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "tosandax", Opt_a_tosand, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT },
|
||||
{ "toseqax", Opt_a_toseq, REG_NONE, OP_NONE },
|
||||
{ "tosgeax", Opt_a_tosuge, REG_NONE, OP_NONE },
|
||||
@@ -1503,6 +1508,7 @@ static const OptFuncDesc FuncRegATable[] = {
|
||||
{ "tosuleax", Opt_a_tosule, REG_NONE, OP_NONE },
|
||||
{ "tosultax", Opt_a_tosult, REG_NONE, OP_NONE },
|
||||
{ "tosxorax", Opt_a_tosxor, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
#define FUNC_COUNT(Table) (sizeof(Table) / sizeof(Table[0]))
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
/* common */
|
||||
#include "coll.h"
|
||||
#include "debugflag.h"
|
||||
#include "print.h"
|
||||
#include "strbuf.h"
|
||||
|
||||
@@ -183,11 +184,15 @@ static unsigned GetDiagnosticLineNum (void)
|
||||
|
||||
|
||||
|
||||
void Fatal (const char* Format, ...)
|
||||
void Fatal_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print a message about a fatal error and die */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s:%u: Fatal: ", GetDiagnosticFileName (), GetDiagnosticLineNum ());
|
||||
|
||||
va_start (ap, Format);
|
||||
@@ -203,11 +208,15 @@ void Fatal (const char* Format, ...)
|
||||
|
||||
|
||||
|
||||
void Internal (const char* Format, ...)
|
||||
void Internal_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print a message about an internal compiler error and die */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s:%u: Internal compiler error:\n",
|
||||
GetDiagnosticFileName (), GetDiagnosticLineNum ());
|
||||
|
||||
@@ -270,10 +279,15 @@ static void IntError (errcat_t EC, LineInfo* LI, const char* Msg, va_list ap)
|
||||
|
||||
|
||||
|
||||
void LIError (errcat_t EC, LineInfo* LI, const char* Format, ...)
|
||||
void LIError_ (const char *file, int line, errcat_t EC, LineInfo* LI, const char* Format, ...)
|
||||
/* Print an error message with the line info given explicitly */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntError (EC, LI, Format, ap);
|
||||
va_end (ap);
|
||||
@@ -281,10 +295,15 @@ void LIError (errcat_t EC, LineInfo* LI, const char* Format, ...)
|
||||
|
||||
|
||||
|
||||
void Error (const char* Format, ...)
|
||||
void Error_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print an error message */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntError (EC_PARSER, GetDiagnosticLI (), Format, ap);
|
||||
va_end (ap);
|
||||
@@ -292,10 +311,15 @@ void Error (const char* Format, ...)
|
||||
|
||||
|
||||
|
||||
void PPError (const char* Format, ...)
|
||||
void PPError_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print an error message. For use within the preprocessor */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntError (EC_PP, GetCurLineInfo (), Format, ap);
|
||||
va_end (ap);
|
||||
@@ -346,10 +370,15 @@ static void IntWarning (errcat_t EC, LineInfo* LI, const char* Msg, va_list ap)
|
||||
|
||||
|
||||
|
||||
void LIWarning (errcat_t EC, LineInfo* LI, const char* Format, ...)
|
||||
void LIWarning_ (const char *file, int line, errcat_t EC, LineInfo* LI, const char* Format, ...)
|
||||
/* Print a warning message with the line info given explicitly */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntWarning (EC, LI, Format, ap);
|
||||
va_end (ap);
|
||||
@@ -357,10 +386,15 @@ void LIWarning (errcat_t EC, LineInfo* LI, const char* Format, ...)
|
||||
|
||||
|
||||
|
||||
void Warning (const char* Format, ...)
|
||||
void Warning_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print a warning message */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntWarning (EC_PARSER, GetDiagnosticLI (), Format, ap);
|
||||
va_end (ap);
|
||||
@@ -368,10 +402,15 @@ void Warning (const char* Format, ...)
|
||||
|
||||
|
||||
|
||||
void PPWarning (const char* Format, ...)
|
||||
void PPWarning_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print a warning message. For use within the preprocessor */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntWarning (EC_PP, GetCurLineInfo (), Format, ap);
|
||||
va_end (ap);
|
||||
@@ -436,10 +475,15 @@ static void IntNote (const LineInfo* LI, const char* Msg, va_list ap)
|
||||
|
||||
|
||||
|
||||
void LINote (const LineInfo* LI, const char* Format, ...)
|
||||
void LINote_ (const char *file, int line, const LineInfo* LI, const char* Format, ...)
|
||||
/* Print a note message with the line info given explicitly */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntNote (LI, Format, ap);
|
||||
va_end (ap);
|
||||
@@ -447,10 +491,15 @@ void LINote (const LineInfo* LI, const char* Format, ...)
|
||||
|
||||
|
||||
|
||||
void Note (const char* Format, ...)
|
||||
void Note_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print a note message */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntNote (GetDiagnosticLI (), Format, ap);
|
||||
va_end (ap);
|
||||
@@ -458,10 +507,15 @@ void Note (const char* Format, ...)
|
||||
|
||||
|
||||
|
||||
void PPNote (const char* Format, ...)
|
||||
void PPNote_ (const char *file, int line, const char* Format, ...)
|
||||
/* Print a note message. For use within the preprocessor */
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (Debug) {
|
||||
fprintf(stderr, "[%s:%d] ", file, line);
|
||||
}
|
||||
|
||||
va_start (ap, Format);
|
||||
IntNote (GetDiagnosticLI (), Format, ap);
|
||||
va_end (ap);
|
||||
|
||||
@@ -103,28 +103,36 @@ struct StrBuf;
|
||||
void PrintFileInclusionInfo (const LineInfo* LI);
|
||||
/* Print hierarchy of file inclusion */
|
||||
|
||||
void Fatal (const char* Format, ...) attribute ((noreturn, format (printf, 1, 2)));
|
||||
void Fatal_ (const char *file, int line, const char* Format, ...) attribute ((noreturn, format (printf, 3, 4)));
|
||||
#define Fatal(...) Fatal_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a message about a fatal error and die */
|
||||
|
||||
void Internal (const char* Format, ...) attribute ((noreturn, format (printf, 1, 2)));
|
||||
void Internal_ (const char *file, int line, const char* Format, ...) attribute ((noreturn, format (printf, 3, 4)));
|
||||
#define Internal(...) Internal_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a message about an internal compiler error and die */
|
||||
|
||||
void Error (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
void Error_ (const char *file, int line, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
#define Error(...) Error_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print an error message */
|
||||
|
||||
void LIError (errcat_t EC, LineInfo* LI, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
void LIError_ (const char *file, int line, errcat_t EC, LineInfo* LI, const char* Format, ...) attribute ((format (printf, 5, 6)));
|
||||
#define LIError(...) LIError_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print an error message with the line info given explicitly */
|
||||
|
||||
void PPError (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
void PPError_ (const char *file, int line, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
#define PPError(...) PPError_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print an error message. For use within the preprocessor */
|
||||
|
||||
void Warning (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
void Warning_ (const char *file, int line, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
#define Warning(...) Warning_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a warning message */
|
||||
|
||||
void LIWarning (errcat_t EC, LineInfo* LI, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
void LIWarning_ (const char *file, int line, errcat_t EC, LineInfo* LI, const char* Format, ...) attribute ((format (printf, 5, 6)));
|
||||
#define LIWarning(...) LIWarning_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a warning message with the line info given explicitly */
|
||||
|
||||
void PPWarning (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
void PPWarning_ (const char *file, int line, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
#define PPWarning(...) PPWarning_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a warning message. For use within the preprocessor */
|
||||
|
||||
void UnreachableCodeWarning (void);
|
||||
@@ -140,13 +148,16 @@ IntStack* FindWarning (const char* Name);
|
||||
void ListWarnings (FILE* F);
|
||||
/* Print a list of warning types/names to the given file */
|
||||
|
||||
void Note (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
void Note_ (const char *file, int line, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
#define Note(...) Note_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a note message */
|
||||
|
||||
void LINote (const LineInfo* LI, const char* Format, ...) attribute ((format (printf, 2, 3)));
|
||||
void LINote_ (const char *file, int line, const LineInfo* LI, const char* Format, ...) attribute ((format (printf, 4, 5)));
|
||||
#define LINote(...) LINote_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a note message with the line info given explicitly */
|
||||
|
||||
void PPNote (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
void PPNote_ (const char *file, int line, const char* Format, ...) attribute ((format (printf, 3, 4)));
|
||||
#define PPNote(...) PPNote_(__FILE__, __LINE__, __VA_ARGS__)
|
||||
/* Print a note message. For use within the preprocessor */
|
||||
|
||||
unsigned GetTotalErrors (void);
|
||||
|
||||
@@ -44,12 +44,14 @@
|
||||
|
||||
|
||||
unsigned char AddSource = 0; /* Add source lines as comments */
|
||||
unsigned char AllowNewComments = 0; /* Allow new style comments in C89 mode */
|
||||
unsigned char AutoCDecl = 0; /* Make functions default to __cdecl__ */
|
||||
unsigned char DebugInfo = 0; /* Add debug info to the obj */
|
||||
unsigned char DumpPredefMacros = 0; /* Output predefined macros */
|
||||
unsigned char DumpUserMacros = 0; /* Output user macros */
|
||||
unsigned char PreprocessOnly = 0; /* Just preprocess the input */
|
||||
unsigned char DebugOptOutput = 0; /* Output debug stuff */
|
||||
unsigned RegisterSpace = 6; /* Space available for register vars */
|
||||
unsigned AllowNewComments = 0; /* Allow new style comments in C89 mode */
|
||||
|
||||
/* Stackable options */
|
||||
IntStack WritableStrings = INTSTACK(0); /* Literal strings are r/w */
|
||||
|
||||
@@ -52,12 +52,14 @@
|
||||
|
||||
/* Options */
|
||||
extern unsigned char AddSource; /* Add source lines as comments */
|
||||
extern unsigned char AllowNewComments; /* Allow new style comments in C89 mode */
|
||||
extern unsigned char AutoCDecl; /* Make functions default to __cdecl__ */
|
||||
extern unsigned char DebugInfo; /* Add debug info to the obj */
|
||||
extern unsigned char DumpPredefMacros; /* Output predefined macros */
|
||||
extern unsigned char DumpUserMacros; /* Output user macros */
|
||||
extern unsigned char PreprocessOnly; /* Just preprocess the input */
|
||||
extern unsigned char DebugOptOutput; /* Output debug stuff */
|
||||
extern unsigned RegisterSpace; /* Space available for register vars */
|
||||
extern unsigned AllowNewComments; /* Allow new style comments in C89 mode */
|
||||
|
||||
/* Stackable options */
|
||||
extern IntStack WritableStrings; /* Literal strings are r/w */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
/* */
|
||||
/* macrotab.h */
|
||||
/* */
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
/* cc65 */
|
||||
#include "error.h"
|
||||
#include "output.h"
|
||||
#include "preproc.h"
|
||||
#include "macrotab.h"
|
||||
|
||||
@@ -60,6 +61,70 @@ static Macro* MacroTab[MACRO_TAB_SIZE];
|
||||
/* The undefined macros list head */
|
||||
static Macro* UndefinedMacrosListHead;
|
||||
|
||||
/* Some defines for better readability when calling OutputMacros() */
|
||||
#define USER_MACROS 0
|
||||
#define PREDEF_MACROS 1
|
||||
#define NAME_ONLY 0
|
||||
#define FULL_DEFINITION 1
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* helpers */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
static void OutputMacro (const Macro* M, int Full)
|
||||
/* Output one macro. If Full is true, the replacement is also output. */
|
||||
{
|
||||
WriteOutput ("#define %s", M->Name);
|
||||
int ParamCount = M->ParamCount;
|
||||
if (M->ParamCount >= 0) {
|
||||
int I;
|
||||
if (M->Variadic) {
|
||||
CHECK (ParamCount > 0);
|
||||
--ParamCount;
|
||||
}
|
||||
WriteOutput ("(");
|
||||
for (I = 0; I < ParamCount; ++I) {
|
||||
const char* Name = CollConstAt (&M->Params, I);
|
||||
WriteOutput ("%s%s", (I == 0)? "" : ",", Name);
|
||||
}
|
||||
if (M->Variadic) {
|
||||
WriteOutput ("%s...", (ParamCount == 0)? "" : ",");
|
||||
}
|
||||
WriteOutput (")");
|
||||
}
|
||||
WriteOutput (" ");
|
||||
if (Full) {
|
||||
WriteOutput ("%.*s",
|
||||
SB_GetLen (&M->Replacement),
|
||||
SB_GetConstBuf (&M->Replacement));
|
||||
}
|
||||
WriteOutput ("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void OutputMacros (int Predefined, int Full)
|
||||
/* Output macros to the output file depending on the flags given. */
|
||||
{
|
||||
/* Note: The Full flag is currently not used by any callers but is left in
|
||||
** place for possible future changes.
|
||||
*/
|
||||
unsigned I;
|
||||
for (I = 0; I < MACRO_TAB_SIZE; ++I) {
|
||||
const Macro* M = MacroTab [I];
|
||||
while (M) {
|
||||
if ((Predefined != 0) == (M->Predefined != 0)) {
|
||||
OutputMacro (M, Full);
|
||||
}
|
||||
M = M->Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -68,7 +133,7 @@ static Macro* UndefinedMacrosListHead;
|
||||
|
||||
|
||||
|
||||
Macro* NewMacro (const char* Name)
|
||||
Macro* NewMacro (const char* Name, unsigned char Predefined)
|
||||
/* Allocate a macro structure with the given name. The structure is not
|
||||
** inserted into the macro table.
|
||||
*/
|
||||
@@ -84,6 +149,7 @@ Macro* NewMacro (const char* Name)
|
||||
M->ParamCount = -1; /* Flag: Not a function-like macro */
|
||||
InitCollection (&M->Params);
|
||||
SB_Init (&M->Replacement);
|
||||
M->Predefined = Predefined;
|
||||
M->Variadic = 0;
|
||||
memcpy (M->Name, Name, Len+1);
|
||||
|
||||
@@ -116,7 +182,7 @@ Macro* CloneMacro (const Macro* M)
|
||||
** Use FreeMacro for that.
|
||||
*/
|
||||
{
|
||||
Macro* New = NewMacro (M->Name);
|
||||
Macro* New = NewMacro (M->Name, M->Predefined);
|
||||
unsigned I;
|
||||
|
||||
for (I = 0; I < CollCount (&M->Params); ++I) {
|
||||
@@ -134,7 +200,7 @@ Macro* CloneMacro (const Macro* M)
|
||||
|
||||
|
||||
void DefineNumericMacro (const char* Name, long Val)
|
||||
/* Define a macro for a numeric constant */
|
||||
/* Define a predefined macro for a numeric constant */
|
||||
{
|
||||
char Buf[64];
|
||||
|
||||
@@ -148,10 +214,10 @@ void DefineNumericMacro (const char* Name, long Val)
|
||||
|
||||
|
||||
void DefineTextMacro (const char* Name, const char* Val)
|
||||
/* Define a macro for a textual constant */
|
||||
/* Define a predefined macro for a textual constant */
|
||||
{
|
||||
/* Create a new macro */
|
||||
Macro* M = NewMacro (Name);
|
||||
Macro* M = NewMacro (Name, 1);
|
||||
|
||||
/* Set the value as replacement text */
|
||||
SB_CopyStr (&M->Replacement, Val);
|
||||
@@ -350,3 +416,19 @@ void PrintMacroStats (FILE* F)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OutputPredefMacros (void)
|
||||
/* Output all predefined macros to the output file */
|
||||
{
|
||||
OutputMacros (PREDEF_MACROS, FULL_DEFINITION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OutputUserMacros (void)
|
||||
/* Output all user defined macros to the output file */
|
||||
{
|
||||
OutputMacros (USER_MACROS, FULL_DEFINITION);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ struct Macro {
|
||||
int ParamCount; /* Number of parameters, -1 = no parens */
|
||||
Collection Params; /* Parameter list (char*) */
|
||||
StrBuf Replacement; /* Replacement text */
|
||||
unsigned char Predefined; /* True if this is a predefined macro */
|
||||
unsigned char Variadic; /* C99 variadic macro */
|
||||
char Name[1]; /* Name, dynamically allocated */
|
||||
};
|
||||
@@ -70,7 +71,7 @@ struct Macro {
|
||||
|
||||
|
||||
|
||||
Macro* NewMacro (const char* Name);
|
||||
Macro* NewMacro (const char* Name, unsigned char Predefined);
|
||||
/* Allocate a macro structure with the given name. The structure is not
|
||||
** inserted into the macro table.
|
||||
*/
|
||||
@@ -87,10 +88,10 @@ Macro* CloneMacro (const Macro* M);
|
||||
*/
|
||||
|
||||
void DefineNumericMacro (const char* Name, long Val);
|
||||
/* Define a macro for a numeric constant */
|
||||
/* Define a predefined macro for a numeric constant */
|
||||
|
||||
void DefineTextMacro (const char* Name, const char* Val);
|
||||
/* Define a macro for a textual constant */
|
||||
/* Define a predefined macro for a textual constant */
|
||||
|
||||
void InsertMacro (Macro* M);
|
||||
/* Insert the given macro into the macro table. */
|
||||
@@ -132,6 +133,12 @@ int MacroCmp (const Macro* M1, const Macro* M2);
|
||||
void PrintMacroStats (FILE* F);
|
||||
/* Print macro statistics to the given text file. */
|
||||
|
||||
void OutputPredefMacros (void);
|
||||
/* Output all predefined macros to the output file */
|
||||
|
||||
void OutputUserMacros (void);
|
||||
/* Output all user defined macros to the output file */
|
||||
|
||||
|
||||
|
||||
/* End of macrotab.h */
|
||||
|
||||
115
src/cc65/main.c
115
src/cc65/main.c
@@ -93,6 +93,8 @@ static void Usage (void)
|
||||
" -V\t\t\t\tPrint the compiler version number\n"
|
||||
" -W [-+]warning[,...]\t\tControl warnings ('-' disables, '+' enables)\n"
|
||||
" -d\t\t\t\tDebug mode\n"
|
||||
" -dM\t\t\t\tOutput all user macros (needs -E)\n"
|
||||
" -dP\t\t\t\tOutput all predefined macros (needs -E)\n"
|
||||
" -g\t\t\t\tAdd debug info to object file\n"
|
||||
" -h\t\t\t\tHelp (this text)\n"
|
||||
" -j\t\t\t\tDefault characters are signed\n"
|
||||
@@ -307,6 +309,10 @@ static void SetSys (const char* Sys)
|
||||
DefineNumericMacro ("__RP6502__", 1);
|
||||
break;
|
||||
|
||||
case TGT_AGAT:
|
||||
DefineNumericMacro ("__AGAT__", 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
AbEnd ("Unknown target system '%s'", Sys);
|
||||
}
|
||||
@@ -317,6 +323,81 @@ static void SetSys (const char* Sys)
|
||||
|
||||
|
||||
|
||||
static void DefineCpuMacros (void)
|
||||
/* Define macros for the target CPU */
|
||||
{
|
||||
const char* CPUName;
|
||||
|
||||
/* Note: The list of CPUs handled here must match the one checked in
|
||||
** OptCPU().
|
||||
*/
|
||||
switch (CPU) {
|
||||
|
||||
/* The following ones are legal CPUs as far as the assembler is
|
||||
** concerned but are ruled out earlier in the compiler, so this
|
||||
** function should never see them.
|
||||
*/
|
||||
case CPU_NONE:
|
||||
case CPU_SWEET16:
|
||||
case CPU_M740:
|
||||
case CPU_4510:
|
||||
case CPU_UNKNOWN:
|
||||
CPUName = (CPU == CPU_UNKNOWN)? "unknown" : CPUNames[CPU];
|
||||
Internal ("Invalid CPU \"%s\"", CPUName);
|
||||
break;
|
||||
|
||||
case CPU_6502:
|
||||
DefineNumericMacro ("__CPU_6502__", 1);
|
||||
break;
|
||||
|
||||
case CPU_6502X:
|
||||
DefineNumericMacro ("__CPU_6502X__", 1);
|
||||
break;
|
||||
|
||||
case CPU_6502DTV:
|
||||
DefineNumericMacro ("__CPU_6502DTV__", 1);
|
||||
break;
|
||||
|
||||
case CPU_65SC02:
|
||||
DefineNumericMacro ("__CPU_65SC02__", 1);
|
||||
break;
|
||||
|
||||
case CPU_65C02:
|
||||
DefineNumericMacro ("__CPU_65C02__", 1);
|
||||
break;
|
||||
|
||||
case CPU_65816:
|
||||
DefineNumericMacro ("__CPU_65816__", 1);
|
||||
break;
|
||||
|
||||
case CPU_HUC6280:
|
||||
DefineNumericMacro ("__CPU_HUC6280__", 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
FAIL ("Unexpected value in switch");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Define the macros for instruction sets. We only include the ones for
|
||||
** the available CPUs.
|
||||
*/
|
||||
DefineNumericMacro ("__CPU_ISET_6502__", CPU_ISET_6502);
|
||||
DefineNumericMacro ("__CPU_ISET_6502X__", CPU_ISET_6502X);
|
||||
DefineNumericMacro ("__CPU_ISET_6502DTV__", CPU_ISET_6502DTV);
|
||||
DefineNumericMacro ("__CPU_ISET_65SC02__", CPU_ISET_65SC02);
|
||||
DefineNumericMacro ("__CPU_ISET_65C02__", CPU_ISET_65C02);
|
||||
DefineNumericMacro ("__CPU_ISET_65816__", CPU_ISET_65816);
|
||||
DefineNumericMacro ("__CPU_ISET_HUC6280__", CPU_ISET_HUC6280);
|
||||
|
||||
/* Now define the macro that contains the bit set with the available
|
||||
** cpu instructions.
|
||||
*/
|
||||
DefineNumericMacro ("__CPU__", CPUIsets[CPU]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void FileNameOption (const char* Opt, const char* Arg, StrBuf* Name)
|
||||
/* Handle an option that remembers a file name for later */
|
||||
{
|
||||
@@ -477,7 +558,9 @@ static void OptCreateFullDep (const char* Opt attribute ((unused)),
|
||||
static void OptCPU (const char* Opt, const char* Arg)
|
||||
/* Handle the --cpu option */
|
||||
{
|
||||
/* Find the CPU from the given name */
|
||||
/* Find the CPU from the given name. We do only accept a certain number
|
||||
** of CPUs. If the list is changed, be sure to adjust SetCpuMacros().
|
||||
*/
|
||||
CPU = FindCPU (Arg);
|
||||
if (CPU != CPU_6502 && CPU != CPU_6502X && CPU != CPU_65SC02 &&
|
||||
CPU != CPU_65C02 && CPU != CPU_65816 && CPU != CPU_HUC6280 &&
|
||||
@@ -945,7 +1028,25 @@ int main (int argc, char* argv[])
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
OptDebug (Arg, 0);
|
||||
P = Arg + 2;
|
||||
if (*P == '\0') {
|
||||
OptDebug (Arg, 0);
|
||||
} else {
|
||||
while (*P) {
|
||||
switch (*P) {
|
||||
case 'M':
|
||||
DumpUserMacros = 1;
|
||||
break;
|
||||
case 'P':
|
||||
DumpPredefMacros = 1;
|
||||
break;
|
||||
default:
|
||||
UnknownOption (Arg);
|
||||
break;
|
||||
}
|
||||
++P;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
@@ -1057,13 +1158,20 @@ int main (int argc, char* argv[])
|
||||
AbEnd ("No input files");
|
||||
}
|
||||
|
||||
/* The options to output macros can only be used with -E */
|
||||
if ((DumpPredefMacros || DumpUserMacros) && !PreprocessOnly) {
|
||||
AbEnd ("Preprocessor macro output can only be used together with -E");
|
||||
}
|
||||
|
||||
/* Add the default include search paths. */
|
||||
FinishIncludePaths ();
|
||||
|
||||
/* Create the output file name if it was not explicitly given */
|
||||
MakeDefaultOutputName (InputFile);
|
||||
|
||||
/* If no CPU given, use the default CPU for the target */
|
||||
/* If no CPU given, use the default CPU for the target. Define macros that
|
||||
** allow to query the CPU.
|
||||
*/
|
||||
if (CPU == CPU_UNKNOWN) {
|
||||
if (Target != TGT_UNKNOWN) {
|
||||
CPU = GetTargetProperties (Target)->DefaultCPU;
|
||||
@@ -1071,6 +1179,7 @@ int main (int argc, char* argv[])
|
||||
CPU = CPU_6502;
|
||||
}
|
||||
}
|
||||
DefineCpuMacros ();
|
||||
|
||||
/* If no memory model was given, use the default */
|
||||
if (MemoryModel == MMODEL_UNKNOWN) {
|
||||
|
||||
@@ -55,9 +55,12 @@
|
||||
|
||||
|
||||
/* Opcode description table */
|
||||
/* CAUTION: table must be sorted by mnemonic for bsearch */
|
||||
const OPCDesc OPCTable[OP65_COUNT] = {
|
||||
|
||||
/* 65XX opcodes */
|
||||
|
||||
/* BEGIN SORTED_OPCODES.SH */
|
||||
{ OP65_ADC, /* opcode */
|
||||
"adc", /* mnemonic */
|
||||
0, /* size */
|
||||
@@ -586,6 +589,7 @@ const OPCDesc OPCTable[OP65_COUNT] = {
|
||||
REG_Y, /* use */
|
||||
REG_A | PSTATE_ZN /* chg */
|
||||
},
|
||||
/* END SORTED_OPCODES.SH */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -89,10 +89,12 @@ typedef enum {
|
||||
} pragma_t;
|
||||
|
||||
/* Pragma table */
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const struct Pragma {
|
||||
const char* Key; /* Keyword */
|
||||
pragma_t Tok; /* Token */
|
||||
} Pragmas[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "align", PRAGMA_ALIGN },
|
||||
{ "allow-eager-inline", PRAGMA_ALLOW_EAGER_INLINE },
|
||||
{ "allow_eager_inline", PRAGMA_ALLOW_EAGER_INLINE },
|
||||
@@ -127,6 +129,7 @@ static const struct Pragma {
|
||||
{ "writable-strings", PRAGMA_WRITABLE_STRINGS },
|
||||
{ "writable_strings", PRAGMA_WRITABLE_STRINGS },
|
||||
{ "zpsym", PRAGMA_ZPSYM },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
#define PRAGMA_COUNT (sizeof (Pragmas) / sizeof (Pragmas[0]))
|
||||
|
||||
@@ -433,12 +436,7 @@ static void ApplySegNamePragma (pragma_t Token, int PushPop, const char* Name, u
|
||||
SetSegAddrSize (Name, AddrSize);
|
||||
}
|
||||
|
||||
/* BSS variables are output at the end of the compilation. Don't
|
||||
** bother to change their segment, now.
|
||||
*/
|
||||
if (Seg != SEG_BSS) {
|
||||
g_segname (Seg);
|
||||
}
|
||||
g_segname (Seg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -216,10 +216,12 @@ typedef enum {
|
||||
|
||||
|
||||
/* Preprocessor directive tokens mapping table */
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const struct PPDType {
|
||||
const char* Tok; /* Token */
|
||||
ppdirective_t Type; /* Type */
|
||||
} PPDTypes[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "define", PPD_DEFINE },
|
||||
{ "elif", PPD_ELIF },
|
||||
{ "else", PPD_ELSE },
|
||||
@@ -233,6 +235,7 @@ static const struct PPDType {
|
||||
{ "pragma", PPD_PRAGMA },
|
||||
{ "undef", PPD_UNDEF },
|
||||
{ "warning", PPD_WARNING },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
/* Number of preprocessor directive types */
|
||||
@@ -2572,7 +2575,7 @@ static void DoDefine (void)
|
||||
CheckForBadIdent (Ident, Std, 0);
|
||||
|
||||
/* Create a new macro definition */
|
||||
M = NewMacro (Ident);
|
||||
M = NewMacro (Ident, 0);
|
||||
|
||||
/* Check if this is a function-like macro */
|
||||
if (CurC == '(') {
|
||||
|
||||
@@ -87,11 +87,13 @@ enum {
|
||||
};
|
||||
|
||||
/* Token table */
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const struct Keyword {
|
||||
char* Key; /* Keyword name */
|
||||
unsigned char Tok; /* The token */
|
||||
unsigned char Std; /* Token supported in which standards? */
|
||||
} Keywords [] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "_Pragma", TOK_PRAGMA, TT_C89 | TT_C99 | TT_CC65 }, /* !! */
|
||||
{ "_Static_assert", TOK_STATIC_ASSERT, TT_CC65 }, /* C11 */
|
||||
{ "__AX__", TOK_AX, TT_C89 | TT_C99 | TT_CC65 },
|
||||
@@ -145,6 +147,7 @@ static const struct Keyword {
|
||||
{ "void", TOK_VOID, TT_C89 | TT_C99 | TT_CC65 },
|
||||
{ "volatile", TOK_VOLATILE, TT_C89 | TT_C99 | TT_CC65 },
|
||||
{ "while", TOK_WHILE, TT_C89 | TT_C99 | TT_CC65 },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
#define KEY_COUNT (sizeof (Keywords) / sizeof (Keywords [0]))
|
||||
|
||||
|
||||
@@ -78,19 +78,20 @@ static void StdFunc_strlen (FuncDesc*, ExprDesc*);
|
||||
|
||||
|
||||
|
||||
/* Table with all known functions and their handlers. Must be sorted
|
||||
** alphabetically!
|
||||
/* Table with all known functions and their handlers.
|
||||
** CAUTION: table must be alphabetically sorted for bsearch
|
||||
*/
|
||||
static struct StdFuncDesc {
|
||||
const char* Name;
|
||||
void (*Handler) (FuncDesc*, ExprDesc*);
|
||||
} StdFuncs[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "memcpy", StdFunc_memcpy },
|
||||
{ "memset", StdFunc_memset },
|
||||
{ "strcmp", StdFunc_strcmp },
|
||||
{ "strcpy", StdFunc_strcpy },
|
||||
{ "strlen", StdFunc_strlen },
|
||||
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
#define FUNC_COUNT (sizeof (StdFuncs) / sizeof (StdFuncs[0]))
|
||||
|
||||
|
||||
@@ -122,6 +122,11 @@ static int DoAssemble = 1;
|
||||
/* The name of the output file, NULL if none given */
|
||||
static const char* OutputName = 0;
|
||||
|
||||
/* The path part of the output file, NULL if none given
|
||||
** or the OutputName is just a filename with no path
|
||||
** information. */
|
||||
static char *OutputDirectory = 0;
|
||||
|
||||
/* The name of the linker configuration file if given */
|
||||
static const char* LinkerConfig = 0;
|
||||
|
||||
@@ -555,7 +560,7 @@ static void AssembleFile (const char* File, const char* TmpFile, unsigned ArgCou
|
||||
if (TmpFile) {
|
||||
ObjName = MakeFilename (TmpFile, ".o");
|
||||
} else {
|
||||
ObjName = MakeTmpFilename (".o");
|
||||
ObjName = MakeTmpFilename (OutputDirectory, File, ".o");
|
||||
}
|
||||
CmdSetOutput (&CA65, ObjName);
|
||||
CmdAddFile (&LD65, ObjName);
|
||||
@@ -684,7 +689,7 @@ static void Compile (const char* File)
|
||||
|
||||
if (DoAssemble) {
|
||||
/* set a temporary output file name */
|
||||
TmpFile = MakeTmpFilename(".s");
|
||||
TmpFile = MakeTmpFilename(OutputDirectory, File, ".s");
|
||||
CmdSetOutput (&CC65, TmpFile);
|
||||
}
|
||||
|
||||
@@ -729,7 +734,7 @@ static void CompileRes (const char* File)
|
||||
** BEFORE adding the file
|
||||
*/
|
||||
if (DoAssemble && DoLink) {
|
||||
AsmName = MakeTmpFilename(".s");
|
||||
AsmName = MakeTmpFilename(OutputDirectory, File, ".s");
|
||||
CmdSetAsmOutput(&GRC, AsmName);
|
||||
}
|
||||
|
||||
@@ -1623,6 +1628,7 @@ int main (int argc, char* argv [])
|
||||
case 'o':
|
||||
/* Name the output file */
|
||||
OutputName = GetArg (&I, 2);
|
||||
OutputDirectory = GetFileDirectory(OutputName);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
@@ -1713,6 +1719,9 @@ int main (int argc, char* argv [])
|
||||
}
|
||||
|
||||
RemoveTempFiles ();
|
||||
if (OutputDirectory != NULL) {
|
||||
xfree(OutputDirectory);
|
||||
}
|
||||
|
||||
/* Return an apropriate exit code */
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -48,8 +48,10 @@
|
||||
|
||||
|
||||
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static const FileId TypeTable[] = {
|
||||
/* Upper case stuff for obsolete operating systems */
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "A", FILETYPE_LIB },
|
||||
{ "A65", FILETYPE_ASM },
|
||||
{ "ASM", FILETYPE_ASM },
|
||||
@@ -65,7 +67,6 @@ static const FileId TypeTable[] = {
|
||||
{ "S", FILETYPE_ASM },
|
||||
{ "SER", FILETYPE_O65 },
|
||||
{ "TGI", FILETYPE_O65 },
|
||||
|
||||
{ "a", FILETYPE_LIB },
|
||||
{ "a65", FILETYPE_ASM },
|
||||
{ "asm", FILETYPE_ASM },
|
||||
@@ -81,6 +82,7 @@ static const FileId TypeTable[] = {
|
||||
{ "s", FILETYPE_ASM },
|
||||
{ "ser", FILETYPE_O65 },
|
||||
{ "tgi", FILETYPE_O65 },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
#define FILETYPE_COUNT (sizeof (TypeTable) / sizeof (TypeTable[0]))
|
||||
|
||||
@@ -33,8 +33,17 @@
|
||||
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <process.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "fname.h"
|
||||
@@ -93,7 +102,28 @@ const char* FindName (const char* Path)
|
||||
return Path + Len;
|
||||
}
|
||||
|
||||
char *GetFileDirectory (const char* File)
|
||||
/* Return a copy of the path part of a File, or NULL if there is none. */
|
||||
{
|
||||
char *Out, *P;
|
||||
|
||||
if (File == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Out = xmalloc (strlen (File) + 1);
|
||||
strcpy(Out, File);
|
||||
|
||||
P = (char *)FindName (Out);
|
||||
if (P == Out) {
|
||||
/* This is a simple filename. */
|
||||
xfree (Out);
|
||||
return NULL;
|
||||
}
|
||||
*P = '\0';
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
char* MakeFilename (const char* Origin, const char* Ext)
|
||||
/* Make a new file name from Origin and Ext. If Origin has an extension, it
|
||||
@@ -119,35 +149,29 @@ char* MakeFilename (const char* Origin, const char* Ext)
|
||||
|
||||
|
||||
|
||||
char* MakeTmpFilename (const char* Ext)
|
||||
/* Make a new temporary file name from Ext. tmpnam(3) is called
|
||||
** and Ext is appended to generate the filename.
|
||||
char* MakeTmpFilename (const char *Directory, const char *Origin, const char* Ext)
|
||||
/* Make a new temporary file name from Origin and Ext.
|
||||
** The result is placed in a malloc'ed buffer and returned.
|
||||
*/
|
||||
{
|
||||
char* Out;
|
||||
char Buffer[L_tmpnam * 2]; /* a lazy way to ensure we have space for Ext */
|
||||
size_t Len = 0;
|
||||
static unsigned int Counter = 0;
|
||||
|
||||
/*
|
||||
** gcc emits the following warning here:
|
||||
**
|
||||
** warning: the use of `tmpnam' is dangerous, better use `mkstemp'
|
||||
**
|
||||
** however, mkstemp actually opens a file, which we do not want.
|
||||
** tmpfile() is unsuitable for the same reason.
|
||||
**
|
||||
** we could write our own version, but then we would have to struggle
|
||||
** with supporting multiple build environments.
|
||||
**
|
||||
** tmpnam(3) is safe here, because ca65 / cc65 / ld65 will simply clobber
|
||||
** an existing file, or exit if with an error if they are unable to.
|
||||
**
|
||||
** gcc will also complain, if you don't use the return value from tmpnam(3)
|
||||
*/
|
||||
strcat(tmpnam(Buffer), Ext);
|
||||
/* Allocate enough for the directory, ... */
|
||||
if (Directory != NULL) {
|
||||
Len = strlen (Directory);
|
||||
}
|
||||
|
||||
Out = xmalloc (strlen (Buffer) + 1);
|
||||
strcpy (Out, Buffer);
|
||||
/* ... plus the the original name, the maximum length of the PID, the
|
||||
* maximum length of the counter, the extension, and the terminator.
|
||||
*/
|
||||
Len += strlen (Origin) + (strlen (".2147483648") * 2) + strlen (Ext) + 1;
|
||||
Out = xmalloc (Len);
|
||||
|
||||
snprintf (Out, Len, "%s%s.%u.%u%s", (Directory != NULL ? Directory : ""),
|
||||
FindName(Origin), getpid(), Counter, Ext);
|
||||
Counter++;
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ const char* FindName (const char* Path);
|
||||
** the file, the function returns Path as name.
|
||||
*/
|
||||
|
||||
char *GetFileDirectory (const char* File);
|
||||
/* Return a copy of the path part of a File, or NULL if there is none. */
|
||||
|
||||
char* MakeFilename (const char* Origin, const char* Ext);
|
||||
/* Make a new file name from Origin and Ext. If Origin has an extension, it
|
||||
** is removed and Ext is appended. If Origin has no extension, Ext is simply
|
||||
@@ -59,9 +62,10 @@ char* MakeFilename (const char* Origin, const char* Ext);
|
||||
** The function may be used to create "foo.o" from "foo.s".
|
||||
*/
|
||||
|
||||
char* MakeTmpFilename (const char* Ext);
|
||||
/* Make a new temporary file name from Ext. tmpnam(3) is called
|
||||
** and Ext is appended to generate the filename.
|
||||
char* MakeTmpFilename (const char *Directory, const char *Origin, const char* Ext);
|
||||
/* Make a new temporary file name from Directory, Origin, and Ext.
|
||||
** A temporary path is generated from the Directory,
|
||||
** the Origin filename, the compiler's PID and the Extension.
|
||||
** The result is placed in a malloc'ed buffer and returned.
|
||||
*/
|
||||
|
||||
|
||||
@@ -129,7 +129,25 @@ static const unsigned char CTPET[256] = {
|
||||
0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
|
||||
};
|
||||
|
||||
|
||||
/* Translation table KOI8-R -> Agat-9 */
|
||||
static unsigned char CTAgat[256] = {
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
|
||||
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
|
||||
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
|
||||
0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
|
||||
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
|
||||
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
|
||||
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
|
||||
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0xA0,
|
||||
0x1B,0x5C,0x10,0x12,0x1D,0x1F,0x13,0x1C,0x11,0x1E,0x14,0xA0,0x02,0x5F,0xA0,0xA0,
|
||||
0xA0,0xA0,0xA0,0xA0,0xA0,0x9E,0x04,0xA0,0x3C,0x3E,0xA0,0xA0,0x30,0x32,0xA0,0x2F,
|
||||
0xA0,0xA0,0xA0,0x0F,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,
|
||||
0xA0,0xA0,0xA0,0x9F,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,
|
||||
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
|
||||
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
|
||||
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
|
||||
0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
|
||||
};
|
||||
|
||||
/* One entry in the target map */
|
||||
typedef struct TargetEntry TargetEntry;
|
||||
@@ -138,10 +156,13 @@ struct TargetEntry {
|
||||
target_t Id; /* Target ID */
|
||||
};
|
||||
|
||||
/* Table that maps target names to IDs. Sorted alphabetically for bsearch().
|
||||
/* Table that maps target names to IDs.
|
||||
** Allows multiple entries for one target ID (target name aliases).
|
||||
** CAUTION: must be alphabetically for bsearch().
|
||||
*/
|
||||
static const TargetEntry TargetMap[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "agat", TGT_AGAT },
|
||||
{ "apple2", TGT_APPLE2 },
|
||||
{ "apple2enh", TGT_APPLE2ENH },
|
||||
{ "atari", TGT_ATARI },
|
||||
@@ -180,6 +201,7 @@ static const TargetEntry TargetMap[] = {
|
||||
{ "sym1", TGT_SYM1 },
|
||||
{ "telestrat", TGT_TELESTRAT },
|
||||
{ "vic20", TGT_VIC20 },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
#define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0]))
|
||||
|
||||
@@ -223,6 +245,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = {
|
||||
{ "sym1", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "kim1", CPU_6502, BINFMT_BINARY, CTNone },
|
||||
{ "rp6502", CPU_65C02, BINFMT_BINARY, CTNone },
|
||||
{ "agat", CPU_6502, BINFMT_BINARY, CTAgat },
|
||||
};
|
||||
|
||||
/* Target system */
|
||||
|
||||
@@ -89,6 +89,7 @@ typedef enum {
|
||||
TGT_SYM1,
|
||||
TGT_KIM1,
|
||||
TGT_RP6502,
|
||||
TGT_AGAT,
|
||||
TGT_COUNT /* Number of target systems */
|
||||
} target_t;
|
||||
|
||||
|
||||
@@ -2523,6 +2523,7 @@ static void NextChar (InputData* D)
|
||||
|
||||
|
||||
|
||||
/* CAUTION: table must be sorted for bsearch */
|
||||
static void NextToken (InputData* D)
|
||||
/* Read the next token from the input stream */
|
||||
{
|
||||
@@ -2530,6 +2531,7 @@ static void NextToken (InputData* D)
|
||||
const char Keyword[12];
|
||||
Token Tok;
|
||||
} KeywordTable[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "abs", TOK_ABSOLUTE },
|
||||
{ "addrsize", TOK_ADDRSIZE },
|
||||
{ "auto", TOK_AUTO },
|
||||
@@ -2578,6 +2580,7 @@ static void NextToken (InputData* D)
|
||||
{ "var", TOK_VAR },
|
||||
{ "version", TOK_VERSION },
|
||||
{ "zp", TOK_ZEROPAGE },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -61,14 +61,17 @@ struct ConverterMapEntry {
|
||||
StrBuf* (*ConvertFunc) (const Bitmap*, const Collection*);
|
||||
};
|
||||
|
||||
/* Converter table, alphabetically sorted */
|
||||
/* Converter table */
|
||||
/* CAUTION: table must be alphabetically sorted for bsearch */
|
||||
static const ConverterMapEntry ConverterMap[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "geos-bitmap", GenGeosBitmap },
|
||||
{ "geos-icon", GenGeosIcon },
|
||||
{ "koala", GenKoala },
|
||||
{ "lynx-sprite", GenLynxSprite },
|
||||
{ "raw", GenRaw },
|
||||
{ "vic2-sprite", GenVic2Sprite },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -69,12 +69,14 @@ static InputFormatDesc InputFormatTable[ifCount] = {
|
||||
{ ReadPCXFile },
|
||||
};
|
||||
|
||||
/* Table that maps extensions to input formats. Must be sorted alphabetically */
|
||||
/* Table that maps extensions to input formats. */
|
||||
/* CAUTION: table must be alphabetically sorted for bsearch */
|
||||
static const FileId FormatTable[] = {
|
||||
/* Upper case stuff for obsolete operating systems */
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "PCX", ifPCX },
|
||||
|
||||
{ "pcx", ifPCX },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -78,22 +78,24 @@ static OutputFormatDesc OutputFormatTable[ofCount] = {
|
||||
{ WriteCFile },
|
||||
};
|
||||
|
||||
/* Table that maps extensions to Output formats. Must be sorted alphabetically */
|
||||
/* Table that maps extensions to Output formats. */
|
||||
/* CAUTION: table must be alphabetically sorted for bsearch */
|
||||
static const FileId FormatTable[] = {
|
||||
/* Upper case stuff for obsolete operating systems */
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "A", ofAsm },
|
||||
{ "ASM", ofAsm },
|
||||
{ "BIN", ofBin },
|
||||
{ "C", ofC },
|
||||
{ "INC", ofAsm },
|
||||
{ "S", ofAsm },
|
||||
|
||||
{ "a", ofAsm },
|
||||
{ "asm", ofAsm },
|
||||
{ "bin", ofBin },
|
||||
{ "c", ofC },
|
||||
{ "inc", ofAsm },
|
||||
{ "s", ofAsm },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -56,9 +56,12 @@ struct PaletteMapEntry {
|
||||
StrBuf* (*PaletteFunc) (const Bitmap*, const Collection*);
|
||||
};
|
||||
|
||||
/* Converter table, alphabetically sorted */
|
||||
/* Converter table */
|
||||
/* CAUTION: table must be alphabetically sorted for bsearch */
|
||||
static const PaletteMapEntry PaletteMap[] = {
|
||||
/* BEGIN SORTED.SH */
|
||||
{ "lynx-palette", GenLynxPalette },
|
||||
/* END SORTED.SH */
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user