From a98186c8f501c3cb86ecbfe55f9d9258199229f8 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 23 Jan 2016 18:38:39 -0800 Subject: [PATCH] Full header information extracted from gcc -aux-info --- actions.h | 29 +++++++++++++++ builtInFunctions.h | 63 +++++++++++++++++++++++++++++++ debugPrint.h | 86 +++++++++++++++++++++++++++++++++++++++++++ emitBranch.h | 7 ---- emitStuff.h | 27 ++++++++++++++ encode.h | 37 +++++++++++++++++++ errorStuff.h | 24 ++++++------ expressionSemantics.h | 7 ++-- fixups.h | 11 ++++++ garbage.h | 66 +++++++++++++++++++++++++++++++++ initialize.h | 21 +++++++++++ lexer.h | 56 ++++++++++++++-------------- listing.h | 15 +++----- lookups.h | 46 ++++++++++++----------- object.h | 37 +++++++++++++++++++ operandStuff.h | 4 +- parserMisc.h | 3 +- statementSemantics.h | 10 ++--- structSemantics.h | 12 ++++++ tokenStrings.h | 9 +++++ 20 files changed, 482 insertions(+), 88 deletions(-) create mode 100644 actions.h create mode 100644 builtInFunctions.h create mode 100644 debugPrint.h create mode 100644 emitStuff.h create mode 100644 encode.h create mode 100644 fixups.h create mode 100644 garbage.h create mode 100644 initialize.h create mode 100644 object.h create mode 100644 structSemantics.h create mode 100644 tokenStrings.h diff --git a/actions.h b/actions.h new file mode 100644 index 0000000..372ee76 --- /dev/null +++ b/actions.h @@ -0,0 +1,29 @@ +#ifndef ACTIONS_H_ +#define ACTIONS_H_ + +#include "macrossTypes.h" + +void actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsDir2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsDirX1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsImmDir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsImmDirX(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsImmDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +void actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); +bool isByte(int value); +bool isByteOffset(int value); +bool isWordOffset(int value); +bool isByteAddress(valueType *value); +bool isWord(int value); +bool byteCheck(int value); +bool wordCheck(int value); +bool isDefined(valueType *value); + +#endif diff --git a/builtInFunctions.h b/builtInFunctions.h new file mode 100644 index 0000000..a853083 --- /dev/null +++ b/builtInFunctions.h @@ -0,0 +1,63 @@ +#ifndef BUILT_IN_FUNCTIONS_H_ +#define BUILT_IN_FUNCTIONS_H_ + +#include "macrossTypes.h" + +/* Platform-independent */ +valueType *makeBooleanValue(int test); +valueType *makeFailureValue(void); +valueType *makeIntegerValue(int integer); +valueType *makeOperandValue(operandType *operand); +valueType *makeStringValue(stringType *string); +valueType *makeUndefinedValue(void); +valueType *addressModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *applyBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *arrayLengthBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *atasciiBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *atasciiColorBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *debugModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *debugModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *emitModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *emitModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isAbsoluteValueBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isBlockBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isBuiltInFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isConditionCodeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isDefinedBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isExternalBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isFieldBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isRelocatableValueBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isStringBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isStructBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isSymbolBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *listingOffBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *listingOnBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *makeArrayBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *nthCharBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *printfBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *strcatBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *strcmpBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *strcmplcBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *strlenBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *substrBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *symbolLookupBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *symbolDefineBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *symbolNameBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *symbolUsageBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *valueTypeBIF(operandListType *parameterList, fixupKindType kindOfFixup); + +/* 6502-specific */ +valueType *isARegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isDirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isImmediateModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isIndirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isPostIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isPreIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isXIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isXRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isYIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup); +valueType *isYRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup); + +#endif diff --git a/debugPrint.h b/debugPrint.h new file mode 100644 index 0000000..24af614 --- /dev/null +++ b/debugPrint.h @@ -0,0 +1,86 @@ +#ifndef DEBUG_PRINT_H_ +#define DEBUG_PRINT_H_ + +#include "macrossTypes.h" + +/* Platform-independent */ +void tab(void); +void printAssignmentKind(assignmentKindType assignmentKind); +void printExpressionKind(expressionTermKindType kind); +stringType *statementKindString(statementKindType kind); +void printStatementKind(statementKindType kind); +void printValue(valueType *value); +void printSymbol(symbolTableEntryType *symbol); +void printArgumentDefinitionList(argumentDefinitionListType *list); +void printBlock(blockType *block); +void printArrayTerm(arrayTermType *arrayTerm); +void printAssignmentTerm(binopTermType *assignmentTerm); +void printBinopTerm(binopTermType *binopTerm); +void printFunctionCall(functionCallTermType *functionCall); +void printHere(void); +void printIdentifier(symbolTableEntryType *identifier); +void printNumber(numberTermType number); +void printPostopTerm(postOpTermType *postopTerm); +void printPreopTerm(preOpTermType *preopTerm); +void printUnopTerm(unopTermType *unopTerm); +void printExpression(expressionType *expression); +void printExpressionList(expressionListType *expressionList); +void printIdentifierList(identifierListType *identifierList); +void printCase(caseType *aCase); +void printCaseList(caseListType *caseList); +void printMacro(macroTableEntryType *macroInstruction); +void printOpcode(opcodeTableEntryType *opcode); +void printOperandList(operandListType *operandList); +void printAlignStatement(alignStatementBodyType *alignStatement); +void printAssertStatement(assertStatementBodyType *assertStatement); +void printBlockStatement(blockStatementBodyType *blockStatement); +void printByteStatement(byteStatementBodyType *byteStatement); +void printConstrainStatement(constrainStatementBodyType *constrainStatement); +void printDbyteStatement(dbyteStatementBodyType *dbyteStatement); +void printDefineStatement(defineStatementBodyType *defineStatement); +void printDoUntilStatement(doUntilStatementBodyType *doUntilStatement); +void printDoWhileStatement(doWhileStatementBodyType *doWhileStatement); +void printExternStatement(externStatementBodyType *externStatement); +void printFreturnStatement(freturnStatementBodyType *freturnStatement); +void printFunctionStatement(functionStatementBodyType *functionStatement); +void printIfStatement(ifStatementBodyType *ifStatement); +void printIncludeStatement(includeStatementBodyType *includeStatement); +void printInstructionStatement(instructionStatementBodyType *instructionStatement); +void printLongStatement(longStatementBodyType *longStatement); +void printMacroStatement(macroStatementBodyType *macroStatement); +void printMdefineStatement(defineStatementBodyType *mdefineStatement); +void printMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement); +void printMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement); +void printMforStatement(mforStatementBodyType *mforStatement); +void printMifStatement(mifStatementBodyType *mifStatement); +void printMswitchStatement(mswitchStatementBodyType *mswitchStatement); +void printMvariableStatement(mvariableStatementBodyType *mvariableStatement); +void printMwhileStatement(mwhileStatementBodyType *mwhileStatement); +void printOrgStatement(orgStatementBodyType *orgStatement); +void printPerformStatement(performStatementBodyType *performStatement); +void printRelStatement(relStatementBodyType *relStatement); +void printStartStatement(startStatementBodyType *startStatement); +void printStringStatement(stringStatementBodyType *stringStatement); +void printStructStatement(structStatementBodyType *structStatement); +void printTargetStatement(targetStatementBodyType *targetStatement); +void printUndefineStatement(undefineStatementBodyType *undefineStatement); +void printVariableStatement(variableStatementBodyType *variableStatement); +void printWhileStatement(whileStatementBodyType *whileStatement); +void printWordStatement(wordStatementBodyType *wordStatement); +void printLabelList(labelListType *labelList); +void printStatementBody(statementKindType kind, statementBodyType body); +void printStatement(statementType *statement); +void printPendingFixupList(fixupListType *fixupList); +void printCreateFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup); +void printExpressionBuffer(void); +void printOneCodeBuffer(codeSegmentType *codeSegment, int bufferNum); +void printCodeBufferSection(codeRegionType *codeBufferSection); +void printCodeBuffers(void); + +/* Platform-specific */ +void printCondition(conditionType condition); +void printOperandKind(operandKindType kind); +void printToken(int token); +void printOperand(operandType *operand); + +#endif diff --git a/emitBranch.h b/emitBranch.h index f53d9c0..b85896d 100644 --- a/emitBranch.h +++ b/emitBranch.h @@ -3,14 +3,7 @@ #include "macrossTypes.h" -#if TARGET_CPU == CPU_6502 -void emitRelativeBranch(conditionType condition, valueType *target, valueType fixupLocation[COMPOUND_BRANCH_MAX]); -#elif TARGET_CPU == CPU_68000 void emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupLocation); -#else -#error Missing or invalid TARGET_CPU -#endif - simpleFixupListType *emitJump(valueType *target, simpleFixupListType *previousFixups); #endif diff --git a/emitStuff.h b/emitStuff.h new file mode 100644 index 0000000..2028c3a --- /dev/null +++ b/emitStuff.h @@ -0,0 +1,27 @@ +#ifndef EMIT_STUFF_H_ +#define EMIT_STUFF_H_ + +#include "macrossTypes.h" + +void incarnateCodeBuffer(int bufferNum, codeBufferKindType bufferKind); +void putByte(addressType address, byte byteValue); +void mapByte(int address, byte byteValue); +void emitByte(byte byteValue); +void emitWord(wordType wordValue); +void emitLong(longType longValue); +void emitByteValue(valueType *byteValue); +void emitString(stringType *string); +void emitWordValue(valueType *wordValue); +void emitLongValue(valueType *longValue); +void pokeByteValue(addressType location, valueType *value); +void pokeWordValue(addressType location, valueType *value); +void pokeLongValue(addressType location, valueType *value); +void pokeRelativeByteValue(addressType location, valueType *value); +void pokeRelativeWordValue(addressType location, valueType *value); +byte getByte(addressType address); +void emitRelativeByteOffset(valueType *target); +void emitRelativeWordOffset(valueType *target); +void fixupBranch(valueType *location, valueType target); +void fixupJump(simpleFixupListType *locations, valueType target); + +#endif diff --git a/encode.h b/encode.h new file mode 100644 index 0000000..51a9db9 --- /dev/null +++ b/encode.h @@ -0,0 +1,37 @@ +#ifndef ENCODE_H_ +#define ENCODE_H_ + +#include "macrossTypes.h" + +bool encodeByte(byte aByte); +bool encodeBigword(int bigword); +bool encodeAssignmentTerm(binopTermType *assignmentTerm); +bool encodeBinopTerm(binopTermType *binopTerm); +bool encodeCondition(conditionType condition); +int functionNumber(functionDefinitionType *function); +bool encodeFunctionCall(functionCallTermType *functionCall); +bool encodeHere(void); +bool encodeIdentifier(symbolTableEntryType *identifier); +bool encodeNumber(numberTermType number); +bool encodeRelocatableNumber(numberTermType number); +bool encodeOperand(operandType *operand); +bool encodePostopTerm(postOpTermType *postopTerm); +bool encodePreopTerm(preOpTermType *preopTerm); +bool encodeString(stringType *string); +bool encodeUnopTerm(unopTermType *unopTerm); +bool encodeValue(valueType *value); +bool encodeExpression(expressionType *expression); +bool encodeAssertStatement(assertStatementBodyType *assertStatement); +bool encodeFreturnStatement(freturnStatementBodyType *freturnStatement); +bool encodeMdefineStatement(defineStatementBodyType *mdefineStatement); +bool encodeMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement); +bool encodeMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement); +bool encodeMforStatement(mforStatementBodyType *mforStatement); +bool encodeMifStatement(mifStatementBodyType *mifStatement); +bool encodeMswitchStatement(mswitchStatementBodyType *mswitchStatement); +bool encodeMvariableStatement(mvariableStatementBodyType *mvariableStatement); +bool encodeMwhileStatement(mwhileStatementBodyType *mwhileStatement); +bool encodeStatement(statementType *statement); +bool encodeBlock(blockType *block); + +#endif diff --git a/errorStuff.h b/errorStuff.h index 4381169..8605c5f 100644 --- a/errorStuff.h +++ b/errorStuff.h @@ -1,16 +1,18 @@ #ifndef ERROR_STUFF_H_ #define ERROR_STUFF_H_ -void puntOnError (errorType theError, ...); -void printErrorMessage (errorType theError, va_list ap); -void error (errorType theError, ...); -void verror (errorType theError, va_list ap); -void warning (errorType theError, ...); -void fatalError (errorType theError, ...); -void fatalSystemError (errorType theError, ...); -void yyerror (char *s); -char *usageString (symbolUsageKindType usageKind); -char *valueKindString (valueKindType valueKind); -char *assignmentString (assignmentKindType assignment); +#include "macrossTypes.h" + +void puntOnError(errorType theError, ...); +void printErrorMessage(errorType theError, va_list ap); +void error(errorType theError, ...); +void verror(errorType theError, va_list ap); +void warning(errorType theError, ...); +void fatalError(errorType theError, ...); +void fatalSystemError(errorType theError, ...); +void yyerror(char *s); +char *usageString(symbolUsageKindType usageKind); +char *valueKindString(valueKindType valueKind); +char *assignmentString(assignmentKindType assignment); #endif diff --git a/expressionSemantics.h b/expressionSemantics.h index cd3edae..2137d13 100644 --- a/expressionSemantics.h +++ b/expressionSemantics.h @@ -1,11 +1,12 @@ #ifndef EXPRESSION_SEMANTICS_H_ #define EXPRESSION_SEMANTICS_H_ + #include "macrossTypes.h" anyOldThing *arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing); valueType *evaluateArrayTerm(arrayTermType *arrayTerm); valueType *evaluateAssignmentTerm(binopTermType *assignmentTerm, fixupKindType kindOfFixup); -valueType *evaluateBinopTerm(binopTermType *assignmentTerm, bool isTopLevel, fixupKindType kindOfFixup); +valueType *evaluateBinopTerm(binopTermType *binopTerm, bool isTopLevel, fixupKindType kindOfFixup); valueType *evaluateCondition(conditionType condition); valueType *evaluateBuiltInFunctionCall(symbolInContextType *workingContext, operandListType *parameters, fixupKindType kindOfFixup); valueType *evaluateFunctionCall(functionCallTermType *functionCall, fixupKindType kindOfFixup, bool isStandalone); @@ -15,8 +16,8 @@ valueType *evaluateNumber(numberTermType number); valueType *evaluatePostopTerm(postOpTermType *postopTerm); valueType *evaluatePreopTerm(preOpTermType *preopTerm); valueType *evaluateString(stringType *string); -valueType *evaluateUnopTerm(unopTermType* unopTerm, fixupKindType kindOfFixup); -valueType *evaluateExpressionInternally(expressionType *expression, bool isToplevel, fixupKindType kindOfFixup, bool isStandalone); +valueType *evaluateUnopTerm(unopTermType *unopTerm, fixupKindType kindOfFixup); +valueType *evaluateExpressionInternally(expressionType *expression, bool isTopLevel, fixupKindType kindOfFixup, bool isStandalone); valueType *evaluateExpression(expressionType *expression, fixupKindType kindOfFixup); void evaluateExpressionStandalone(expressionType *expression); valueType *evaluateDefineExpression(expressionType *expression); diff --git a/fixups.h b/fixups.h new file mode 100644 index 0000000..b01f5c5 --- /dev/null +++ b/fixups.h @@ -0,0 +1,11 @@ +#ifndef FIXUPS_H_ +#define FIXUPS_H_ + +#include "macrossTypes.h" + +expressionType *generateFixupExpression(expressionType *expression); +expressionType *duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand); +functionCallTermType *duplicateFunctionCall(functionCallTermType *functionCall); +expressionType *duplicateArrayReference(arrayTermType *arrayTerm); + +#endif diff --git a/garbage.h b/garbage.h new file mode 100644 index 0000000..68f2138 --- /dev/null +++ b/garbage.h @@ -0,0 +1,66 @@ +#ifndef GARBAGE_H_ +#define GARBAGE_H_ + +#include "macrossTypes.h" + +void freeArrayTerm(arrayTermType *arrayTerm); +void freeAssignmentTerm(binopTermType *assignmentTerm); +void freeBinopTerm(binopTermType *binopTerm); +void freeFunctionCall(functionCallTermType *functionCall); +void freePostopTerm(postOpTermType *postopTerm); +void freePreopTerm(preOpTermType *preopTerm); +void freeString(stringType *string); +void freeUnopTerm(unopTermType *unopTerm); +void freeExpression(expressionType *expression); +void freeExpressionList(expressionListType *expressionList); +void freeIdentifierList(identifierListType *identifierList); +void freeSelectionList(selectionListType *selectionList); +void freeBlock(blockType *block); +void freeCase(caseType *aCase); +void freeCaseList(caseListType *caseList); +void freeOperandList(operandListType *operandList); +void freeMacro(operandListType *operands); +void freeMachineInstruction(operandListType *operands); +void freeAlignStatement(alignStatementBodyType *alignStatement); +void freeAssertStatement(assertStatementBodyType *assertStatement); +void freeBlockStatement(blockStatementBodyType *blockStatement); +void freeByteStatement(byteStatementBodyType *byteStatement); +void freeConstrainStatement(constrainStatementBodyType *constrainStatement); +void freeDbyteStatement(dbyteStatementBodyType *dbyteStatement); +void freeDefineStatement(defineStatementBodyType *defineStatement); +void freeDoUntilStatement(doUntilStatementBodyType *doUntilStatement); +void freeDoWhileStatement(doWhileStatementBodyType *doWhileStatement); +void freeExternStatement(externStatementBodyType *externStatement); +void freeFreturnStatement(freturnStatementBodyType *freturnStatement); +void freeFunctionStatement(functionStatementBodyType *functionStatement); +void freeIfStatement(ifStatementBodyType *ifStatement); +void freeIncludeStatement(includeStatementBodyType *includeStatement); +void freeInstructionStatement(instructionStatementBodyType *instructionStatement); +void freeLongStatement(longStatementBodyType *longStatement); +void freeMacroStatement(macroStatementBodyType *macroStatement); +void freeMdefineStatement(defineStatementBodyType *mdefineStatement); +void freeMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement); +void freeMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement); +void freeMifStatement(mifStatementBodyType *mifStatement); +void freeMswitchStatement(mswitchStatementBodyType *mswitchStatement); +void freeMforStatement(mforStatementBodyType *mforStatement); +void freeMvariableStatement(mvariableStatementBodyType *mvariableStatement); +void freeMwhileStatement(mwhileStatementBodyType *mwhileStatement); +void freeOrgStatement(orgStatementBodyType *orgStatement); +void freePerformStatement(performStatementBodyType *performStatement); +void freeRelStatement(relStatementBodyType *relStatement); +void freeStartStatement(startStatementBodyType *startStatement); +void freeStringStatement(stringStatementBodyType *stringStatement); +void freeStructStatement(structStatementBodyType *structStatement); +void freeTargetStatement(targetStatementBodyType *targetStatement); +void freeUndefineStatement(undefineStatementBodyType *undefineStatement); +void freeVariableStatement(variableStatementBodyType *variableStatement); +void freeWhileStatement(whileStatementBodyType *whileStatement); +void freeWordStatement(wordStatementBodyType *wordStatement); +void freeStatementBody(statementKindType kind, statementBodyType body); +void freeLabelList(labelListType *labelList); +void freeStatement(statementType *statement); +void freeArray(arrayType *array); +void freeValue(valueType *value); + +#endif diff --git a/initialize.h b/initialize.h new file mode 100644 index 0000000..1dd376c --- /dev/null +++ b/initialize.h @@ -0,0 +1,21 @@ +#ifndef INITIALIZE_H_ +#define INITIALIZE_H_ + +#include "macrossTypes.h" + +void chokePukeAndDie(void); +void initializeStuff(int argc, char **argv); +void installBuiltInFunctions(void); +void installPredefinedSymbols(void); +void installCommandLineDefineSymbols(void); +void createHashTables(void); +void queueInputFile(char *name); +void openFirstInputFile(void); +bool isDotMName(stringType *fileName); +bool parseCommandLineDefine(char *arg, char **name, int *value); +void noteCommandLineDefine(char *arg); + +/* Actually defined in main.c */ +void printVersion(void); + +#endif diff --git a/lexer.h b/lexer.h index a3f3031..4bdb184 100644 --- a/lexer.h +++ b/lexer.h @@ -1,32 +1,34 @@ #ifndef LEXER_H_ #define LEXER_H_ -int yylex (void); -int lexer (void); -void initializeLexDispatchTable (void); -bool isMacrossLiteralCharacter (char c); -void snarfAlphanumericString (char c, char *buffer); -int lexIdentifier (char c); -int lexNumber (char c); -int fancyAtoI (char *buffer, int base); -int digitValue (char c); -int lexLiteral (char c); -int lexCharacterConstant (void); -int getStringCharacter (FILE *input); -int lexStringConstant (void); -int lexOperator (char firstC); -char controlCharacter (char c); -char skipWhitespaceAndComments (void); -int popInputFileStack (void); -void pushInputFileStack (stringType *fileName); -void resynchronizeInput (void); -void saveLineForListing (stringType *line); -void saveEOLForListing (void); -void saveIndexForListing (statementKindType kindOfStatement, int cumulativeLineNumber); -void saveEndMifForListing (int cumulativeLineNumber); -void saveListingOff (void); -void saveListingOn (void); -char *myfgets (char *buffer, int length, FILE *stream); -int readAnotherLine (void); +#include "macrossTypes.h" + +int yylex(void); +int lexer(void); +void initializeLexDispatchTable(void); +bool isMacrossLiteralCharacter(char c); +void snarfAlphanumericString(char c, char *buffer); +int lexIdentifier(char c); +int lexNumber(char c); +int fancyAtoI(char *buffer, int base); +int digitValue(char c); +int lexLiteral(char c); +int lexCharacterConstant(void); +int getStringCharacter(FILE *input); +int lexStringConstant(void); +int lexOperator(char firstC); +char controlCharacter(char c); +char skipWhitespaceAndComments(void); +int popInputFileStack(void); +void pushInputFileStack(stringType *fileName); +void resynchronizeInput(void); +void saveLineForListing(stringType *line); +void saveEOLForListing(void); +void saveIndexForListing(statementKindType kindOfStatement, int cumulativeLineNumber); +void saveEndMifForListing(int cumulativeLineNumber); +void saveListingOff(void); +void saveListingOn(void); +char *myfgets(char *buffer, int length, FILE *stream); +int readAnotherLine(void); #endif diff --git a/listing.h b/listing.h index 58ec521..2512d4a 100644 --- a/listing.h +++ b/listing.h @@ -1,24 +1,22 @@ #ifndef LISTING_H_ #define LISTING_H_ -/* TODO: Functions here that have "format" arguments should actually - * be varargs. In 1984 it probably wasn't standardized, but here in - * Glorious Future Year 1989 the vprintf function does almost exactly - * what we want. */ +#include "macrossTypes.h" void outputListing(void); void terminateListingFiles(void); void generateListing(void); int printMacroLine(int numberOfBytes, int byteAddress, statementKindType kind); -void readSourceFileLine(int *sourceAddressPtr, int *sourceDepthPtr, char lineBuffer[], FILE *file); +void readSourceFileLine(int *sourceAddressPtr, int *sourceDepthPtr, char *lineBuffer, FILE *file); void readIndexFileLine(statementKindType *statementKindPtr, int *indexAddressPtr, int *indexLineNumberPtr); int printListingLine(int numberOfBytes, int byteAddress, char *text, statementKindType kind); bool isBlockOpener(statementKindType statementKind); -bool isBlankStatment(statementKindType statementKind); +bool isBlankStatement(statementKindType statementKind); void tabPrint(stringType *text); -void printNTimes (char aChar, int times); +void printNTimes(char aChar, int times); void tabIndent(void); bool labeledLine(void); +void vaddText(char *buffer, char **bufferPtr, char *format, va_list ap); void addText(char *buffer, char **bufferPtr, char *format, ...); void moreTextOptional(char *buffer, char **bufferPtr, char *format, ...); void moreText(char *format, ...); @@ -36,6 +34,3 @@ void startLineMarked(void); bool notListable(statementKindType statementKind); #endif - - - diff --git a/lookups.h b/lookups.h index e9b2a0a..e61dc0a 100644 --- a/lookups.h +++ b/lookups.h @@ -1,27 +1,29 @@ #ifndef LOOKUPS_H_ #define LOOKUPS_H_ -conditionType lookupConditionCode (char *s, int hashValue); -int lookupKeyword (char *s, int hashValue); -macroTableEntryType *lookupMacroName (char *s, int hashValue); -opcodeTableEntryType *lookupOpcode (char *s, int hashValue); -symbolTableEntryType *lookupOrEnterSymbol (stringType *s, symbolUsageKindType kind); -void pushSymbol (symbolTableEntryType *symbol); -void popSymbol (symbolTableEntryType *symbol); -macroTableEntryType *createMacro (stringType *macroName); -genericTableEntryType *prehashedStringLookup (char *s, genericTableEntryType **table, int hashValue); -genericTableEntryType *hashStringLookup (char *s, genericTableEntryType **table); -genericTableEntryType *hashStringEnter (genericTableEntryType *entry, genericTableEntryType **table); -int hashString (char *s); -bool strcmplc (char *s1, char *s2); -bool strcmplct (char *s1, char *s2); -void purgeSymbol (symbolTableEntryType *symbol); -void reincarnateSymbol (symbolInContextType *context, symbolUsageKindType newUsage); -void pushBinding (symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage); -void popBinding (symbolTableEntryType *symbol); -int bindMacroArguments (argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *macroName); -int bindFunctionArguments (argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *functionName); -void unbindArguments (argumentDefinitionListType *argumentList, int numberToUnbind); -void unbindLocalVariables (identifierListType *identifierList); +#include "macrossTypes.h" + +conditionType lookupConditionCode(char *s, int hashValue); +int lookupKeyword(char *s, int hashValue); +macroTableEntryType *lookupMacroName(char *s, int hashValue); +opcodeTableEntryType *lookupOpcode(char *s, int hashValue); +symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind); +void pushSymbol(symbolTableEntryType *symbol); +void popSymbol(symbolTableEntryType *symbol); +macroTableEntryType *createMacro(stringType *macroName); +genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue); +genericTableEntryType *hashStringLookup(char *s, genericTableEntryType **table); +genericTableEntryType *hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table); +int hashString(char *s); +bool strcmplc(char *s1, char *s2); +bool strcmplct(char *s1, char *s2); +void purgeSymbol(symbolTableEntryType *symbol); +void reincarnateSymbol(symbolInContextType *context, symbolUsageKindType newUsage); +void pushBinding(symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage); +void popBinding(symbolTableEntryType *symbol); +int bindMacroArguments(argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *macroName); +int bindFunctionArguments(argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *functionName); +void unbindArguments(argumentDefinitionListType *argumentList, int numberToUnbind); +void unbindLocalVariables(identifierListType *identifierList); #endif diff --git a/object.h b/object.h new file mode 100644 index 0000000..955b636 --- /dev/null +++ b/object.h @@ -0,0 +1,37 @@ +#ifndef OBJECT_H_ +#define OBJECT_H_ + +#include "macrossTypes.h" + +void outputObjectFile(void); +void outputWord(int aWord); +void outputPartition(void); +void outputBigword(long unsigned int bigword); +void outputByte(byte aByte); +void outputString(stringType *string); +void outputStartAddress(addressType startAddress); +void outputRelocatableCode(void); +void outputBreak(codeBreakType *codeBreak); +void outputAbsoluteCode(void); +void outputOneCodeBuffer(codeSegmentType *segment); +void outputPseudoSegment(addressType codeStartAddress, addressType codeEndAddress); +bool isObjectSymbol(symbolTableEntryType *symbol); +void enumerateAndCountSymbols(void); +int enumerateAndCountReferences(void); +void outputReference(expressionReferenceType *reference); +void outputReferenceInfo(void); +void outputOneSymbol(symbolTableEntryType *symbol); +void outputSymbolTableInfo(void); +int symbolCompare(symbolTableEntryType **symbol1, symbolTableEntryType **symbol2); +bool shouldDumpSymbol(symbolTableEntryType *symbol); +void dumpSymbolTable(void); +bool hackableSymbol(symbolTableEntryType *symbol); +void printValueTersely(valueType *value); +void outputReservations(void); +void outputExpressionBuffer(void); +void outputOneExpression(expressionType *expression); +void outputExpressions(void); +void outputOneFunction(functionDefinitionType *function); +void outputFunctions(void); + +#endif diff --git a/operandStuff.h b/operandStuff.h index 796d565..80582f6 100644 --- a/operandStuff.h +++ b/operandStuff.h @@ -12,10 +12,10 @@ operandType *buildOperand(operandKindType kindOfOperand, int arg1, int arg2, int #endif operandListType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand); -void expandOperand(operandKindType addressMode, char *buffer); void freeOperand(operandType *operand); +void expandOperand(operandKindType addressMode, char *buffer); valueType *evaluateOperand(operandType *operand); conditionType invertConditionCode(conditionType conditionCode); -bool shouldParethesize(operandType *operand); +bool shouldParenthesize(operandType *operand); #endif diff --git a/parserMisc.h b/parserMisc.h index 9984ce7..6835f3d 100644 --- a/parserMisc.h +++ b/parserMisc.h @@ -1,11 +1,12 @@ #ifndef PARSER_MISC_H_ #define PARSER_MISC_H_ + #include "macrossTypes.h" statementType *addLabelToStatement(labelListType *labelList, statementType *statement); void botch(char *message, ...); void checkDefineAssignmentOperator(assignmentKindType assignmentOperator); -void convertDefineToMDefine(statementType *defineStatement); +statementType *convertDefineToMdefine(statementType *defineStatement); ifStatementBodyType *extractIfBody(statementType *ifStatement); mifStatementBodyType *extractMifBody(statementType *mifStatement); stringType *extractString(operandType *textExpression); diff --git a/statementSemantics.h b/statementSemantics.h index 423c8fd..6ccbe59 100644 --- a/statementSemantics.h +++ b/statementSemantics.h @@ -5,26 +5,26 @@ void assembleBlock(blockType *block); simpleFixupListType *assembleBlockInsideIf(blockType *block, simpleFixupListType *ongoingFixupList); -bool operandCheck(opcodeTableEntryType *opcode, int numberOfOperands, valueType *evaluatedOperands[]); +bool operandCheck(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands); void assembleMachineInstruction(opcodeTableEntryType *opcode, operandListType *operands); void assembleMacro(macroTableEntryType *macroInstruction, operandListType *operands); void assembleAlignStatement(alignStatementBodyType *alignStatement); void assembleAssertStatement(assertStatementBodyType *assertStatement); void assembleBlockStatement(blockStatementBodyType *blockStatement); -void assembleByteStatement(byteStatementBodyType *byeStatement); +void assembleByteStatement(byteStatementBodyType *byteStatement); void assembleConstrainStatement(constrainStatementBodyType *constrainStatement); void assembleDbyteStatement(dbyteStatementBodyType *dbyteStatement); void assembleDefineStatement(defineStatementBodyType *defineStatement); void assembleDoUntilStatement(doUntilStatementBodyType *doUntilStatement); void assembleDoWhileStatement(doWhileStatementBodyType *doWhileStatement); void assembleExternStatement(externStatementBodyType *externStatement); -void assembleFReturnStatement(freturnStatementBodyType *freturnStatement); +void assembleFreturnStatement(freturnStatementBodyType *freturnStatement); void assembleFunctionStatement(functionStatementBodyType *functionStatement); void assembleGroupStatement(blockType *groupStatement); simpleFixupListType *assembleIfStatement(ifStatementBodyType *ifStatement, bool terminalIf, simpleFixupListType *ongoingFixupList); void assembleIfStatementOldStyle(ifStatementBodyType *ifStatement); void assembleIncludeStatement(includeStatementBodyType *includeStatement); -void assembleInstructionStatement(instructionStatementBodyType *Statement, int cumulativeLineNumber); +void assembleInstructionStatement(instructionStatementBodyType *instructionStatement, int cumulativeLineNumber); void assembleLongStatement(longStatementBodyType *longStatement); void assembleMacroStatement(macroStatementBodyType *macroStatement); void assembleMdefineStatement(defineStatementBodyType *mdefineStatement); @@ -46,9 +46,9 @@ void assembleUndefineStatement(undefineStatementBodyType *undefineStatement); void assembleVariableStatement(variableStatementBodyType *variableStatement); void assembleWhileStatement(whileStatementBodyType *whileStatement); void assembleWordStatement(wordStatementBodyType *wordStatement); -bool assembleStatementBody(statementKindType kind, statementBodyType body, int cumulativeLineNumber, bool worryAboutIf, simpleFixupListType **ifFixupList); void assembleLabelList(labelListType *labelList); simpleFixupListType *assembleStatement(statementType *statement, bool insideIf, simpleFixupListType *ongoingFixupList); +bool assembleStatementBody(statementKindType kind, statementBodyType body, int cumulativeLineNumber, bool worryAboutIf, simpleFixupListType **ifFixupList); void eatStatement(statementType *statement); #endif diff --git a/structSemantics.h b/structSemantics.h new file mode 100644 index 0000000..a623eb4 --- /dev/null +++ b/structSemantics.h @@ -0,0 +1,12 @@ +#ifndef STRUCT_SEMANTICS_H_ +#define STRUCT_SEMANTICS_H_ + +#include "macrossTypes.h" + +void putStructFixups(int base, fixupListType *fixups); +void putStructReferences(int base, expressionReferenceListType *references); +void instantiateStruct(structStatementBodyType *structStatement); +structInstanceType *assembleStructDefinitionBody(structBodyType *structBody); +void assembleStructDefinition(structStatementBodyType *structStatement); + +#endif diff --git a/tokenStrings.h b/tokenStrings.h new file mode 100644 index 0000000..2d7cf53 --- /dev/null +++ b/tokenStrings.h @@ -0,0 +1,9 @@ +#ifndef TOKEN_STRINGS_6502_H_ +#define TOKEN_STRINGS_6502_H_ + +#include "macrossTypes.h" + +char *conditionString(conditionType condition); +char *tokenString(int token); + +#endif