command:
  protoize -c '-m32 -DTARGET_CPU=CPU_6502' -g $(ls *.c | grep -v 68)
This commit is contained in:
Peter De Wachter 2016-01-23 19:18:42 +01:00
parent b9748cbe0e
commit e10a35e3e1
34 changed files with 1130 additions and 1661 deletions

View File

@ -45,11 +45,19 @@
and operand.
*/
void
actionsDir1(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
bool isByteAddress (valueType *value);
bool isDefined (valueType *value);
extern void emitByte (byte byteValue);
bool wordCheck (int value);
extern void putFixupsHere (fixupKindType kindOfFixupsToPut, int whichFixup);
extern void emitWord (wordType wordValue);
bool byteCheck (int value);
bool isByteOffset (int value);
extern void error (errorType theError, ...);
void
actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define ZERO_PAGE_ADDRESS_BIT 0x00
#define NON_ZERO_PAGE_ADDRESS_BIT 0x08
@ -66,10 +74,7 @@ actionsDir1(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsDir2(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDir2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
if (wordCheck(address)) {
emitByte(binary);
@ -79,10 +84,7 @@ actionsDir2(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsDirIndir(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_BIT 0x00
#define INDIRECT_ADDRESS_BIT 0x20
@ -98,10 +100,7 @@ actionsDirIndir(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsDirX1(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirX1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X1 0x04
#define A_REGISTER_BITS_X1 0x08
@ -133,10 +132,7 @@ actionsDirX1(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsDirX2(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X2 0x00
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_X2 0x08
@ -165,10 +161,7 @@ actionsDirX2(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsDirX3(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
if (class == EXPRESSION_OPND) {
if (isByteAddress(operand) && isDefined(operand)) {
@ -189,10 +182,7 @@ actionsDirX3(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsDirY(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_Y 0x00
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_Y 0x08
@ -217,10 +207,7 @@ actionsDirY(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsImmDir(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmDir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define IMMEDIATE_DATA_BITS_ID 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_ID 0x04
@ -245,10 +232,7 @@ actionsImmDir(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsImmDirX(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmDirX(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define IMMEDIATE_DATA_BITS_IX 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IX 0x04
@ -284,10 +268,7 @@ actionsImmDirX(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsImmDirY(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define IMMEDIATE_DATA_BITS_IY 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IY 0x04
@ -323,10 +304,7 @@ actionsImmDirY(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsImmIndex(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
#define PRE_INDEXED_BITS_A 0x00
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_A 0x04
@ -383,10 +361,7 @@ actionsImmIndex(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsIndex(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
if (class == EXPRESSION_OPND) {
if (isByteAddress(operand) && isDefined(operand)) {
@ -428,19 +403,13 @@ actionsIndex(opcode, numberOfOperands, evaluatedOperands)
}
void
actionsNone(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
emitByte(binary);
}
void
actionsRelative(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
int offset;
@ -465,43 +434,37 @@ actionsRelative(opcode, numberOfOperands, evaluatedOperands)
*/
bool
isByte(value)
int value;
isByte(int value)
{
return (-129<value && value<256);
}
bool
isByteOffset(value)
int value;
isByteOffset(int value)
{
return (-129<value && value<128);
}
bool
isWordOffset(value)
int value;
isWordOffset(int value)
{
return (-32769<value && value<32768);
}
bool
isByteAddress(value)
valueType *value;
isByteAddress(valueType *value)
{
return(value->kindOfValue==ABSOLUTE_VALUE && isByte(value->value));
}
bool
isWord(value)
int value;
isWord(int value)
{
return (-32769<value && value<65536);
}
bool
byteCheck(value)
int value;
byteCheck(int value)
{
if (isByte(value)) {
return(TRUE);
@ -512,8 +475,7 @@ byteCheck(value)
}
bool
wordCheck(value)
int value;
wordCheck(int value)
{
if (isWord(value)) {
return(TRUE);
@ -525,8 +487,7 @@ wordCheck(value)
}
bool
isDefined(value)
valueType *value;
isDefined(valueType *value)
{
return(value!=NULL && value->kindOfValue!=UNDEFINED_VALUE);
}

View File

@ -33,14 +33,16 @@
#include "macrossTypes.h"
#include "macrossGlobals.h"
symbolTableEntryType *lookupOrEnterSymbol();
char *saveString();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
char *saveString(char *s);
/* Generic routine to create statement nodes */
statementType *
newStatement(kind, body)
statementKindType kind;
statementBodyType body;
extern void botch (char *message, ...);
extern void error (errorType theError, ...);
statementType *
newStatement(statementKindType kind, statementBodyType body)
{
statementType *result;
@ -62,17 +64,14 @@ newStatement(kind, body)
*/
statementType *
buildAlignStatement(expression)
expressionType *expression;
buildAlignStatement(expressionType *expression)
{
return(newStatement(ALIGN_STATEMENT,
(statementBodyType) expression));
}
statementType *
buildAssertStatement(condition, message)
expressionType *condition;
expressionType *message;
buildAssertStatement(expressionType *condition, expressionType *message)
{
assertStatementBodyType *result;
@ -84,25 +83,21 @@ buildAssertStatement(condition, message)
}
statementType *
buildBlockStatement(expressionList)
expressionListType *expressionList;
buildBlockStatement(expressionListType *expressionList)
{
return(newStatement(BLOCK_STATEMENT,
(statementBodyType) expressionList));
}
statementType *
buildByteStatement(expressionList)
expressionListType *expressionList;
buildByteStatement(expressionListType *expressionList)
{
return(newStatement(BYTE_STATEMENT,
(statementBodyType) expressionList));
}
statementType *
buildConstrainStatement(expression, block)
expressionType *expression;
blockType *block;
buildConstrainStatement(expressionType *expression, blockType *block)
{
constrainStatementBodyType *result;
@ -114,17 +109,14 @@ buildConstrainStatement(expression, block)
}
statementType *
buildDbyteStatement(expressionList)
expressionListType *expressionList;
buildDbyteStatement(expressionListType *expressionList)
{
return(newStatement(DBYTE_STATEMENT,
(statementBodyType) expressionList));
}
statementType *
buildDefineStatement(name, value)
stringType *name;
expressionType *value;
buildDefineStatement(stringType *name, expressionType *value)
{
defineStatementBodyType *result;
@ -135,9 +127,7 @@ buildDefineStatement(name, value)
}
statementType *
buildDoUntilStatement(body, condition)
blockType *body;
conditionType condition;
buildDoUntilStatement(blockType *body, conditionType condition)
{
doUntilStatementBodyType *result;
@ -148,9 +138,7 @@ buildDoUntilStatement(body, condition)
}
statementType *
buildDoWhileStatement(body, condition)
blockType *body;
conditionType condition;
buildDoWhileStatement(blockType *body, conditionType condition)
{
doWhileStatementBodyType *result;
@ -161,9 +149,7 @@ buildDoWhileStatement(body, condition)
}
statementType *
buildDoStatement(body, end)
blockType *body;
doEndType *end;
buildDoStatement(blockType *body, doEndType *end)
{
statementType *result;
@ -178,26 +164,21 @@ buildDoStatement(body, end)
}
statementType *
buildExternStatement(identifierList)
identifierListType *identifierList;
buildExternStatement(identifierListType *identifierList)
{
return(newStatement(EXTERN_STATEMENT,
(statementBodyType) identifierList));
}
statementType *
buildFreturnStatement(expression)
expressionType *expression;
buildFreturnStatement(expressionType *expression)
{
return(newStatement(FRETURN_STATEMENT,
(statementBodyType) expression));
}
statementType *
buildFunctionStatement(name, arguments, body)
stringType *name;
argumentDefinitionListType *arguments;
blockType *body;
buildFunctionStatement(stringType *name, argumentDefinitionListType *arguments, blockType *body)
{
functionStatementBodyType *result;
symbolTableEntryType *testSymbol;
@ -216,18 +197,14 @@ buildFunctionStatement(name, arguments, body)
}
statementType *
buildGroupStatement(block)
blockType *block;
buildGroupStatement(blockType *block)
{
return(newStatement(GROUP_STATEMENT,
(statementBodyType) block));
}
statementType *
buildIfStatement(head, continuation, continuationKind)
ifHeadType *head;
ifContinuationType continuation;
ifContinuationKindType continuationKind;
buildIfStatement(ifHeadType *head, ifContinuationType continuation, ifContinuationKindType continuationKind)
{
ifStatementBodyType *result;
@ -255,17 +232,14 @@ buildIfStatement(head, continuation, continuationKind)
}
statementType *
buildIncludeStatement(filename)
expressionType *filename;
buildIncludeStatement(expressionType *filename)
{
return(newStatement(INCLUDE_STATEMENT,
(statementBodyType) filename));
}
statementType *
buildInstructionStatement(opcode, operands)
opcodeTableEntryType *opcode;
operandListType *operands;
buildInstructionStatement(opcodeTableEntryType *opcode, operandListType *operands)
{
instructionStatementBodyType *result;
@ -277,18 +251,14 @@ buildInstructionStatement(opcode, operands)
}
statementType *
buildLongStatement(expressionList)
expressionListType *expressionList;
buildLongStatement(expressionListType *expressionList)
{
return(newStatement(LONG_STATEMENT,
(statementBodyType) expressionList));
}
statementType *
buildMacroStatement(macro, arguments, body)
macroTableEntryType *macro;
argumentDefinitionListType *arguments;
blockType *body;
buildMacroStatement(macroTableEntryType *macro, argumentDefinitionListType *arguments, blockType *body)
{
macroStatementBodyType *result;
@ -300,9 +270,7 @@ buildMacroStatement(macro, arguments, body)
}
statementType *
buildMacroInstructionStatement(macro, operands)
macroTableEntryType *macro;
operandListType *operands;
buildMacroInstructionStatement(macroTableEntryType *macro, operandListType *operands)
{
instructionStatementBodyType *result;
@ -314,9 +282,7 @@ buildMacroInstructionStatement(macro, operands)
}
statementType *
buildMdefineStatement(name, value)
stringType *name;
expressionType *value;
buildMdefineStatement(stringType *name, expressionType *value)
{
mdefineStatementBodyType *result;
@ -327,9 +293,7 @@ buildMdefineStatement(name, value)
}
statementType *
buildMdoUntilStatement(body, condition)
blockType *body;
ExpressionType *condition;
buildMdoUntilStatement(blockType *body, struct expressionTermStruct *condition)
{
mdoUntilStatementBodyType *result;
@ -340,9 +304,7 @@ buildMdoUntilStatement(body, condition)
}
statementType *
buildMdoWhileStatement(body, condition)
blockType *body;
expressionType *condition;
buildMdoWhileStatement(blockType *body, expressionType *condition)
{
mdoWhileStatementBodyType *result;
@ -353,9 +315,7 @@ buildMdoWhileStatement(body, condition)
}
statementType *
buildMdoStatement(body, end)
blockType *body;
mdoEndType *end;
buildMdoStatement(blockType *body, mdoEndType *end)
{
statementType *result;
@ -370,9 +330,7 @@ buildMdoStatement(body, end)
}
statementType *
buildMforStatement(forExpressions, body)
forExpressionsType *forExpressions;
blockType *body;
buildMforStatement(forExpressionsType *forExpressions, blockType *body)
{
mforStatementBodyType *result;
@ -386,10 +344,7 @@ buildMforStatement(forExpressions, body)
}
statementType *
buildMifStatement(head, continuation, continuationKind)
mifHeadType *head;
mifContinuationType continuation;
ifContinuationKindType continuationKind;
buildMifStatement(mifHeadType *head, mifContinuationType continuation, ifContinuationKindType continuationKind)
{
mifStatementBodyType *result;
@ -417,9 +372,7 @@ buildMifStatement(head, continuation, continuationKind)
}
statementType *
buildMswitchStatement(switchExpression, cases)
expressionType *switchExpression;
caseListType *cases;
buildMswitchStatement(expressionType *switchExpression, caseListType *cases)
{
mswitchStatementBodyType *result;
@ -430,10 +383,7 @@ buildMswitchStatement(switchExpression, cases)
}
statementType *
buildMvariableStatement(name, value, dimension)
stringType *name;
expressionListType *value;
expressionType *dimension;
buildMvariableStatement(stringType *name, expressionListType *value, expressionType *dimension)
{
mvariableStatementBodyType *result;
@ -445,9 +395,7 @@ buildMvariableStatement(name, value, dimension)
}
statementType *
buildMwhileStatement(condition, body)
expressionType *condition;
blockType *body;
buildMwhileStatement(expressionType *condition, blockType *body)
{
mwhileStatementBodyType *result;
@ -458,53 +406,47 @@ buildMwhileStatement(condition, body)
}
statementType *
buildNullStatement()
buildNullStatement(void)
{
return(newStatement(NULL_STATEMENT, (statementBodyType){ .ifUnion = NULL }));
}
statementType *
buildOrgStatement(expression)
expressionType *expression;
buildOrgStatement(expressionType *expression)
{
return(newStatement(ORG_STATEMENT,
(statementBodyType) expression));
}
statementType *
buildPerformStatement(expression)
expressionType *expression;
buildPerformStatement(expressionType *expression)
{
return(newStatement(PERFORM_STATEMENT,
(statementBodyType) expression));
}
statementType *
buildRelStatement()
buildRelStatement(void)
{
return(newStatement(REL_STATEMENT, (statementBodyType){ .ifUnion = NULL }));
}
statementType *
buildStartStatement(expression)
expressionType *expression;
buildStartStatement(expressionType *expression)
{
return(newStatement(START_STATEMENT,
(statementBodyType) expression));
}
statementType *
buildStringStatement(expressionList)
expressionListType *expressionList;
buildStringStatement(expressionListType *expressionList)
{
return(newStatement(STRING_STATEMENT,
(statementBodyType) expressionList));
}
statementType *
buildStructStatement(name, body)
symbolTableEntryType *name;
blockType *body;
buildStructStatement(symbolTableEntryType *name, blockType *body)
{
structStatementBodyType *result;
@ -515,26 +457,21 @@ buildStructStatement(name, body)
}
statementType *
buildTargetStatement(expression)
expressionType *expression;
buildTargetStatement(expressionType *expression)
{
return(newStatement(TARGET_STATEMENT,
(statementBodyType) expression));
}
statementType *
buildUndefineStatement(identifierList)
identifierListType *identifierList;
buildUndefineStatement(identifierListType *identifierList)
{
return(newStatement(UNDEFINE_STATEMENT,
(statementBodyType) identifierList));
}
statementType *
buildVariableStatement(name, value, dimension)
stringType *name;
expressionListType *value;
expressionType *dimension;
buildVariableStatement(stringType *name, expressionListType *value, expressionType *dimension)
{
variableStatementBodyType *result;
@ -546,9 +483,7 @@ buildVariableStatement(name, value, dimension)
}
statementType *
buildWhileStatement(condition, body)
conditionType condition;
blockType *body;
buildWhileStatement(conditionType condition, blockType *body)
{
whileStatementBodyType *result;
@ -559,8 +494,7 @@ buildWhileStatement(condition, body)
}
statementType *
buildWordStatement(expressionList)
expressionListType *expressionList;
buildWordStatement(expressionListType *expressionList)
{
return(newStatement(WORD_STATEMENT,
(statementBodyType) expressionList));

View File

@ -41,10 +41,11 @@
/* Fragments of statement structures */
caseType *
buildCase(caseTags, caseBody)
expressionListType *caseTags;
blockType *caseBody;
extern void botch (char *message, ...);
caseType *
buildCase(expressionListType *caseTags, blockType *caseBody)
{
caseType *result;
@ -55,9 +56,7 @@ buildCase(caseTags, caseBody)
}
doEndType *
buildDoEnd(condition, kindOfDoEnd)
conditionType condition;
doEndKindType kindOfDoEnd;
buildDoEnd(conditionType condition, doEndKindType kindOfDoEnd)
{
doEndType *result;
@ -68,10 +67,7 @@ buildDoEnd(condition, kindOfDoEnd)
}
forExpressionsType *
buildForExpressions(initExpression, testExpression, incrExpression)
expressionType *initExpression;
expressionType *testExpression;
expressionType *incrExpression;
buildForExpressions(expressionType *initExpression, expressionType *testExpression, expressionType *incrExpression)
{
forExpressionsType *result;
@ -83,9 +79,7 @@ buildForExpressions(initExpression, testExpression, incrExpression)
}
ifHeadType *
buildIfHead(condition, block)
conditionType condition;
blockType *block;
buildIfHead(conditionType condition, blockType *block)
{
ifHeadType *result;
@ -96,9 +90,7 @@ buildIfHead(condition, block)
}
mdoEndType *
buildMdoEnd(condition, kindOfMdoEnd)
expressionType *condition;
doEndKindType kindOfMdoEnd;
buildMdoEnd(expressionType *condition, doEndKindType kindOfMdoEnd)
{
mdoEndType *result;
@ -110,9 +102,7 @@ buildMdoEnd(condition, kindOfMdoEnd)
mifHeadType *
buildMifHead(condition, block)
expressionType *condition;
blockType *block;
buildMifHead(expressionType *condition, blockType *block)
{
mifHeadType *result;
@ -126,9 +116,7 @@ buildMifHead(condition, block)
/* Fragments of expression structures */
arrayTermType *
buildArrayTerm(array, index)
expressionType *array;
expressionType *index;
buildArrayTerm(expressionType *array, expressionType *index)
{
arrayTermType *result;
@ -139,10 +127,7 @@ buildArrayTerm(array, index)
}
binopTermType *
buildBinopTerm(binop, leftArgument, rightArgument)
binopKindType binop;
expressionType *leftArgument;
expressionType *rightArgument;
buildBinopTerm(binopKindType binop, expressionType *leftArgument, expressionType *rightArgument)
{
binopTermType *result;
@ -154,12 +139,10 @@ buildBinopTerm(binop, leftArgument, rightArgument)
}
functionCallTermType *
buildFunctionCall(functionName, arguments)
stringType *functionName;
operandListType *arguments;
buildFunctionCall(stringType *functionName, operandListType *arguments)
{
functionCallTermType *result;
symbolTableEntryType *lookupOrEnterSymbol();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
result = typeAlloc(functionCallTermType);
result->functionName = lookupOrEnterSymbol(functionName,
@ -169,9 +152,7 @@ buildFunctionCall(functionName, arguments)
}
postOpTermType *
buildPostOpTerm(postOp, postOpArgument)
postOpKindType postOp;
expressionType *postOpArgument;
buildPostOpTerm(postOpKindType postOp, expressionType *postOpArgument)
{
postOpTermType *result;
@ -182,9 +163,7 @@ buildPostOpTerm(postOp, postOpArgument)
}
preOpTermType *
buildPreOpTerm(preOp, preOpArgument)
preOpKindType preOp;
expressionType *preOpArgument;
buildPreOpTerm(preOpKindType preOp, expressionType *preOpArgument)
{
preOpTermType *result;
@ -195,9 +174,7 @@ buildPreOpTerm(preOp, preOpArgument)
}
unopTermType *
buildUnopTerm(unop, unopArgument)
unopKindType unop;
expressionType *unopArgument;
buildUnopTerm(unopKindType unop, expressionType *unopArgument)
{
unopTermType *result;
@ -208,15 +185,11 @@ buildUnopTerm(unop, unopArgument)
}
expressionTermType *
buildExpressionTerm(kindOfExpressionTerm, arg1, arg2, arg3)
expressionTermKindType kindOfExpressionTerm;
anyOldThing *arg1;
anyOldThing *arg2;
anyOldThing *arg3;
buildExpressionTerm(expressionTermKindType kindOfExpressionTerm, anyOldThing *arg1, anyOldThing *arg2, anyOldThing *arg3)
{
expressionType *result;
symbolTableEntryType *lookupOrEnterSymbol();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
result = typeAlloc(expressionType);
result->kindOfTerm = kindOfExpressionTerm;
@ -298,11 +271,10 @@ buildExpressionTerm(kindOfExpressionTerm, arg1, arg2, arg3)
/* Other stuff */
macroTableEntryType *
buildMacroTableEntry(name)
stringType *name;
buildMacroTableEntry(stringType *name)
{
macroTableEntryType *result;
char *saveString();
char *saveString(char *s);
result = typeAlloc(macroTableEntryType);
result->macroName = saveString(name);
@ -313,12 +285,10 @@ buildMacroTableEntry(name)
}
symbolTableEntryType *
buildSymbolTableEntry(name, usage)
stringType *name;
symbolUsageKindType usage;
buildSymbolTableEntry(stringType *name, symbolUsageKindType usage)
{
symbolTableEntryType *result;
char *saveString();
char *saveString(char *s);
result = typeAlloc(symbolTableEntryType);
result->symbolName = saveString(name);
@ -335,10 +305,7 @@ buildSymbolTableEntry(name, usage)
}
codeBreakType *
buildCodeBreak(kind, address, data)
codeBreakKindType kind;
addressType address;
int data;
buildCodeBreak(codeBreakKindType kind, addressType address, int data)
{
codeBreakType *result;
@ -351,10 +318,7 @@ buildCodeBreak(kind, address, data)
}
reservationListType *
buildReservation(startAddress, blockSize, nextReservation)
addressType startAddress;
int blockSize;
reservationListType *nextReservation;
buildReservation(addressType startAddress, int blockSize, reservationListType *nextReservation)
{
reservationListType *result;
@ -366,9 +330,7 @@ buildReservation(startAddress, blockSize, nextReservation)
}
simpleFixupListType *
buildSimpleFixupList(locationToFixup, previousList)
valueType locationToFixup;
simpleFixupListType *previousList;
buildSimpleFixupList(valueType locationToFixup, simpleFixupListType *previousList)
{
simpleFixupListType *result;

View File

@ -43,14 +43,11 @@
*/
argumentListHeadType *
buildArgumentList(new, rest, arrayTag)
stringType *new;
argumentListHeadType *rest;
bool arrayTag;
buildArgumentList(stringType *new, argumentListHeadType *rest, bool arrayTag)
{
argumentListHeadType *newListHead;
argumentDefinitionListType *newArgument;
symbolTableEntryType *lookupOrEnterSymbol();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
if (rest == NULL) {
newListHead = typeAlloc(argumentListHeadType);
@ -76,9 +73,7 @@ buildArgumentList(new, rest, arrayTag)
}
caseListHeadType *
buildCaseList(new, rest)
caseType *new;
caseListHeadType *rest;
buildCaseList(caseType *new, caseListHeadType *rest)
{
caseListHeadType *newListHead;
caseListType *newCase;
@ -103,9 +98,7 @@ buildCaseList(new, rest)
}
expressionListHeadType *
buildExpressionList(new, rest)
expressionType *new;
expressionListHeadType *rest;
buildExpressionList(expressionType *new, expressionListHeadType *rest)
{
expressionListHeadType *newListHead;
expressionListType *newListEntry;
@ -130,15 +123,12 @@ buildExpressionList(new, rest)
}
identifierListHeadType *
buildIdentifierList(new, rest, usage)
stringType *new;
identifierListHeadType *rest;
symbolUsageKindType usage;
buildIdentifierList(stringType *new, identifierListHeadType *rest, symbolUsageKindType usage)
{
identifierListType *newListEntry;
identifierListHeadType *newListHead;
symbolTableEntryType *lookupOrEnterSymbol();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
if (rest == NULL) {
newListHead = typeAlloc(identifierListHeadType);
@ -160,9 +150,7 @@ buildIdentifierList(new, rest, usage)
}
labelListHeadType *
buildLabelList(new, rest)
symbolTableEntryType *new;
labelListHeadType *rest;
buildLabelList(symbolTableEntryType *new, labelListHeadType *rest)
{
labelListHeadType *newLabelHead;
labelListType *newLabel;
@ -187,9 +175,7 @@ buildLabelList(new, rest)
}
operandListHeadType *
buildOperandList(new, rest)
operandType *new;
operandListHeadType *rest;
buildOperandList(operandType *new, operandListHeadType *rest)
{
operandListHeadType *newListHead;
@ -213,17 +199,13 @@ buildOperandList(new, rest)
}
selectionListHeadType *
buildSelectionList(new, rest)
selectionListType *new;
selectionListHeadType *rest;
buildSelectionList(selectionListType *new, selectionListHeadType *rest)
{
return((selectionListHeadType *) buildIdentifierList(new, rest, unknownSymbolTag /* random guess */));
}
statementListHeadType *
buildStatementList(new, rest)
statementType *new;
statementListHeadType *rest;
buildStatementList(statementType *new, statementListHeadType *rest)
{
statementListHeadType *newListHead;

View File

@ -42,47 +42,54 @@
environment
*/
valueType *
makeBooleanValue(test)
int test;
extern void error (errorType theError, ...);
extern int hashString (char *s);
extern void assembleMacro (macroTableEntryType *macroInstruction, operandListType *operands);
extern void saveListingOff (void);
extern void saveListingOn (void);
extern bool strcmplc (char *s1, char *s2);
extern symbolTableEntryType *lookupOrEnterSymbol (stringType *s, symbolUsageKindType kind);
extern void assembleDefineStatement (defineStatementBodyType *defineStatement);
extern void freeStatement (statementType *statement);
valueType *
makeBooleanValue(int test)
{
return(newValue(ABSOLUTE_VALUE, test!=0, EXPRESSION_OPND));
}
valueType *
makeFailureValue()
makeFailureValue(void)
{
return(newValue(FAIL, 0, EXPRESSION_OPND));
}
valueType *
makeIntegerValue(integer)
int integer;
makeIntegerValue(int integer)
{
return(newValue(ABSOLUTE_VALUE, integer, EXPRESSION_OPND));
}
valueType *
makeOperandValue(operand)
operandType *operand;
makeOperandValue(operandType *operand)
{
return(newValue(OPERAND_VALUE, operand, EXPRESSION_OPND));
}
valueType *
makeStringValue(string)
stringType *string;
makeStringValue(stringType *string)
{
return(newValue(STRING_VALUE, string, STRING_OPND));
}
valueType *
makeUndefinedValue()
makeUndefinedValue(void)
{
return(newValue(UNDEFINED_VALUE, 0, EXPRESSION_OPND));
@ -98,9 +105,7 @@ makeUndefinedValue()
/* Return internal address mode of an operand */
valueType *
addressModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
addressModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -115,15 +120,13 @@ addressModeBIF(parameterList, kindOfFixup)
/* Call a macro where the macro name is obtained dynamically from a string */
valueType *
applyBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
applyBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
stringType *macroToLookup;
macroTableEntryType *macroToCall;
macroTableEntryType *lookupMacroName();
macroTableEntryType *lookupMacroName(char *s, int hashValue);
if (parameterList == NULL) {
error(NO_ARGUMENTS_TO_BIF_ERROR, "apply");
@ -146,9 +149,7 @@ applyBIF(parameterList, kindOfFixup)
/* return the length of an array */
valueType *
arrayLengthBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
arrayLengthBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *testObjectValue;
@ -188,9 +189,7 @@ static char atasciiTable[] = { /* 0xFFs will become 0x00s on output */
/* Convert a string to ATASCII */
valueType *
atasciiBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
atasciiBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
int i;
valueType *stringValue;
@ -215,9 +214,7 @@ atasciiBIF(parameterList, kindOfFixup)
/* Convert a string to ATASCII while setting high-order color bits */
valueType *
atasciiColorBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
atasciiColorBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
int i;
valueType *stringValue;
@ -264,18 +261,14 @@ atasciiColorBIF(parameterList, kindOfFixup)
/* Turn debug mode off and on */
valueType *
debugModeOffBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
debugModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
debug = FALSE;
return(makeBooleanValue(FALSE));
}
valueType *
debugModeOnBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
debugModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
debug = TRUE;
return(makeBooleanValue(TRUE));
@ -283,18 +276,14 @@ debugModeOnBIF(parameterList, kindOfFixup)
/* Turn display of code emission off and on */
valueType *
emitModeOffBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
emitModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
emitPrint = FALSE;
return(makeBooleanValue(FALSE));
}
valueType *
emitModeOnBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
emitModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
emitPrint = TRUE;
return(makeBooleanValue(TRUE));
@ -302,9 +291,7 @@ emitModeOnBIF(parameterList, kindOfFixup)
/* Check if an operand is absolute (as opposed to relocatable) */
valueType *
isAbsoluteValueBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isAbsoluteValueBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -320,9 +307,9 @@ isAbsoluteValueBIF(parameterList, kindOfFixup)
/* Check if operand is code block */
valueType *
isBlockBIF(parameterList, kindOfFixup) /* questionable */
operandListType *parameterList;
fixupKindType kindOfFixup;
isBlockBIF(operandListType *parameterList, fixupKindType kindOfFixup) /* questionable */
{
valueType *evaluatedParameter;
@ -338,9 +325,7 @@ isBlockBIF(parameterList, kindOfFixup) /* questionable */
/* Check if operand is a BIF */
valueType *
isBuiltInFunctionBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isBuiltInFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -356,9 +341,7 @@ isBuiltInFunctionBIF(parameterList, kindOfFixup)
/* Check if operand is a condition code */
valueType *
isConditionCodeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isConditionCodeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -374,15 +357,13 @@ isConditionCodeBIF(parameterList, kindOfFixup)
/* Check if a symbol is defined */
valueType *
isDefinedBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isDefinedBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
expressionType *expression;
symbolInContextType *context;
symbolInContextType *getWorkingContext();
symbolTableEntryType *effectiveSymbol();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
if (parameterList != NULL) {
if (parameterList->kindOfOperand == EXPRESSION_OPND &&
@ -409,14 +390,12 @@ isDefinedBIF(parameterList, kindOfFixup)
/* Check if a symbol is externally visible */
valueType *
isExternalBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isExternalBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
expressionType *expression;
symbolInContextType *context;
symbolInContextType *getWorkingContext();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
if (parameterList != NULL && parameterList->kindOfOperand ==
EXPRESSION_OPND) {
@ -432,9 +411,7 @@ isExternalBIF(parameterList, kindOfFixup)
/* Check if an operand is a struct field */
valueType *
isFieldBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isFieldBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -450,9 +427,7 @@ isFieldBIF(parameterList, kindOfFixup)
/* Check if an operand is a user-defined function */
valueType *
isFunctionBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -468,9 +443,7 @@ isFunctionBIF(parameterList, kindOfFixup)
/* Check if an operand value is relocatable */
valueType *
isRelocatableValueBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isRelocatableValueBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -487,9 +460,7 @@ isRelocatableValueBIF(parameterList, kindOfFixup)
/* Check if an operand is a string */
valueType *
isStringBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isStringBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -505,9 +476,7 @@ isStringBIF(parameterList, kindOfFixup)
/* Check if an operand is a struct */
valueType *
isStructBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isStructBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
@ -523,9 +492,7 @@ isStructBIF(parameterList, kindOfFixup)
/* Check if an operand is a symbol */
valueType *
isSymbolBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isSymbolBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
expressionType *expression;
@ -541,9 +508,7 @@ isSymbolBIF(parameterList, kindOfFixup)
/* Turn listing off and on */
valueType *
listingOffBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
listingOffBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
if (listingOn) {
if (!listingControlCounter)
@ -554,9 +519,7 @@ listingOffBIF(parameterList, kindOfFixup)
}
valueType *
listingOnBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
listingOnBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
if (listingOn) {
if (--listingControlCounter < 0) {
@ -575,9 +538,7 @@ listingOnBIF(parameterList, kindOfFixup)
/* Generate an array on the fly */
valueType *
makeArrayBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
makeArrayBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *lengthValue;
int length;
@ -619,9 +580,7 @@ makeArrayBIF(parameterList, kindOfFixup)
/* Return the Nth character of a string (as an integer) */
valueType *
nthCharBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
nthCharBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *positionValue;
int position;
@ -658,9 +617,7 @@ nthCharBIF(parameterList, kindOfFixup)
/* Pass stuff through to stdio's 'printf' function */
valueType *
printfBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
printfBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
stringType *formatString;
valueType *stringValue;
@ -697,9 +654,7 @@ printfBIF(parameterList, kindOfFixup)
/* Concatenate two strings */
valueType *
strcatBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
strcatBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
stringType *string1;
@ -731,9 +686,7 @@ strcatBIF(parameterList, kindOfFixup)
/* Compare two strings */
valueType *
strcmpBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
strcmpBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
stringType *string1;
@ -764,9 +717,7 @@ strcmpBIF(parameterList, kindOfFixup)
/* Compare two strings in a case-independent fashion */
valueType *
strcmplcBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
strcmplcBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
stringType *string1;
@ -797,9 +748,7 @@ strcmplcBIF(parameterList, kindOfFixup)
/* Return the length of a string */
valueType *
strlenBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
strlenBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
@ -815,9 +764,7 @@ strlenBIF(parameterList, kindOfFixup)
/* Return a substring of a string */
valueType *
substrBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
substrBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
stringType *string;
@ -895,16 +842,14 @@ substrBIF(parameterList, kindOfFixup)
/* Turn a string into a symbol */
valueType *
symbolLookupBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
symbolLookupBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
stringType *identifierToLookup;
expressionTermType *buildExpressionTerm();
operandType *buildOperand();
valueType *evaluateIdentifier();
expressionTermType *buildExpressionTerm(expressionTermKindType kindOfExpressionTerm, anyOldThing *arg1, anyOldThing *arg2, anyOldThing *arg3);
operandType *buildOperand(operandKindType kindOfOperand, anyOldThing *arg);
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
if (parameterList == NULL) {
error(NO_ARGUMENTS_TO_BIF_ERROR, "symbolLookup");
@ -922,13 +867,11 @@ symbolLookupBIF(parameterList, kindOfFixup)
/* Define a string as a symbol */
valueType *
symbolDefineBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
symbolDefineBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *stringValue;
statementType *syntheticDefineStatement;
statementType *buildDefineStatement();
statementType *buildDefineStatement(stringType *name, expressionType *value);
if (parameterList == NULL) {
error(NO_ARGUMENTS_TO_BIF_ERROR, "symbolDefine");
@ -957,15 +900,13 @@ symbolDefineBIF(parameterList, kindOfFixup)
/* Turn a symbol into a string */
valueType *
symbolNameBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
symbolNameBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
expressionType *expression;
symbolInContextType *context;
environmentType *saveEnvironment;
symbolInContextType *getWorkingContext();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
saveEnvironment = currentEnvironment;
while (parameterList != NULL && parameterList->kindOfOperand ==
@ -996,14 +937,12 @@ symbolNameBIF(parameterList, kindOfFixup)
/* Return internal form of what sort of symbol a symbol is */
valueType *
symbolUsageBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
symbolUsageBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
expressionType *expression;
symbolInContextType *context;
symbolInContextType *getWorkingContext();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
if (parameterList != NULL && parameterList->kindOfOperand ==
EXPRESSION_OPND) {
@ -1018,9 +957,7 @@ symbolUsageBIF(parameterList, kindOfFixup)
/* Return internal form of what sort of value a value is */
valueType *
valueTypeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
valueTypeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;

View File

@ -34,23 +34,21 @@
#include "macrossGlobals.h"
/* Helper functions, defined in builtInFunctions.c */
valueType *makeBooleanValue();
valueType *makeFailureValue();
valueType *makeIntegerValue();
valueType *makeOperandValue();
valueType *makeStringValue();
valueType *makeUndefinedValue();
valueType *makeBooleanValue(int test);
valueType *makeFailureValue(void);
valueType *makeIntegerValue(int integer);
valueType *makeOperandValue(operandType *operand);
valueType *makeStringValue(stringType *string);
valueType *makeUndefinedValue(void);
/* Check if operand is the accumulator */
valueType *
isARegisterBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isARegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -63,13 +61,11 @@ isARegisterBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is DIRECT */
valueType *
isDirectModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isDirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -82,13 +78,11 @@ isDirectModeBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is IMMEDIATE */
valueType *
isImmediateModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isImmediateModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -101,13 +95,11 @@ isImmediateModeBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is INDEXED (either X or Y) */
valueType *
isIndexedModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -123,13 +115,11 @@ isIndexedModeBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is INDIRECT */
valueType *
isIndirectModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isIndirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -142,13 +132,11 @@ isIndirectModeBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is POST-INDEXED */
valueType *
isPostIndexedModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isPostIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -161,13 +149,11 @@ isPostIndexedModeBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is PRE-INDEXED */
valueType *
isPreIndexedModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isPreIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -181,13 +167,11 @@ isPreIndexedModeBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is X-INDEXED */
valueType *
isXIndexedModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isXIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -201,13 +185,11 @@ isXIndexedModeBIF(parameterList, kindOfFixup)
/* Check if an operand is the X index register */
valueType *
isXRegisterBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isXRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -220,13 +202,11 @@ isXRegisterBIF(parameterList, kindOfFixup)
/* Check if an operand's address mode is Y-INDEXED */
valueType *
isYIndexedModeBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isYIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);
@ -240,13 +220,11 @@ isYIndexedModeBIF(parameterList, kindOfFixup)
/* Check if an operand is the Y index register */
valueType *
isYRegisterBIF(parameterList, kindOfFixup)
operandListType *parameterList;
fixupKindType kindOfFixup;
isYRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
{
valueType *evaluatedParameter;
valueType *evaluateOperand();
valueType *evaluateOperand(operandType *operand);
if (parameterList != NULL) {
evaluatedParameter = evaluateOperand(parameterList);

View File

@ -44,8 +44,14 @@ int tablevel = 0;
#define nullPrint(thing) if (thing==NULL) { tab(); printf("()\n"); return; }
/* For keeping nested structures looking pretty */
void
tab()
extern void printOperandKind (operandKindType kind);
extern void printToken (int token);
extern void printCondition (conditionType condition);
extern void printOperand (operandType *operand);
void
tab(void)
{
int n;
@ -62,8 +68,7 @@ tab()
*/
void
printAssignmentKind(assignmentKind)
assignmentKindType assignmentKind;
printAssignmentKind(assignmentKindType assignmentKind)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'assignmentKindType'. */
@ -86,8 +91,7 @@ printAssignmentKind(assignmentKind)
}
void
printExpressionKind(kind)
expressionTermKindType kind;
printExpressionKind(expressionTermKindType kind)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'expressionTermKindType'. */
@ -112,8 +116,7 @@ printExpressionKind(kind)
}
stringType *
statementKindString(kind)
statementKindType kind;
statementKindString(statementKindType kind)
{
/* This table MUST be maintained congruently with the definition of
the enumerated type 'statementKindType'. */
@ -161,8 +164,7 @@ static char *statementKindTable[] = {
}
void
printStatementKind(kind)
statementKindType kind;
printStatementKind(statementKindType kind)
{
printf("%s", statementKindString(kind));
}
@ -173,8 +175,7 @@ printStatementKind(kind)
*/
void
printValue(value)
valueType *value;
printValue(valueType *value)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'valueKindType'. */
@ -207,8 +208,7 @@ printValue(value)
}
void
printSymbol(symbol)
symbolTableEntryType *symbol;
printSymbol(symbolTableEntryType *symbol)
{
/* This table MUST be maintained congruent with the definition of the
enumerated type 'symbolUsageKindType'. */
@ -243,8 +243,7 @@ printSymbol(symbol)
}
void
printArgumentDefinitionList(list)
argumentDefinitionListType *list;
printArgumentDefinitionList(argumentDefinitionListType *list)
{
nullPrint(list);
tab(); printf("(arguments:\n");
@ -258,10 +257,9 @@ printArgumentDefinitionList(list)
}
void
printBlock(block)
blockType *block;
printBlock(blockType *block)
{
void printStatement();
void printStatement(statementType *statement);
nullPrint(block);
tab(); printf("(block:\n");
@ -272,10 +270,9 @@ printBlock(block)
}
void
printArrayTerm(arrayTerm)
arrayTermType *arrayTerm;
printArrayTerm(arrayTermType *arrayTerm)
{
void printIdentifier();
void printIdentifier(symbolTableEntryType *identifier);
nullPrint(arrayTerm);
tab(); printf("(array\n");
@ -287,8 +284,7 @@ printArrayTerm(arrayTerm)
}
void
printAssignmentTerm(assignmentTerm)
binopTermType *assignmentTerm;
printAssignmentTerm(binopTermType *assignmentTerm)
{
nullPrint(assignmentTerm);
@ -303,10 +299,9 @@ printAssignmentTerm(assignmentTerm)
}
void
printBinopTerm(binopTerm)
binopTermType *binopTerm;
printBinopTerm(binopTermType *binopTerm)
{
void printIdentifier();
void printIdentifier(symbolTableEntryType *identifier);
nullPrint(binopTerm);
tab(); printf("(binop [");
@ -323,10 +318,9 @@ printBinopTerm(binopTerm)
}
void
printFunctionCall(functionCall)
functionCallTermType *functionCall;
printFunctionCall(functionCallTermType *functionCall)
{
void printOperandList();
void printOperandList(operandListType *operandList);
nullPrint(functionCall);
tab(); printf("(function call %s\n", functionCall->functionName->
@ -338,29 +332,26 @@ printFunctionCall(functionCall)
}
void
printHere()
printHere(void)
{
tab(); printf("(here)\n");
}
void
printIdentifier(identifier)
symbolTableEntryType *identifier;
printIdentifier(symbolTableEntryType *identifier)
{
nullPrint(identifier);
printSymbol(identifier);
}
void
printNumber(number)
numberTermType number;
printNumber(numberTermType number)
{
tab(); printf("(number: %d)\n", number);
}
void
printPostopTerm(postopTerm)
postOpTermType *postopTerm;
printPostopTerm(postOpTermType *postopTerm)
{
nullPrint(postopTerm);
tab(); printf("(postop [");
@ -373,8 +364,7 @@ printPostopTerm(postopTerm)
}
void
printPreopTerm(preopTerm)
preOpTermType *preopTerm;
printPreopTerm(preOpTermType *preopTerm)
{
nullPrint(preopTerm);
tab(); printf("(preop [");
@ -387,8 +377,7 @@ printPreopTerm(preopTerm)
}
void
printUnopTerm(unopTerm)
unopTermType *unopTerm;
printUnopTerm(unopTermType *unopTerm)
{
nullPrint(unopTerm);
tab(); printf("(unop [");
@ -401,8 +390,7 @@ printUnopTerm(unopTerm)
}
void
printExpression(expression)
expressionType *expression;
printExpression(expressionType *expression)
{
nullPrint(expression);
tab(); printf("(expression: [");
@ -477,8 +465,7 @@ printExpression(expression)
}
void
printExpressionList(expressionList)
expressionListType *expressionList;
printExpressionList(expressionListType *expressionList)
{
while (expressionList != NULL) {
printExpression(expressionList->theExpression);
@ -487,8 +474,7 @@ printExpressionList(expressionList)
}
void
printIdentifierList(identifierList)
identifierListType *identifierList;
printIdentifierList(identifierListType *identifierList)
{
nullPrint(identifierList);
printSymbol(identifierList->theSymbol);
@ -502,8 +488,7 @@ printIdentifierList(identifierList)
*/
void
printCase(aCase)
caseType *aCase;
printCase(caseType *aCase)
{
tab(); printf("(case:\n"); tablevel++;
if (aCase->caseTags == NULL) {
@ -520,8 +505,7 @@ printCase(aCase)
}
void
printCaseList(caseList)
caseListType *caseList;
printCaseList(caseListType *caseList)
{
tab(); printf("(cases:\n");
tablevel++;
@ -534,24 +518,21 @@ printCaseList(caseList)
}
void
printMacro(macroInstruction)
macroTableEntryType *macroInstruction;
printMacro(macroTableEntryType *macroInstruction)
{
nullPrint(macroInstruction);
tab(); printf("(macro: %s)\n", macroInstruction->macroName);
}
void
printOpcode(opcode)
opcodeTableEntryType *opcode;
printOpcode(opcodeTableEntryType *opcode)
{
nullPrint(opcode);
tab(); printf("(opcode: %s)\n", opcode->mnemonic);
}
void
printOperandList(operandList)
operandListType *operandList;
printOperandList(operandListType *operandList)
{
nullPrint(operandList);
printOperand(operandList);
@ -560,16 +541,14 @@ printOperandList(operandList)
}
void
printAlignStatement(alignStatement)
alignStatementBodyType *alignStatement;
printAlignStatement(alignStatementBodyType *alignStatement)
{
nullPrint(alignStatement);
printExpression(alignStatement);
}
void
printAssertStatement(assertStatement)
assertStatementBodyType *assertStatement;
printAssertStatement(assertStatementBodyType *assertStatement)
{
nullPrint(assertStatement);
printExpression(assertStatement->condition);
@ -577,24 +556,21 @@ printAssertStatement(assertStatement)
}
void
printBlockStatement(blockStatement)
blockStatementBodyType *blockStatement;
printBlockStatement(blockStatementBodyType *blockStatement)
{
nullPrint(blockStatement);
printExpressionList(blockStatement);
}
void
printByteStatement(byteStatement)
byteStatementBodyType *byteStatement;
printByteStatement(byteStatementBodyType *byteStatement)
{
nullPrint(byteStatement);
printExpressionList(byteStatement);
}
void
printConstrainStatement(constrainStatement)
constrainStatementBodyType *constrainStatement;
printConstrainStatement(constrainStatementBodyType *constrainStatement)
{
nullPrint(constrainStatement);
printExpression(constrainStatement->constraint);
@ -602,16 +578,14 @@ printConstrainStatement(constrainStatement)
}
void
printDbyteStatement(dbyteStatement)
dbyteStatementBodyType *dbyteStatement;
printDbyteStatement(dbyteStatementBodyType *dbyteStatement)
{
nullPrint(dbyteStatement);
printExpressionList(dbyteStatement);
}
void
printDefineStatement(defineStatement)
defineStatementBodyType *defineStatement;
printDefineStatement(defineStatementBodyType *defineStatement)
{
nullPrint(defineStatement);
printSymbol(defineStatement->theSymbol);
@ -619,8 +593,7 @@ printDefineStatement(defineStatement)
}
void
printDoUntilStatement(doUntilStatement)
doUntilStatementBodyType *doUntilStatement;
printDoUntilStatement(doUntilStatementBodyType *doUntilStatement)
{
nullPrint(doUntilStatement);
printBlock(doUntilStatement->doUntilLoop);
@ -630,8 +603,7 @@ printDoUntilStatement(doUntilStatement)
}
void
printDoWhileStatement(doWhileStatement)
doWhileStatementBodyType *doWhileStatement;
printDoWhileStatement(doWhileStatementBodyType *doWhileStatement)
{
nullPrint(doWhileStatement);
printBlock(doWhileStatement->doWhileLoop);
@ -641,24 +613,21 @@ printDoWhileStatement(doWhileStatement)
}
void
printExternStatement(externStatement)
externStatementBodyType *externStatement;
printExternStatement(externStatementBodyType *externStatement)
{
nullPrint(externStatement);
printIdentifierList(externStatement);
}
void
printFreturnStatement(freturnStatement)
freturnStatementBodyType *freturnStatement;
printFreturnStatement(freturnStatementBodyType *freturnStatement)
{
nullPrint(freturnStatement);
printExpression(freturnStatement);
}
void
printFunctionStatement(functionStatement)
functionStatementBodyType *functionStatement;
printFunctionStatement(functionStatementBodyType *functionStatement)
{
nullPrint(functionStatement);
tab();printf("(function name: %s)\n",functionStatement->functionName);
@ -667,8 +636,7 @@ printFunctionStatement(functionStatement)
}
void
printIfStatement(ifStatement)
ifStatementBodyType *ifStatement;
printIfStatement(ifStatementBodyType *ifStatement)
{
nullPrint(ifStatement);
tab(); printf("(condition: ");
@ -683,16 +651,14 @@ printIfStatement(ifStatement)
}
void
printIncludeStatement(includeStatement)
includeStatementBodyType *includeStatement;
printIncludeStatement(includeStatementBodyType *includeStatement)
{
nullPrint(includeStatement);
printExpression(includeStatement);
}
void
printInstructionStatement(instructionStatement)
instructionStatementBodyType *instructionStatement;
printInstructionStatement(instructionStatementBodyType *instructionStatement)
{
nullPrint(instructionStatement);
switch(instructionStatement->kindOfInstruction) {
@ -713,16 +679,14 @@ printInstructionStatement(instructionStatement)
}
void
printLongStatement(longStatement)
longStatementBodyType *longStatement;
printLongStatement(longStatementBodyType *longStatement)
{
nullPrint(longStatement);
printExpressionList(longStatement);
}
void
printMacroStatement(macroStatement)
macroStatementBodyType *macroStatement;
printMacroStatement(macroStatementBodyType *macroStatement)
{
nullPrint(macroStatement);
tab(); printf("(macro name: %s)\n", macroStatement->theMacro);
@ -731,8 +695,7 @@ printMacroStatement(macroStatement)
}
void
printMdefineStatement(mdefineStatement)
defineStatementBodyType *mdefineStatement;
printMdefineStatement(defineStatementBodyType *mdefineStatement)
{
nullPrint(mdefineStatement);
printSymbol(mdefineStatement->theSymbol);
@ -740,8 +703,7 @@ printMdefineStatement(mdefineStatement)
}
void
printMdoUntilStatement(mdoUntilStatement)
mdoUntilStatementBodyType *mdoUntilStatement;
printMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
{
nullPrint(mdoUntilStatement);
printBlock(mdoUntilStatement->mdoUntilLoop);
@ -749,8 +711,7 @@ printMdoUntilStatement(mdoUntilStatement)
}
void
printMdoWhileStatement(mdoWhileStatement)
mdoWhileStatementBodyType *mdoWhileStatement;
printMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
{
nullPrint(mdoWhileStatement);
printBlock(mdoWhileStatement->mdoWhileLoop);
@ -758,8 +719,7 @@ printMdoWhileStatement(mdoWhileStatement)
}
void
printMforStatement(mforStatement)
mforStatementBodyType *mforStatement;
printMforStatement(mforStatementBodyType *mforStatement)
{
nullPrint(mforStatement);
printExpression(mforStatement->initExpression);
@ -769,8 +729,7 @@ printMforStatement(mforStatement)
}
void
printMifStatement(mifStatement)
mifStatementBodyType *mifStatement;
printMifStatement(mifStatementBodyType *mifStatement)
{
nullPrint(mifStatement);
printExpression(mifStatement->mifCondition);
@ -783,8 +742,7 @@ printMifStatement(mifStatement)
}
void
printMswitchStatement(mswitchStatement)
mswitchStatementBodyType *mswitchStatement;
printMswitchStatement(mswitchStatementBodyType *mswitchStatement)
{
nullPrint(mswitchStatement);
printExpression(mswitchStatement->switchExpression);
@ -792,8 +750,7 @@ printMswitchStatement(mswitchStatement)
}
void
printMvariableStatement(mvariableStatement)
mvariableStatementBodyType *mvariableStatement;
printMvariableStatement(mvariableStatementBodyType *mvariableStatement)
{
nullPrint(mvariableStatement);
printSymbol(mvariableStatement->theSymbol);
@ -801,8 +758,7 @@ printMvariableStatement(mvariableStatement)
}
void
printMwhileStatement(mwhileStatement)
mwhileStatementBodyType *mwhileStatement;
printMwhileStatement(mwhileStatementBodyType *mwhileStatement)
{
nullPrint(mwhileStatement);
printExpression(mwhileStatement->mwhileCondition);
@ -810,47 +766,41 @@ printMwhileStatement(mwhileStatement)
}
void
printOrgStatement(orgStatement)
orgStatementBodyType *orgStatement;
printOrgStatement(orgStatementBodyType *orgStatement)
{
nullPrint(orgStatement);
printExpression(orgStatement);
}
void
printPerformStatement(performStatement)
performStatementBodyType *performStatement;
printPerformStatement(performStatementBodyType *performStatement)
{
nullPrint(performStatement);
printExpression(performStatement);
}
void
printRelStatement(relStatement)
relStatementBodyType *relStatement;
printRelStatement(relStatementBodyType *relStatement)
{
/* there's nothing here... */
}
void
printStartStatement(startStatement)
startStatementBodyType *startStatement;
printStartStatement(startStatementBodyType *startStatement)
{
nullPrint(startStatement);
printExpression(startStatement);
}
void
printStringStatement(stringStatement)
stringStatementBodyType *stringStatement;
printStringStatement(stringStatementBodyType *stringStatement)
{
nullPrint(stringStatement);
printExpressionList(stringStatement);
}
void
printStructStatement(structStatement)
structStatementBodyType *structStatement;
printStructStatement(structStatementBodyType *structStatement)
{
nullPrint(structStatement);
printSymbol(structStatement->structName);
@ -858,24 +808,21 @@ printStructStatement(structStatement)
}
void
printTargetStatement(targetStatement)
targetStatementBodyType *targetStatement;
printTargetStatement(targetStatementBodyType *targetStatement)
{
nullPrint(targetStatement);
printExpression(targetStatement);
}
void
printUndefineStatement(undefineStatement)
undefineStatementBodyType *undefineStatement;
printUndefineStatement(undefineStatementBodyType *undefineStatement)
{
nullPrint(undefineStatement);
printIdentifierList(undefineStatement);
}
void
printVariableStatement(variableStatement)
variableStatementBodyType *variableStatement;
printVariableStatement(variableStatementBodyType *variableStatement)
{
nullPrint(variableStatement);
printSymbol(variableStatement->theSymbol);
@ -883,8 +830,7 @@ printVariableStatement(variableStatement)
}
void
printWhileStatement(whileStatement)
whileStatementBodyType *whileStatement;
printWhileStatement(whileStatementBodyType *whileStatement)
{
nullPrint(whileStatement);
tab(); printf("(condition: ");
@ -894,16 +840,14 @@ printWhileStatement(whileStatement)
}
void
printWordStatement(wordStatement)
wordStatementBodyType *wordStatement;
printWordStatement(wordStatementBodyType *wordStatement)
{
nullPrint(wordStatement);
printExpressionList(wordStatement);
}
void
printLabelList(labelList)
labelListType *labelList;
printLabelList(labelListType *labelList)
{
nullPrint(labelList);
tab(); printf("(\n");
@ -917,9 +861,7 @@ printLabelList(labelList)
}
void
printStatementBody(kind, body)
statementKindType kind;
statementBodyType body;
printStatementBody(statementKindType kind, statementBodyType body)
{
switch (kind) {
@ -1082,8 +1024,7 @@ printStatementBody(kind, body)
}
void
printStatement(statement)
statementType *statement;
printStatement(statementType *statement)
{
nullPrint(statement);
tab(); printf("(statement[");
@ -1104,8 +1045,7 @@ printStatement(statement)
*/
void
printPendingFixupList(fixupList)
fixupListType *fixupList;
printPendingFixupList(fixupListType *fixupList)
{
printf("fixup list: (");
tablevel++;
@ -1118,10 +1058,7 @@ printPendingFixupList(fixupList)
}
void
printCreateFixup(expression, location, kindOfFixup)
expressionType *expression;
addressType location;
fixupKindType kindOfFixup;
printCreateFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup)
{
static char *fixupStringTable[] = {
"BYTE FIXUP",
@ -1145,7 +1082,7 @@ printCreateFixup(expression, location, kindOfFixup)
*/
void
printExpressionBuffer()
printExpressionBuffer(void)
{
int line;
int i;
@ -1160,9 +1097,7 @@ printExpressionBuffer()
}
void
printOneCodeBuffer(codeSegment, bufferNum)
codeSegmentType *codeSegment;
int bufferNum;
printOneCodeBuffer(codeSegmentType *codeSegment, int bufferNum)
{
int line;
int i;
@ -1190,8 +1125,7 @@ printOneCodeBuffer(codeSegment, bufferNum)
}
void
printCodeBufferSection(codeBufferSection)
codeRegionType *codeBufferSection;
printCodeBufferSection(codeRegionType *codeBufferSection)
{
bool anyCodeThereFlag;
int i;
@ -1209,7 +1143,7 @@ printCodeBufferSection(codeBufferSection)
}
void
printCodeBuffers()
printCodeBuffers(void)
{
printf("absolute code:\n");
printCodeBufferSection(&absoluteCodeRegion);

View File

@ -39,9 +39,14 @@ int tablevel;
/* Fundamental nop print operation */
#define nullPrint(thing) if (thing==NULL) { tab(); printf("()\n"); return; }
void
printCondition(condition)
conditionType condition;
extern void tab (void);
extern void printExpression (expressionType *expression);
extern void printIdentifierList (identifierListType *identifierList);
extern void printBlock (blockType *block);
void
printCondition(conditionType condition)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'conditionType'. */
@ -70,8 +75,7 @@ printCondition(condition)
}
void
printOperandKind(kind)
operandKindType kind;
printOperandKind(operandKindType kind)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'operandKindType'. */
@ -97,8 +101,7 @@ printOperandKind(kind)
}
void
printToken(token)
int token;
printToken(int token)
{
/* This table MUST be maintained congruently with the set of '#define's in
the file 'y.tab.h' as produced by yacc. */
@ -193,8 +196,7 @@ printToken(token)
}
void
printOperand(operand)
operandType *operand;
printOperand(operandType *operand)
{
nullPrint(operand);
tab(); printf("(operand: [");

View File

@ -38,8 +38,7 @@ char *m68000 = "68000";
char **mlist;
main(argc, argv)
char **argv;
main(int argc, char **argv)
{
char *processor = m6502;
int i;

View File

@ -37,11 +37,16 @@
branching from the current location given a condition to branch upon and a
target address. */
void
emitRelativeBranch(condition, target, fixupLocation)
conditionType condition;
valueType *target;
valueType fixupLocation[COMPOUND_BRANCH_MAX];
extern void emitByte (byte byteValue);
extern void emitRelativeByteOffset (valueType *target);
extern void botch (char *message, ...);
extern void emitWord (wordType wordValue);
extern void noteAnonymousReference (void);
extern void emitWordValue (valueType *wordValue);
void
emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupLocation)
{
int i;
@ -139,14 +144,12 @@ emitRelativeBranch(condition, target, fixupLocation)
/* emitJump emits a 6502 jump instruction given the target address */
simpleFixupListType *
emitJump(target, previousFixups)
valueType *target;
simpleFixupListType *previousFixups;
emitJump(valueType *target, simpleFixupListType *previousFixups)
{
simpleFixupListType *result;
valueType picFixup[COMPOUND_BRANCH_MAX];
simpleFixupListType *buildSimpleFixupList();
simpleFixupListType *buildSimpleFixupList(valueType locationToFixup, simpleFixupListType *previousList);
#define JUMP_OPCODE 0x4C

View File

@ -62,10 +62,19 @@
/* incarnateCodeBuffer causes code buffer space to actually be allocated */
void
incarnateCodeBuffer(bufferNum, bufferKind)
int bufferNum;
codeBufferKindType bufferKind;
extern void fatalError (errorType theError, ...);
extern bool byteCheck (int value);
extern void printValue (valueType *value);
extern void error (errorType theError, ...);
extern char *valueKindString (valueKindType valueKind);
extern bool wordCheck (int value);
extern bool isByteOffset (int value);
extern bool isWordOffset (int value);
extern void noteAnonymousReference (void);
void
incarnateCodeBuffer(int bufferNum, codeBufferKindType bufferKind)
{
codeSegmentType *newCodeSegment;
codeBufferType *newCodeBuffer;
@ -88,9 +97,7 @@ incarnateCodeBuffer(bufferNum, bufferKind)
care to make sure said buffer actually exists before using it. */
void
putByte(address, byteValue)
addressType address;
byte byteValue;
putByte(addressType address, byte byteValue)
{
int bufferNum;
int bufferPos;
@ -131,9 +138,7 @@ putByte(address, byteValue)
buffer */
void
mapByte(address, byteValue)
int address;
byte byteValue;
mapByte(int address, byte byteValue)
{
if (address < MAXIMUM_ALLOWED_STRUCT_SIZE)
structScratchBuffer[address] = byteValue;
@ -144,8 +149,7 @@ mapByte(address, byteValue)
code buffer or the current struct assembly buffer */
void
emitByte(byteValue)
byte byteValue;
emitByte(byte byteValue)
{
if (debug || emitPrint)
if (structNestingDepth == 0)
@ -165,8 +169,7 @@ emitByte(byteValue)
/* emitWord similarly emits a word */
void
emitWord(wordValue)
wordType wordValue;
emitWord(wordType wordValue)
{
byteToWordType convert;
int loByte, hiByte;
@ -216,8 +219,7 @@ emitWord(wordValue)
/* emitLong similarly emits a long */
void
emitLong(longValue)
longType longValue;
emitLong(longType longValue)
{
byteToLongType convert;
int loByte, secondByte, thirdByte, hiByte;
@ -286,8 +288,7 @@ emitLong(longValue)
/* emitByteValue takes the byte to be emitted out of a 'valueType' */
void
emitByteValue(byteValue)
valueType *byteValue;
emitByteValue(valueType *byteValue)
{
if (byteValue->kindOfValue == ABSOLUTE_VALUE || byteValue->kindOfValue ==
RELOCATABLE_VALUE || byteValue->kindOfValue == UNDEFINED_VALUE) {
@ -313,8 +314,7 @@ emitByteValue(byteValue)
/* emitString similarly spits out a string of bytes */
void
emitString(string)
stringType *string;
emitString(stringType *string)
{
if (debug || emitPrint)
if (structNestingDepth == 0)
@ -342,8 +342,7 @@ emitString(string)
/* emitWordValue emits a word out of a 'valueType' */
void
emitWordValue(wordValue)
valueType *wordValue;
emitWordValue(valueType *wordValue)
{
if (wordValue->kindOfValue == ABSOLUTE_VALUE || wordValue->kindOfValue ==
RELOCATABLE_VALUE || wordValue->kindOfValue == UNDEFINED_VALUE) {
@ -369,8 +368,7 @@ emitWordValue(wordValue)
/* emitLongValue emits a long out of a 'valueType' */
void
emitLongValue(longValue)
valueType *longValue;
emitLongValue(valueType *longValue)
{
if (longValue->kindOfValue == ABSOLUTE_VALUE || longValue->kindOfValue ==
RELOCATABLE_VALUE || longValue->kindOfValue == UNDEFINED_VALUE) {
@ -396,9 +394,7 @@ emitLongValue(longValue)
/* pokeByteValue is like 'emitByte' but it's random access */
void
pokeByteValue(location, value)
addressType location;
valueType *value;
pokeByteValue(addressType location, valueType *value)
{
currentLocationCounter.value = location;
emitByteValue(value);
@ -408,9 +404,7 @@ pokeByteValue(location, value)
/* ditto pokeWordValue */
void
pokeWordValue(location, value)
addressType location;
valueType *value;
pokeWordValue(addressType location, valueType *value)
{
currentLocationCounter.value = location;
emitWordValue(value);
@ -420,9 +414,7 @@ pokeWordValue(location, value)
/* ditto pokeLongValue */
void
pokeLongValue(location, value)
addressType location;
valueType *value;
pokeLongValue(addressType location, valueType *value)
{
currentLocationCounter.value = location;
emitLongValue(value);
@ -433,9 +425,7 @@ pokeLongValue(location, value)
relative branches */
void
pokeRelativeByteValue(location, value)
addressType location;
valueType *value;
pokeRelativeByteValue(addressType location, valueType *value)
{
int offset;
@ -456,9 +446,7 @@ pokeRelativeByteValue(location, value)
relative branches */
void
pokeRelativeWordValue(location, value)
addressType location;
valueType *value;
pokeRelativeWordValue(addressType location, valueType *value)
{
int offset;
@ -475,8 +463,7 @@ pokeRelativeWordValue(location, value)
/* getByte fetches a byte back out of the labyrinth of code buffers */
byte
getByte(address)
addressType address;
getByte(addressType address)
{
int bufferNum;
int bufferPos;
@ -494,8 +481,7 @@ getByte(address)
}
void
emitRelativeByteOffset(target)
valueType *target;
emitRelativeByteOffset(valueType *target)
{
int saveTargetOffset;
@ -512,8 +498,7 @@ emitRelativeByteOffset(target)
}
void
emitRelativeWordOffset(target)
valueType *target;
emitRelativeWordOffset(valueType *target)
{
int saveTargetOffset;
@ -531,9 +516,7 @@ emitRelativeWordOffset(target)
has become known. */
void
fixupBranch(location, target)
valueType location[COMPOUND_BRANCH_MAX];
valueType target;
fixupBranch(valueType *location, valueType target)
{
valueType saveCurrentLocation;
int saveTargetOffset;
@ -554,9 +537,7 @@ fixupBranch(location, target)
/* fixupJump similarly repairs a jump */
void
fixupJump(locations, target)
simpleFixupListType *locations;
valueType target;
fixupJump(simpleFixupListType *locations, valueType target)
{
valueType saveCurrentLocation;
simpleFixupListType *oldLocation;

105
encode.c
View File

@ -39,9 +39,20 @@
bool encodingFunction;
bool
encodeByte(aByte)
byte aByte;
extern void error (errorType theError, ...);
bool encodeIdentifier (symbolTableEntryType *identifier);
bool encodeExpression (expressionType *expression);
bool encodeValue (valueType *value);
bool encodeOperand (operandType *operand);
bool encodeString (stringType *string);
extern char *valueKindString (valueKindType valueKind);
extern void botch (char *message, ...);
bool encodeBlock (blockType *block);
extern stringType *statementKindString (statementKindType kind);
bool
encodeByte(byte aByte)
{
if (expressionBufferSize < EXPRESSION_BUFFER_LIMIT) {
expressionBuffer[expressionBufferSize++] = aByte;
@ -53,8 +64,7 @@ encodeByte(aByte)
}
bool
encodeBigword(bigword)
int bigword;
encodeBigword(int bigword)
{
int i;
for (i=0; i<sizeof(int); ++i) {
@ -66,8 +76,7 @@ encodeBigword(bigword)
}
bool
encodeAssignmentTerm(assignmentTerm)
binopTermType *assignmentTerm;
encodeAssignmentTerm(binopTermType *assignmentTerm)
{
nullEncode(assignmentTerm);
if ((assignmentKindType)assignmentTerm->binop != ASSIGN_ASSIGN) {
@ -83,10 +92,9 @@ encodeAssignmentTerm(assignmentTerm)
}
bool
encodeBinopTerm(binopTerm)
binopTermType *binopTerm;
encodeBinopTerm(binopTermType *binopTerm)
{
bool encodeExpression();
bool encodeExpression(expressionType *expression);
nullEncode(binopTerm);
return (
@ -98,8 +106,7 @@ encodeBinopTerm(binopTerm)
}
bool
encodeCondition(condition)
conditionType condition;
encodeCondition(conditionType condition)
{
return(
encodeByte(CONDITION_CODE_TAG) &&
@ -108,8 +115,7 @@ encodeCondition(condition)
}
int
functionNumber(function)
functionDefinitionType *function;
functionNumber(functionDefinitionType *function)
{
if (function->ordinal == -1) {
function->ordinal = externalFunctionCount++;
@ -126,8 +132,7 @@ functionNumber(function)
}
bool
encodeFunctionCall(functionCall)
functionCallTermType *functionCall;
encodeFunctionCall(functionCallTermType *functionCall)
{
functionDefinitionType *theFunction;
int functionOrdinal;
@ -177,14 +182,13 @@ encodeFunctionCall(functionCall)
}
bool
encodeHere()
encodeHere(void)
{
return(encodeByte(HERE_TAG));
}
bool
encodeIdentifier(identifier)
symbolTableEntryType *identifier;
encodeIdentifier(symbolTableEntryType *identifier)
{
symbolInContextType *workingContext;
environmentType *saveEnvironment;
@ -248,8 +252,7 @@ encodeIdentifier(identifier)
}
bool
encodeNumber(number)
numberTermType number;
encodeNumber(numberTermType number)
{
return(
encodeByte(NUMBER_TAG) &&
@ -258,8 +261,7 @@ encodeNumber(number)
}
bool
encodeRelocatableNumber(number)
numberTermType number;
encodeRelocatableNumber(numberTermType number)
{
return(
encodeByte(RELOCATABLE_TAG) &&
@ -268,8 +270,7 @@ encodeRelocatableNumber(number)
}
bool
encodeOperand(operand)
operandType *operand;
encodeOperand(operandType *operand)
{
switch (operand->kindOfOperand) {
case EXPRESSION_OPND:
@ -303,8 +304,7 @@ encodeOperand(operand)
}
bool
encodePostopTerm(postopTerm)
postOpTermType *postopTerm;
encodePostopTerm(postOpTermType *postopTerm)
{
nullEncode(postopTerm);
return(
@ -315,8 +315,7 @@ encodePostopTerm(postopTerm)
}
bool
encodePreopTerm(preopTerm)
preOpTermType *preopTerm;
encodePreopTerm(preOpTermType *preopTerm)
{
nullEncode(preopTerm);
return(
@ -327,8 +326,7 @@ encodePreopTerm(preopTerm)
}
bool
encodeString(string)
stringType *string;
encodeString(stringType *string)
{
if (!encodeByte(STRING_TAG))
return(FALSE);
@ -340,8 +338,7 @@ encodeString(string)
}
bool
encodeUnopTerm(unopTerm)
unopTermType *unopTerm;
encodeUnopTerm(unopTermType *unopTerm)
{
nullEncode(unopTerm);
return(
@ -352,8 +349,7 @@ encodeUnopTerm(unopTerm)
}
bool
encodeValue(value)
valueType *value;
encodeValue(valueType *value)
{
switch (value->kindOfValue) {
case ABSOLUTE_VALUE:
@ -389,8 +385,7 @@ encodeValue(value)
}
bool
encodeExpression(expression)
expressionType *expression;
encodeExpression(expressionType *expression)
{
nullEncode(expression);
switch (expression->kindOfTerm) {
@ -460,8 +455,7 @@ encodeExpression(expression)
}
bool
encodeAssertStatement(assertStatement)
assertStatementBodyType *assertStatement;
encodeAssertStatement(assertStatementBodyType *assertStatement)
{
return(
encodeByte(ASSERT_TAG) &&
@ -471,8 +465,7 @@ encodeAssertStatement(assertStatement)
}
bool
encodeFreturnStatement(freturnStatement)
freturnStatementBodyType *freturnStatement;
encodeFreturnStatement(freturnStatementBodyType *freturnStatement)
{
return(
encodeByte(FRETURN_TAG) &&
@ -481,8 +474,7 @@ encodeFreturnStatement(freturnStatement)
}
bool
encodeMdefineStatement(mdefineStatement)
defineStatementBodyType *mdefineStatement;
encodeMdefineStatement(defineStatementBodyType *mdefineStatement)
{
return(
encodeByte(MDEFINE_TAG) &&
@ -492,8 +484,7 @@ encodeMdefineStatement(mdefineStatement)
}
bool
encodeMdoUntilStatement(mdoUntilStatement)
mdoUntilStatementBodyType *mdoUntilStatement;
encodeMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
{
return(
encodeByte(MDOUNTIL_TAG) &&
@ -503,8 +494,7 @@ encodeMdoUntilStatement(mdoUntilStatement)
}
bool
encodeMdoWhileStatement(mdoWhileStatement)
mdoWhileStatementBodyType *mdoWhileStatement;
encodeMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
{
return(
encodeByte(MDOWHILE_TAG) &&
@ -514,8 +504,7 @@ encodeMdoWhileStatement(mdoWhileStatement)
}
bool
encodeMforStatement(mforStatement)
mforStatementBodyType *mforStatement;
encodeMforStatement(mforStatementBodyType *mforStatement)
{
return(
encodeByte(MFOR_TAG) &&
@ -527,8 +516,7 @@ encodeMforStatement(mforStatement)
}
bool
encodeMifStatement(mifStatement)
mifStatementBodyType *mifStatement;
encodeMifStatement(mifStatementBodyType *mifStatement)
{
return(
encodeByte(MIF_TAG) &&
@ -539,8 +527,7 @@ encodeMifStatement(mifStatement)
}
bool
encodeMswitchStatement(mswitchStatement)
mswitchStatementBodyType *mswitchStatement;
encodeMswitchStatement(mswitchStatementBodyType *mswitchStatement)
{
caseListType *caseList;
caseType *theCase;
@ -564,8 +551,7 @@ encodeMswitchStatement(mswitchStatement)
}
bool
encodeMvariableStatement(mvariableStatement)
mvariableStatementBodyType *mvariableStatement;
encodeMvariableStatement(mvariableStatementBodyType *mvariableStatement)
{
int length;
@ -585,8 +571,7 @@ encodeMvariableStatement(mvariableStatement)
}
bool
encodeMwhileStatement(mwhileStatement)
mwhileStatementBodyType *mwhileStatement;
encodeMwhileStatement(mwhileStatementBodyType *mwhileStatement)
{
return(
encodeByte(MWHILE_TAG) &&
@ -596,8 +581,7 @@ encodeMwhileStatement(mwhileStatement)
}
bool
encodeStatement(statement)
statementType *statement;
encodeStatement(statementType *statement)
{
switch(statement->kindOfStatement) {
@ -677,8 +661,7 @@ encodeStatement(statement)
}
bool
encodeBlock(block)
blockType *block;
encodeBlock(blockType *block)
{
if (!encodeByte(BLOCK_TAG))
return(FALSE);

View File

@ -39,7 +39,12 @@ bool nullStatementFlag;
input up to the end of the line, in a (probably futile) effort to recover
from the booboo. */
void
void verror (errorType theError, va_list ap);
void fatalError (errorType theError, ...);
extern void chokePukeAndDie (void);
void
puntOnError(errorType theError, ...)
{
va_list ap;
@ -289,8 +294,7 @@ fatalSystemError(errorType theError, ...)
the error message as a string (this is almost always 'syntax error'). */
void
yyerror(s)
char *s;
yyerror(char *s)
{
printf("\"%s\", line %d: %s\n", currentFileName, currentLineNumber,s);
fflush(stdout);
@ -304,8 +308,7 @@ yyerror(s)
in a sentence). */
char *
usageString(usageKind)
symbolUsageKindType usageKind;
usageString(symbolUsageKindType usageKind)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'symbolUsageKindType'. */
@ -336,8 +339,7 @@ usageString(usageKind)
/* valueKindString similarly deals with the different kinds of values. */
char *
valueKindString(valueKind)
valueKindType valueKind;
valueKindString(valueKindType valueKind)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'valueKindType'. */
@ -366,8 +368,7 @@ valueKindString(valueKind)
/* assignmentString similarly handles assignments */
char *
assignmentString(assignment)
assignmentKindType assignment;
assignmentString(assignmentKindType assignment)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'assignmentKindType'. */

View File

@ -64,10 +64,32 @@ stringType *dbString;
#define moreStuff(f) (generatingFixup ? moreExpression(f) : moreText(f))
#define moreStuff1(f,x) (generatingFixup? moreExpression(f,x) : moreText(f,x))
anyOldThing *
arrayLookup(arrayTerm, kindOfThing)
arrayTermType *arrayTerm;
valueKindType *kindOfThing;
extern void error (errorType theError, ...);
extern char *valueKindString (valueKindType valueKind);
extern void moreExpression (char *format, ...);
extern valueType *evaluateOperand (operandType *operand);
extern char *tokenString (int token);
extern char *assignmentString (assignmentKindType assignment);
extern char *usageString (symbolUsageKindType usageKind);
extern valueType *makeUndefinedValue (void);
extern void botch (char *message, ...);
extern char *conditionString (conditionType condition);
extern int bindFunctionArguments (argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *functionName);
extern void assembleBlock (blockType *block);
extern void unbindArguments (argumentDefinitionListType *argumentList, int numberToUnbind);
extern void unbindLocalVariables (identifierListType *identifierList);
extern void reincarnateSymbol (symbolInContextType *context, symbolUsageKindType newUsage);
extern bool shouldParenthesize (operandType *operand);
extern void moreText (char *format, ...);
extern void endLine (void);
extern void tabIndent (void);
extern void flushExpressionString (void);
extern operandType *buildOperand (operandKindType kindOfOperand, anyOldThing *arg);
extern expressionType *generateFixupExpression (expressionType *expression);
anyOldThing *
arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing)
{
valueType *arrayValue;
valueType *indexValue;
@ -124,8 +146,7 @@ arrayLookup(arrayTerm, kindOfThing)
}
valueType *
evaluateArrayTerm(arrayTerm)
arrayTermType *arrayTerm;
evaluateArrayTerm(arrayTermType *arrayTerm)
{
anyOldThing *resultThing;
valueKindType kindOfResult;
@ -169,9 +190,7 @@ evaluateArrayTerm(arrayTerm)
}
valueType *
evaluateAssignmentTerm(assignmentTerm, kindOfFixup)
binopTermType *assignmentTerm;
fixupKindType kindOfFixup;
evaluateAssignmentTerm(binopTermType *assignmentTerm, fixupKindType kindOfFixup)
{
symbolTableEntryType *targetSymbol;
valueType *target;
@ -363,10 +382,7 @@ evaluateAssignmentTerm(assignmentTerm, kindOfFixup)
}
valueType *
evaluateBinopTerm(binopTerm, isTopLevel, kindOfFixup)
binopTermType *binopTerm;
bool isTopLevel;
fixupKindType kindOfFixup;
evaluateBinopTerm(binopTermType *binopTerm, bool isTopLevel, fixupKindType kindOfFixup)
{
valueType *leftOperand;
valueType *rightOperand;
@ -580,18 +596,14 @@ evaluateBinopTerm(binopTerm, isTopLevel, kindOfFixup)
}
valueType *
evaluateCondition(condition)
conditionType condition;
evaluateCondition(conditionType condition)
{
expand(moreExpression("%s", conditionString(condition)));
return(newValue(CONDITION_VALUE, condition, EXPRESSION_OPND));
}
valueType *
evaluateBuiltInFunctionCall(workingContext, parameters, kindOfFixup)
symbolInContextType *workingContext;
operandListType *parameters;
fixupKindType kindOfFixup;
evaluateBuiltInFunctionCall(symbolInContextType *workingContext, operandListType *parameters, fixupKindType kindOfFixup)
{
sideEffectFlag = TRUE;
return((*builtInFunctionTable[workingContext->value->value].
@ -599,10 +611,7 @@ evaluateBuiltInFunctionCall(workingContext, parameters, kindOfFixup)
}
valueType *
evaluateFunctionCall(functionCall, kindOfFixup, isStandalone)
functionCallTermType *functionCall;
fixupKindType kindOfFixup;
bool isStandalone;
evaluateFunctionCall(functionCallTermType *functionCall, fixupKindType kindOfFixup, bool isStandalone)
{
functionDefinitionType *theFunction;
int numberBound;
@ -682,7 +691,7 @@ evaluateFunctionCall(functionCall, kindOfFixup, isStandalone)
}
valueType *
evaluateHere()
evaluateHere(void)
{
valueType *result;
@ -694,10 +703,7 @@ evaluateHere()
}
valueType *
evaluateIdentifier(identifier, isTopLevel, kindOfFixup)
symbolTableEntryType *identifier;
bool isTopLevel;
fixupKindType kindOfFixup;
evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup)
{
symbolInContextType *workingContext;
valueType *resultValue;
@ -821,16 +827,14 @@ evaluateIdentifier(identifier, isTopLevel, kindOfFixup)
}
valueType *
evaluateNumber(number)
numberTermType number;
evaluateNumber(numberTermType number)
{
expand(moreExpression("0x%x", number));
return(newValue(ABSOLUTE_VALUE, number, EXPRESSION_OPND));
}
valueType *
evaluatePostopTerm(postopTerm)
postOpTermType *postopTerm;
evaluatePostopTerm(postOpTermType *postopTerm)
{
valueType *theOperand;
valueType **theOperandPtr;
@ -897,8 +901,7 @@ evaluatePostopTerm(postopTerm)
}
valueType *
evaluatePreopTerm(preopTerm)
preOpTermType *preopTerm;
evaluatePreopTerm(preOpTermType *preopTerm)
{
valueType *theOperand;
valueType *result;
@ -965,8 +968,7 @@ evaluatePreopTerm(preopTerm)
}
valueType *
evaluateString(string)
stringType *string;
evaluateString(stringType *string)
{
stringType *newString;
@ -977,9 +979,7 @@ evaluateString(string)
}
valueType *
evaluateUnopTerm(unopTerm, kindOfFixup)
unopTermType *unopTerm;
fixupKindType kindOfFixup;
evaluateUnopTerm(unopTermType *unopTerm, fixupKindType kindOfFixup)
{
valueType *theOperand;
valueKindType resultKindOfValue;
@ -1031,11 +1031,7 @@ evaluateUnopTerm(unopTerm, kindOfFixup)
}
valueType *
evaluateExpressionInternally(expression, isTopLevel, kindOfFixup,isStandalone)
expressionType *expression;
bool isTopLevel;
fixupKindType kindOfFixup;
bool isStandalone;
evaluateExpressionInternally(expressionType *expression, bool isTopLevel, fixupKindType kindOfFixup, bool isStandalone)
{
valueType *result;
@ -1125,9 +1121,7 @@ evaluateExpressionInternally(expression, isTopLevel, kindOfFixup,isStandalone)
}
valueType *
evaluateExpression(expression, kindOfFixup)
expressionType *expression;
fixupKindType kindOfFixup;
evaluateExpression(expressionType *expression, fixupKindType kindOfFixup)
{
valueType *result;
@ -1148,8 +1142,7 @@ evaluateExpression(expression, kindOfFixup)
}
void
evaluateExpressionStandalone(expression)
expressionType *expression;
evaluateExpressionStandalone(expressionType *expression)
{
bool saveExpansion;
valueType *expressionResult;
@ -1169,8 +1162,7 @@ evaluateExpressionStandalone(expression)
}
valueType *
evaluateDefineExpression(expression)
expressionType *expression;
evaluateDefineExpression(expressionType *expression)
{
nullEvaluate(expression);
return(newValue(OPERAND_VALUE, buildOperand(EXPRESSION_OPND,
@ -1178,8 +1170,7 @@ evaluateDefineExpression(expression)
}
valueType *
evaluateSelectionList(selectionList)
selectionListType *selectionList;
evaluateSelectionList(selectionListType *selectionList)
{
int offset;

View File

@ -9,7 +9,7 @@ valueType *evaluateBinopTerm(binopTermType *assignmentTerm, bool isTopLevel, fix
valueType *evaluateCondition(conditionType condition);
valueType *evaluateBuiltInFunctionCall(symbolInContextType *workingContext, operandListType *parameters, fixupKindType kindOfFixup);
valueType *evaluateFunctionCall(functionCallTermType *functionCall, fixupKindType kindOfFixup, bool isStandalone);
valueType *evaluateHere();
valueType *evaluateHere(void);
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
valueType *evaluateNumber(numberTermType number);
valueType *evaluatePostopTerm(postOpTermType *postopTerm);

View File

@ -57,12 +57,19 @@ stringType *dbString = "graphics2.m";
The routines below collectively duplicate expressions for later evaluation.
*/
expressionType *
generateFixupExpression(expression)
expressionType *expression;
extern void moreExpression (char *format, ...);
extern bool isUndefined (valueType *value);
extern char *tokenString (int token);
extern void error (errorType theError, ...);
extern char *conditionString (conditionType condition);
extern void botch (char *message, ...);
expressionType *
generateFixupExpression(expressionType *expression)
{
expressionType *result;
expressionType *duplicateExpressionForFixup();
expressionType *duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand);
generatingFixup = TRUE;
result = duplicateExpressionForFixup(expression, TRUE, FALSE);
@ -71,10 +78,7 @@ generateFixupExpression(expression)
}
expressionType *
duplicateExpressionForFixup(expression, isTopLevel, isSpecialFunctionOperand)
expressionType *expression;
bool isTopLevel;
bool isSpecialFunctionOperand;
duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand)
{
expressionType *result;
expressionType *originalResult;
@ -85,15 +89,15 @@ duplicateExpressionForFixup(expression, isTopLevel, isSpecialFunctionOperand)
environmentType *saveEnvironment;
bool saveExpansion;
operandType *duplicateOperandForFixup();
symbolInContextType *getWorkingContext();
functionCallTermType *duplicateFunctionCall();
expressionType *duplicateArrayReference();
valueType *evaluateIdentifier();
valueType *evaluateHere();
valueType *newValue();
symbolTableEntryType *generateLocalLabel();
stringType *saveString();
operandType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
functionCallTermType *duplicateFunctionCall(functionCallTermType *functionCall);
expressionType *duplicateArrayReference(arrayTermType *arrayTerm);
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
valueType *evaluateHere(void);
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
symbolTableEntryType *generateLocalLabel(symbolTableEntryType *symbol);
stringType *saveString(char *s);
nullDup(expression);
result = originalResult = typeAlloc(expressionType);
@ -280,14 +284,13 @@ duplicateExpressionForFixup(expression, isTopLevel, isSpecialFunctionOperand)
}
functionCallTermType *
duplicateFunctionCall(functionCall)
functionCallTermType *functionCall;
duplicateFunctionCall(functionCallTermType *functionCall)
{
functionCallTermType *result;
operandListType **argument;
operandListType *parameterList;
operandListType *duplicateOperandForFixup();
operandListType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
result = typeAlloc(functionCallTermType);
result->functionName = functionCall->functionName;
@ -310,8 +313,7 @@ duplicateFunctionCall(functionCall)
expressionType *
duplicateArrayReference(arrayTerm)
arrayTermType *arrayTerm;
duplicateArrayReference(arrayTermType *arrayTerm)
{
anyOldThing *resultThing;
valueKindType kindOfResult;
@ -322,9 +324,9 @@ duplicateArrayReference(arrayTerm)
bool saveExpansion;
operandType *newOperand;
valueType *newValue();
operandType *duplicateOperandForFixup();
anyOldThing *arrayLookup();
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
operandType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
anyOldThing *arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing);
expansionOff();
resultThing = arrayLookup(arrayTerm, &kindOfResult);

199
garbage.c
View File

@ -33,11 +33,14 @@
#define nullFree(thing) if (thing == NULL) return;
void
freeArrayTerm(arrayTerm)
arrayTermType *arrayTerm;
extern void botch (char *message, ...);
extern void freeOperand (operandType *operand);
void
freeArrayTerm(arrayTermType *arrayTerm)
{
void freeExpression();
void freeExpression(expressionType *expression);
nullFree(arrayTerm);
freeExpression(arrayTerm->arrayName);
@ -46,10 +49,9 @@ freeArrayTerm(arrayTerm)
}
void
freeAssignmentTerm(assignmentTerm)
binopTermType *assignmentTerm;
freeAssignmentTerm(binopTermType *assignmentTerm)
{
void freeExpression();
void freeExpression(expressionType *expression);
nullFree(assignmentTerm);
freeExpression(assignmentTerm->rightArgument);
@ -57,10 +59,9 @@ freeAssignmentTerm(assignmentTerm)
}
void
freeBinopTerm(binopTerm)
binopTermType *binopTerm;
freeBinopTerm(binopTermType *binopTerm)
{
void freeExpression();
void freeExpression(expressionType *expression);
nullFree(binopTerm);
freeExpression(binopTerm->leftArgument);
@ -70,10 +71,9 @@ freeBinopTerm(binopTerm)
}
void
freeFunctionCall(functionCall)
functionCallTermType *functionCall;
freeFunctionCall(functionCallTermType *functionCall)
{
void freeOperandList();
void freeOperandList(operandListType *operandList);
nullFree(functionCall);
freeOperandList(functionCall->parameters);
@ -81,34 +81,30 @@ freeFunctionCall(functionCall)
}
void
freePostopTerm(postopTerm)
postOpTermType *postopTerm;
freePostopTerm(postOpTermType *postopTerm)
{
nullFree(postopTerm);
free(postopTerm);
}
void
freePreopTerm(preopTerm)
preOpTermType *preopTerm;
freePreopTerm(preOpTermType *preopTerm)
{
nullFree(preopTerm);
free(preopTerm);
}
void
freeString(string)
stringType *string;
freeString(stringType *string)
{
nullFree(string);
free(string);
}
void
freeUnopTerm(unopTerm)
unopTermType *unopTerm;
freeUnopTerm(unopTermType *unopTerm)
{
void freeExpression();
void freeExpression(expressionType *expression);
nullFree(unopTerm);
freeExpression(unopTerm->unopArgument);
@ -116,8 +112,7 @@ freeUnopTerm(unopTerm)
}
void
freeExpression(expression)
expressionType *expression;
freeExpression(expressionType *expression)
{
nullFree(expression);
switch (expression->kindOfTerm) {
@ -171,8 +166,7 @@ freeExpression(expression)
}
void
freeExpressionList(expressionList)
expressionListType *expressionList;
freeExpressionList(expressionListType *expressionList)
{
expressionListType *newExpressionList;
@ -185,8 +179,7 @@ freeExpressionList(expressionList)
}
void
freeIdentifierList(identifierList)
identifierListType *identifierList;
freeIdentifierList(identifierListType *identifierList)
{
identifierListType *newIdentifierList;
@ -198,25 +191,22 @@ freeIdentifierList(identifierList)
}
void
freeSelectionList(selectionList)
selectionListType *selectionList;
freeSelectionList(selectionListType *selectionList)
{
freeIdentifierList(selectionList);
}
void
freeBlock(block)
blockType *block;
freeBlock(blockType *block)
{
void freeStatement();
void freeStatement(statementType *statement);
nullFree(block);
freeStatement(block);
}
void
freeCase(aCase)
caseType *aCase;
freeCase(caseType *aCase)
{
freeExpressionList(aCase->caseTags);
freeBlock(aCase->caseBody);
@ -224,8 +214,7 @@ freeCase(aCase)
}
void
freeCaseList(caseList)
caseListType *caseList;
freeCaseList(caseListType *caseList)
{
caseListType *newCaseList;
@ -238,37 +227,32 @@ freeCaseList(caseList)
}
void
freeOperandList(operandList)
operandListType *operandList;
freeOperandList(operandListType *operandList)
{
freeOperand(operandList);
}
void
freeMacro(operands)
operandListType *operands;
freeMacro(operandListType *operands)
{
freeOperandList(operands);
}
void
freeMachineInstruction(operands)
operandListType *operands;
freeMachineInstruction(operandListType *operands)
{
freeOperandList(operands);
}
void
freeAlignStatement(alignStatement)
alignStatementBodyType *alignStatement;
freeAlignStatement(alignStatementBodyType *alignStatement)
{
nullFree(alignStatement);
freeExpression(alignStatement);
}
void
freeAssertStatement(assertStatement)
assertStatementBodyType *assertStatement;
freeAssertStatement(assertStatementBodyType *assertStatement)
{
nullFree(assertStatement);
freeExpression(assertStatement->condition);
@ -277,16 +261,14 @@ freeAssertStatement(assertStatement)
}
void
freeBlockStatement(blockStatement)
blockStatementBodyType *blockStatement;
freeBlockStatement(blockStatementBodyType *blockStatement)
{
nullFree(blockStatement);
freeExpressionList(blockStatement);
}
void
freeByteStatement(byteStatement)
byteStatementBodyType *byteStatement;
freeByteStatement(byteStatementBodyType *byteStatement)
{
byteStatementBodyType *newByteStatement;
@ -300,8 +282,7 @@ freeByteStatement(byteStatement)
}
void
freeConstrainStatement(constrainStatement)
constrainStatementBodyType *constrainStatement;
freeConstrainStatement(constrainStatementBodyType *constrainStatement)
{
nullFree(constrainStatement);
freeExpression(constrainStatement->constraint);
@ -310,8 +291,7 @@ freeConstrainStatement(constrainStatement)
}
void
freeDbyteStatement(dbyteStatement)
dbyteStatementBodyType *dbyteStatement;
freeDbyteStatement(dbyteStatementBodyType *dbyteStatement)
{
dbyteStatementBodyType *newDbyteStatement;
@ -325,8 +305,7 @@ freeDbyteStatement(dbyteStatement)
}
void
freeDefineStatement(defineStatement)
defineStatementBodyType *defineStatement;
freeDefineStatement(defineStatementBodyType *defineStatement)
{
nullFree(defineStatement);
freeExpression(defineStatement->theValue);
@ -334,8 +313,7 @@ freeDefineStatement(defineStatement)
}
void
freeDoUntilStatement(doUntilStatement)
doUntilStatementBodyType *doUntilStatement;
freeDoUntilStatement(doUntilStatementBodyType *doUntilStatement)
{
nullFree(doUntilStatement);
freeBlock(doUntilStatement->doUntilLoop);
@ -343,8 +321,7 @@ freeDoUntilStatement(doUntilStatement)
}
void
freeDoWhileStatement(doWhileStatement)
doWhileStatementBodyType *doWhileStatement;
freeDoWhileStatement(doWhileStatementBodyType *doWhileStatement)
{
nullFree(doWhileStatement);
freeBlock(doWhileStatement->doWhileLoop);
@ -352,23 +329,20 @@ freeDoWhileStatement(doWhileStatement)
}
void
freeExternStatement(externStatement)
externStatementBodyType *externStatement;
freeExternStatement(externStatementBodyType *externStatement)
{
freeIdentifierList(externStatement);
}
void
freeFreturnStatement(freturnStatement)
freturnStatementBodyType *freturnStatement;
freeFreturnStatement(freturnStatementBodyType *freturnStatement)
{
nullFree(freturnStatement);
freeExpression(freturnStatement);
}
void
freeFunctionStatement(functionStatement)
functionStatementBodyType *functionStatement;
freeFunctionStatement(functionStatementBodyType *functionStatement)
{
nullFree(functionStatement);
free(functionStatement->functionName);
@ -376,8 +350,7 @@ freeFunctionStatement(functionStatement)
}
void
freeIfStatement(ifStatement)
ifStatementBodyType *ifStatement;
freeIfStatement(ifStatementBodyType *ifStatement)
{
nullFree(ifStatement);
if (ifStatement->consequence != NULL)
@ -389,16 +362,14 @@ freeIfStatement(ifStatement)
}
void
freeIncludeStatement(includeStatement)
includeStatementBodyType *includeStatement;
freeIncludeStatement(includeStatementBodyType *includeStatement)
{
nullFree(includeStatement);
freeExpression(includeStatement);
}
void
freeInstructionStatement(instructionStatement)
instructionStatementBodyType *instructionStatement;
freeInstructionStatement(instructionStatementBodyType *instructionStatement)
{
nullFree(instructionStatement);
switch(instructionStatement->kindOfInstruction) {
@ -419,8 +390,7 @@ freeInstructionStatement(instructionStatement)
}
void
freeLongStatement(longStatement)
longStatementBodyType *longStatement;
freeLongStatement(longStatementBodyType *longStatement)
{
longStatementBodyType *newLongStatement;
@ -434,16 +404,15 @@ freeLongStatement(longStatement)
}
void
freeMacroStatement(macroStatement)
macroStatementBodyType *macroStatement;
freeMacroStatement(macroStatementBodyType *macroStatement)
{
nullFree(macroStatement);
free(macroStatement);
}
void
freeMdefineStatement(mdefineStatement)
defineStatementBodyType *mdefineStatement; /* MIST: shouldn't this be "mdefineStatementBodyType"? */
freeMdefineStatement(defineStatementBodyType *mdefineStatement)
/* MIST: shouldn't this be "mdefineStatementBodyType"? */
{
valueType *freeDefineExpression();
@ -453,8 +422,7 @@ freeMdefineStatement(mdefineStatement)
}
void
freeMdoUntilStatement(mdoUntilStatement)
mdoUntilStatementBodyType *mdoUntilStatement;
freeMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
{
nullFree(mdoUntilStatement);
freeBlock(mdoUntilStatement->mdoUntilLoop);
@ -462,8 +430,7 @@ freeMdoUntilStatement(mdoUntilStatement)
}
void
freeMdoWhileStatement(mdoWhileStatement)
mdoWhileStatementBodyType *mdoWhileStatement;
freeMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
{
nullFree(mdoWhileStatement);
freeBlock(mdoWhileStatement->mdoWhileLoop);
@ -472,8 +439,7 @@ freeMdoWhileStatement(mdoWhileStatement)
}
void
freeMifStatement(mifStatement)
mifStatementBodyType *mifStatement;
freeMifStatement(mifStatementBodyType *mifStatement)
{
nullFree(mifStatement);
freeExpression(mifStatement->mifCondition);
@ -484,8 +450,7 @@ freeMifStatement(mifStatement)
}
void
freeMswitchStatement(mswitchStatement)
mswitchStatementBodyType *mswitchStatement;
freeMswitchStatement(mswitchStatementBodyType *mswitchStatement)
{
freeExpression(mswitchStatement->switchExpression);
freeCaseList(mswitchStatement->cases);
@ -493,8 +458,7 @@ freeMswitchStatement(mswitchStatement)
}
void
freeMforStatement(mforStatement)
mforStatementBodyType *mforStatement;
freeMforStatement(mforStatementBodyType *mforStatement)
{
nullFree(mforStatement);
freeExpression(mforStatement->initExpression);
@ -505,8 +469,7 @@ freeMforStatement(mforStatement)
}
void
freeMvariableStatement(mvariableStatement)
mvariableStatementBodyType *mvariableStatement;
freeMvariableStatement(mvariableStatementBodyType *mvariableStatement)
{
nullFree(mvariableStatement);
if ((int)mvariableStatement->theDimension != -1)
@ -516,8 +479,7 @@ freeMvariableStatement(mvariableStatement)
}
void
freeMwhileStatement(mwhileStatement)
mwhileStatementBodyType *mwhileStatement;
freeMwhileStatement(mwhileStatementBodyType *mwhileStatement)
{
nullFree(mwhileStatement);
freeExpression(mwhileStatement->mwhileCondition);
@ -526,38 +488,33 @@ freeMwhileStatement(mwhileStatement)
}
void
freeOrgStatement(orgStatement)
orgStatementBodyType *orgStatement;
freeOrgStatement(orgStatementBodyType *orgStatement)
{
nullFree(orgStatement);
freeExpression(orgStatement);
}
void
freePerformStatement(performStatement)
performStatementBodyType *performStatement;
freePerformStatement(performStatementBodyType *performStatement)
{
nullFree(performStatement);
freeExpression(performStatement);
}
void
freeRelStatement(relStatement)
relStatementBodyType *relStatement;
freeRelStatement(relStatementBodyType *relStatement)
{
}
void
freeStartStatement(startStatement)
startStatementBodyType *startStatement;
freeStartStatement(startStatementBodyType *startStatement)
{
nullFree(startStatement);
freeExpression(startStatement);
}
void
freeStringStatement(stringStatement)
stringStatementBodyType *stringStatement;
freeStringStatement(stringStatementBodyType *stringStatement)
{
stringStatementBodyType *newStringStatement;
@ -571,8 +528,7 @@ freeStringStatement(stringStatement)
}
void
freeStructStatement(structStatement)
structStatementBodyType *structStatement;
freeStructStatement(structStatementBodyType *structStatement)
{
nullFree(structStatement);
freeBlock(structStatement->structBody);
@ -580,23 +536,20 @@ freeStructStatement(structStatement)
}
void
freeTargetStatement(targetStatement)
targetStatementBodyType *targetStatement;
freeTargetStatement(targetStatementBodyType *targetStatement)
{
nullFree(targetStatement);
freeExpression(targetStatement);
}
void
freeUndefineStatement(undefineStatement)
undefineStatementBodyType *undefineStatement;
freeUndefineStatement(undefineStatementBodyType *undefineStatement)
{
freeIdentifierList(undefineStatement);
}
void
freeVariableStatement(variableStatement)
variableStatementBodyType *variableStatement;
freeVariableStatement(variableStatementBodyType *variableStatement)
{
nullFree(variableStatement);
if ((int)variableStatement->theDimension != -1)
@ -606,8 +559,7 @@ freeVariableStatement(variableStatement)
}
void
freeWhileStatement(whileStatement)
whileStatementBodyType *whileStatement;
freeWhileStatement(whileStatementBodyType *whileStatement)
{
nullFree(whileStatement);
freeBlock(whileStatement->whileLoop);
@ -615,8 +567,7 @@ freeWhileStatement(whileStatement)
}
void
freeWordStatement(wordStatement)
wordStatementBodyType *wordStatement;
freeWordStatement(wordStatementBodyType *wordStatement)
{
wordStatementBodyType *newWordStatement;
@ -630,9 +581,7 @@ freeWordStatement(wordStatement)
}
void
freeStatementBody(kind, body)
statementKindType kind;
statementBodyType body;
freeStatementBody(statementKindType kind, statementBodyType body)
{
switch (kind) {
@ -795,8 +744,7 @@ freeStatementBody(kind, body)
}
void
freeLabelList(labelList)
labelListType *labelList;
freeLabelList(labelListType *labelList)
{
labelListType *nextLabel;
@ -808,8 +756,7 @@ freeLabelList(labelList)
}
void
freeStatement(statement)
statementType *statement;
freeStatement(statementType *statement)
{
statementType *newStatement;
@ -824,11 +771,10 @@ freeStatement(statement)
}
void
freeArray(array)
arrayType *array;
freeArray(arrayType *array)
{
int i;
void freeValue();
void freeValue(valueType *value);
if (array->arraySize > 0) {
for (i=0; i<array->arraySize; i++)
@ -839,8 +785,7 @@ freeArray(array)
}
void
freeValue(value)
valueType *value;
freeValue(valueType *value)
{
if (value->kindOfValue == STRING_VALUE)
freeString(value->value);

View File

@ -39,17 +39,27 @@ extern int yydebug;
static fileNameListType *bottomOfInputFileStack;
static char *outputFileName;
void
chokePukeAndDie()
extern int unlink (const char *);
bool isDotMName (stringType *fileName);
extern void fatalError (errorType theError, ...);
extern void printVersion (void);
extern void warning (errorType theError, ...);
extern void fatalSystemError (errorType theError, ...);
extern void initializeLexDispatchTable (void);
extern genericTableEntryType *hashStringEnter (genericTableEntryType *entry, genericTableEntryType **table);
extern int fancyAtoI (char *buffer, int base);
extern void error (errorType theError, ...);
void
chokePukeAndDie(void)
{
unlink(outputFileName);
exit(1);
}
void
initializeStuff(argc, argv)
int argc;
char *argv[];
initializeStuff(int argc, char **argv)
{
int i;
int j;
@ -62,13 +72,13 @@ initializeStuff(argc, argv)
char *symbolDumpFileName;
bool dontUnlinkTempFiles;
void createHashTables();
void installBuiltInFunctions();
void installPredefinedSymbols();
void installCommandLineDefineSymbols();
void openFirstInputFile();
void queueInputFile();
void noteCommandLineDefine();
void createHashTables(void);
void installBuiltInFunctions(void);
void installPredefinedSymbols(void);
void installCommandLineDefineSymbols(void);
void openFirstInputFile(void);
void queueInputFile(char *name);
void noteCommandLineDefine(char *arg);
for (i=0; i<128; i++) {
lowerCaseCharacterTable[i] = i;
@ -381,13 +391,13 @@ initializeStuff(argc, argv)
}
void
installBuiltInFunctions()
installBuiltInFunctions(void)
{
int i;
symbolTableEntryType *newFunction;
symbolTableEntryType *lookupOrEnterSymbol();
valueType *newValue();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
for (i=0; builtInFunctionTable[i].functionName!=NULL; i++) {
newFunction = lookupOrEnterSymbol(builtInFunctionTable[i].
@ -401,13 +411,13 @@ installBuiltInFunctions()
}
void
installPredefinedSymbols()
installPredefinedSymbols(void)
{
int i;
symbolTableEntryType *newSymbol;
symbolTableEntryType *lookupOrEnterSymbol();
valueType *newValue();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
for (i=0; predefinedSymbolTable[i].symbolName!=NULL; i++) {
newSymbol = lookupOrEnterSymbol(predefinedSymbolTable[i].
@ -420,13 +430,13 @@ installPredefinedSymbols()
}
void
installCommandLineDefineSymbols()
installCommandLineDefineSymbols(void)
{
int i;
symbolTableEntryType *newSymbol;
symbolTableEntryType *lookupOrEnterSymbol();
valueType *newValue();
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
while (commandLineDefines != NULL) {
newSymbol = lookupOrEnterSymbol(commandLineDefines->name,
@ -439,7 +449,7 @@ installCommandLineDefineSymbols()
}
void
createHashTables()
createHashTables(void)
{
opcodeTableEntryType *newOpcodeEntry;
keywordTableEntryType *newKeywordEntry;
@ -459,8 +469,7 @@ createHashTables()
}
void
queueInputFile(name)
char *name;
queueInputFile(char *name)
{
fileNameListType *newFileName;
@ -479,7 +488,7 @@ queueInputFile(name)
}
void
openFirstInputFile()
openFirstInputFile(void)
{
if (inputFileStack == NULL) {
inputFileStack = typeAlloc(fileNameListType);
@ -504,8 +513,7 @@ openFirstInputFile()
}
bool
isDotMName(fileName)
stringType *fileName;
isDotMName(stringType *fileName)
{
int length;
@ -515,10 +523,7 @@ isDotMName(fileName)
}
bool
parseCommandLineDefine(arg, name, value)
char *arg;
char **name;
int *value;
parseCommandLineDefine(char *arg, char **name, int *value)
{
char *ptr;
char c;
@ -561,14 +566,13 @@ parseCommandLineDefine(arg, name, value)
}
void
noteCommandLineDefine(arg)
char *arg;
noteCommandLineDefine(char *arg)
{
char *name;
int value;
commandLineDefineType *newCommandLineDefine;
bool parseCommandLineDefine();
bool parseCommandLineDefine(char *arg, char **name, int *value);
if (parseCommandLineDefine(arg, &name, &value)) {
newCommandLineDefine = typeAlloc(commandLineDefineType);

112
lexer.c
View File

@ -52,8 +52,26 @@ static int lineBufferPtr = 0;
#define isNumeric(c) (numericCharacterTable[c])
#define isAlphaNumeric(c) (alphaNumericCharacterTable[c])
int
yylex()
int lexer (void);
extern void printToken (int token);
int lexLiteral (char c);
bool isMacrossLiteralCharacter (char c);
int readAnotherLine (void);
extern int hashString (char *s);
extern opcodeTableEntryType *lookupOpcode (char *s, int hashValue);
extern int lookupKeyword (char *s, int hashValue);
extern conditionType lookupConditionCode (char *s, int hashValue);
extern macroTableEntryType *lookupMacroName (char *s, int hashValue);
int fancyAtoI (char *buffer, int base);
int digitValue (char c);
extern void error (errorType theError, ...);
int getStringCharacter (FILE *input);
extern void fatalSystemError (errorType theError, ...);
extern bool notListable (statementKindType statementKind);
int
yylex(void)
{
int result;
@ -67,11 +85,11 @@ yylex()
}
int
lexer()
lexer(void)
{
char c;
char skipWhitespaceAndComments();
char skipWhitespaceAndComments(void);
if ((c = skipWhitespaceAndComments()) == EOF)
return(lexLiteral(c));
@ -80,15 +98,15 @@ lexer()
}
void
initializeLexDispatchTable()
initializeLexDispatchTable(void)
{
int c;
int lexIdentifier();
int lexNumber();
int lexLiteral();
int lexCharacterConstant();
int lexStringConstant();
int lexOperator();
int lexIdentifier(char c);
int lexNumber(char c);
int lexLiteral(char c);
int lexCharacterConstant(void);
int lexStringConstant(void);
int lexOperator(char firstC);
for (c = 0; c < LEX_DISPATCH_TABLE_SIZE; c++) {
if (isAlphabetic(c) || c=='$')
@ -107,8 +125,7 @@ initializeLexDispatchTable()
}
bool
isMacrossLiteralCharacter(c)
char c;
isMacrossLiteralCharacter(char c)
{
return(c==':' || c==',' || c=='@' || c=='#' ||
c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' ||
@ -116,9 +133,7 @@ isMacrossLiteralCharacter(c)
}
void
snarfAlphanumericString(c, buffer)
char c;
char *buffer;
snarfAlphanumericString(char c, char *buffer)
{
char *bufferPtr;
@ -135,10 +150,9 @@ snarfAlphanumericString(c, buffer)
char nameBuffer[MAX_NAME_SIZE+1];
int
lexIdentifier(c)
char c;
lexIdentifier(char c)
{
char *saveString();
char *saveString(char *s);
int hashValue;
snarfAlphanumericString(c, nameBuffer);
@ -161,8 +175,7 @@ lexIdentifier(c)
char numberBuffer[MAX_NAME_SIZE+1];
int
lexNumber(c)
char c;
lexNumber(char c)
{
int base;
int start;
@ -189,9 +202,7 @@ lexNumber(c)
}
int
fancyAtoI(buffer, base)
char *buffer;
int base;
fancyAtoI(char *buffer, int base)
{
int value;
int digit;
@ -209,8 +220,7 @@ fancyAtoI(buffer, base)
}
int
digitValue(c)
char c;
digitValue(char c)
{
if (isNumeric(c))
return(c - '0');
@ -219,8 +229,7 @@ digitValue(c)
}
int
lexLiteral(c)
char c;
lexLiteral(char c)
{
static bool passedEnd = FALSE;
@ -240,7 +249,7 @@ lexLiteral(c)
}
int
lexCharacterConstant()
lexCharacterConstant(void)
{
char c;
@ -256,13 +265,12 @@ lexCharacterConstant()
bool escaped; /* true if last string character read was an escape
code. */
int
getStringCharacter(input)
FILE *input;
getStringCharacter(FILE *input)
{
char c;
char *numberPtr;
int result;
char controlCharacter();
char controlCharacter(char c);
escaped = FALSE;
c = getNextChar();
@ -292,7 +300,7 @@ getStringCharacter(input)
char stringBuffer[MAX_NAME_SIZE + 1];
int
lexStringConstant()
lexStringConstant(void)
{
char *stringPtr;
char c;
@ -309,8 +317,7 @@ lexStringConstant()
}
int
lexOperator(firstC)
char firstC;
lexOperator(char firstC)
{
char secondC;
char thirdC;
@ -347,8 +354,7 @@ lexOperator(firstC)
}
char
controlCharacter(c)
char c;
controlCharacter(char c)
{
#define CONTROL_CHARACTER_MASK (~0100)
@ -356,7 +362,7 @@ controlCharacter(c)
}
char
skipWhitespaceAndComments()
skipWhitespaceAndComments(void)
{
char c;
@ -394,7 +400,7 @@ skipWhitespaceAndComments()
}
int
popInputFileStack()
popInputFileStack(void)
{
fileNameListType *oldFile;
@ -425,8 +431,7 @@ popInputFileStack()
}
void
pushInputFileStack(fileName)
stringType *fileName;
pushInputFileStack(stringType *fileName)
{
fileNameListType *newFileName;
@ -446,7 +451,7 @@ pushInputFileStack(fileName)
}
void
resynchronizeInput()
resynchronizeInput(void)
{
char c;
while ((c = getNextChar())!='\n' && c!=EOF)
@ -458,8 +463,7 @@ resynchronizeInput()
static bool previousLongLineFlag = FALSE;
void
saveLineForListing(line)
stringType *line;
saveLineForListing(stringType *line)
{
if (!previousLongLineFlag) {
putw(currentLocationCounter.value, saveFileForPass2);
@ -470,7 +474,7 @@ saveLineForListing(line)
}
void
saveEOLForListing()
saveEOLForListing(void)
{
putw(-1, saveFileForPass2);
putw(includeNestingDepth, saveFileForPass2);
@ -478,9 +482,7 @@ saveEOLForListing()
}
void
saveIndexForListing(kindOfStatement, cumulativeLineNumber)
statementKindType kindOfStatement;
int cumulativeLineNumber;
saveIndexForListing(statementKindType kindOfStatement, int cumulativeLineNumber)
{
if (!amExpanding() || !notListable(kindOfStatement)) {
putw(kindOfStatement, indexFileForPass2);
@ -493,8 +495,7 @@ saveIndexForListing(kindOfStatement, cumulativeLineNumber)
}
void
saveEndMifForListing(cumulativeLineNumber)
int cumulativeLineNumber;
saveEndMifForListing(int cumulativeLineNumber)
{
putw(MIF_STATEMENT, indexFileForPass2);
putw(-1, indexFileForPass2);
@ -505,13 +506,13 @@ saveEndMifForListing(cumulativeLineNumber)
}
void
saveListingOff()
saveListingOff(void)
{
saveIndexForListing(-1, cumulativeLineNumber);
}
void
saveListingOn()
saveListingOn(void)
{
if (currentCodeMode == ABSOLUTE_BUFFER)
saveIndexForListing(-1, cumulativeLineNumber);
@ -520,10 +521,7 @@ saveListingOn()
}
char *
myfgets(buffer, length, stream)
char *buffer;
int length;
FILE *stream;
myfgets(char *buffer, int length, FILE *stream)
{
char *result;
char c;
@ -546,7 +544,7 @@ myfgets(buffer, length, stream)
}
int
readAnotherLine()
readAnotherLine(void)
{
int result;

View File

@ -44,8 +44,16 @@ static int nextMacroAddress;
static int macroDepth;
static int nextMacroDepth;
void
outputListing()
extern void saveLineForListing (stringType *line);
extern void saveIndexForListing (statementKindType kindOfStatement, int cumulativeLineNumber);
extern char *myfgets (char *buffer, int length, FILE *stream);
bool isBlankStatement (statementKindType statementKind);
extern byte getByte (addressType address);
extern bool listableStatement (statementKindType kind);
void
outputListing(void)
{
rewind(saveFileForPass2);
rewind(indexFileForPass2);
@ -54,7 +62,7 @@ outputListing()
}
void
terminateListingFiles()
terminateListingFiles(void)
{
saveLineForListing("\n");
saveIndexForListing(NULL_STATEMENT, cumulativeLineNumber);
@ -96,7 +104,7 @@ terminateListingFiles()
/* This is the most horrible piece of code I have ever written in my entire
life -- cbm */
void
generateListing()
generateListing(void)
{
int sourceAddress;
int sourceDepth;
@ -297,10 +305,7 @@ generateListing()
bool longLineFlag; /* defined in lexer.c */
int
printMacroLine(numberOfBytes, byteAddress, kind)
int numberOfBytes;
int byteAddress;
statementKindType kind;
printMacroLine(int numberOfBytes, int byteAddress, statementKindType kind)
{
macroAddress = nextMacroAddress;
macroDepth = nextMacroDepth;
@ -312,11 +317,7 @@ printMacroLine(numberOfBytes, byteAddress, kind)
}
void
readSourceFileLine(sourceAddressPtr, sourceDepthPtr, lineBuffer, file)
int *sourceAddressPtr;
int *sourceDepthPtr;
char lineBuffer[];
FILE *file;
readSourceFileLine(int *sourceAddressPtr, int *sourceDepthPtr, char *lineBuffer, FILE *file)
{
char c;
@ -331,10 +332,7 @@ readSourceFileLine(sourceAddressPtr, sourceDepthPtr, lineBuffer, file)
}
void
readIndexFileLine(statementKindPtr, indexAddressPtr, indexLineNumberPtr)
statementKindType *statementKindPtr;
int *indexAddressPtr;
int *indexLineNumberPtr;
readIndexFileLine(statementKindType *statementKindPtr, int *indexAddressPtr, int *indexLineNumberPtr)
{
statementKindType statementKindRead;
int indexAddressRead;
@ -353,11 +351,7 @@ readIndexFileLine(statementKindPtr, indexAddressPtr, indexLineNumberPtr)
}
int
printListingLine(numberOfBytes, byteAddress, text, kind)
int numberOfBytes;
int byteAddress;
char *text;
statementKindType kind;
printListingLine(int numberOfBytes, int byteAddress, char *text, statementKindType kind)
{
int i;
@ -408,8 +402,7 @@ printListingLine(numberOfBytes, byteAddress, text, kind)
bool
isBlockOpener(statementKind)
statementKindType statementKind;
isBlockOpener(statementKindType statementKind)
{
return (statementKind==IF_STATEMENT ||
statementKind==WHILE_STATEMENT ||
@ -428,8 +421,7 @@ isBlockOpener(statementKind)
}
bool
isBlankStatement(statementKind)
statementKindType statementKind;
isBlankStatement(statementKindType statementKind)
{
return( statementKind == DEFINE_STATEMENT ||
statementKind == NULL_STATEMENT ||
@ -455,8 +447,7 @@ isBlankStatement(statementKind)
}
void
tabPrint(text)
stringType *text;
tabPrint(stringType *text)
{
int column;
int spaces;
@ -477,16 +468,14 @@ tabPrint(text)
}
void
printNTimes(aChar, times)
char aChar;
int times;
printNTimes(char aChar, int times)
{
while (times-- > 0)
moreText("%c", aChar, 0, 0);
}
void
tabIndent()
tabIndent(void)
{
printNTimes('\t', tabCount);
}
@ -499,7 +488,7 @@ static char labelString[LINE_BUFFER_SIZE] = { '\0' };
static char *labelStringPtr = labelString;
bool
labeledLine()
labeledLine(void)
{
return(labelStringPtr != labelString);
}
@ -542,9 +531,7 @@ moreText(char *format, ...)
}
void
moreLabel(format, arg1)
char *format;
int arg1;
moreLabel(char *format, int arg1)
{
sprintf(labelStringPtr, format, arg1);
labelStringPtr = labelString + strlen(labelString);
@ -554,7 +541,7 @@ static addressType savedCurrentLocationCounterValue;
static int savedIncludeNestingDepth;
void
startLine()
startLine(void)
{
printNTimes('+', macroCallDepth);
savedCurrentLocationCounterValue = currentLocationCounter.value;
@ -562,7 +549,7 @@ startLine()
}
void
endLine()
endLine(void)
{
if (amListing()) {
putw(savedCurrentLocationCounterValue, macroFileForPass2);
@ -574,16 +561,14 @@ endLine()
}
void
flushExpressionString()
flushExpressionString(void)
{
expressionStringPtr = expressionString;
*expressionStringPtr = '\0';
}
void
expandExpression(toBuffer, toBufferPtr)
char *toBuffer;
char **toBufferPtr;
expandExpression(char *toBuffer, char **toBufferPtr)
{
if (toBuffer == NULL)
moreText("%s", expressionString, 0, 0);
@ -593,25 +578,20 @@ expandExpression(toBuffer, toBufferPtr)
}
void
expandNum(buffer, bufferPtr, n)
char *buffer;
char **bufferPtr;
int n;
expandNum(char *buffer, char **bufferPtr, int n)
{
moreTextOptional(buffer, bufferPtr, "%d", n, 0, 0);
}
void
flushOperand(n)
int n;
flushOperand(int n)
{
moreText("%s", operandBuffer[n], 0, 0);
operandBuffer[n][0] = '\0';
}
void
expandOperands(op)
int op;
expandOperands(int op)
{
int i;
@ -625,7 +605,7 @@ expandOperands(op)
}
void
expandLabel()
expandLabel(void)
{
moreText("%s", labelString, 0, 0);
labelStringPtr = labelString;
@ -643,7 +623,7 @@ moreExpression(char *format, ...)
}
void
startLineMarked()
startLineMarked(void)
{
startLine();
if (amListing())
@ -651,8 +631,7 @@ startLineMarked()
}
bool
notListable(statementKind)
statementKindType statementKind;
notListable(statementKindType statementKind)
{
return(!listableStatement(statementKind) &&
statementKind != INSTRUCTION_STATEMENT &&

View File

@ -6,9 +6,9 @@
* Glorious Future Year 1989 the vprintf function does almost exactly
* what we want. */
void outputListing();
void terminateListingFiles();
void generateListing();
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 readIndexFileLine(statementKindType *statementKindPtr, int *indexAddressPtr, int *indexLineNumberPtr);
@ -17,22 +17,22 @@ bool isBlockOpener(statementKindType statementKind);
bool isBlankStatment(statementKindType statementKind);
void tabPrint(stringType *text);
void printNTimes (char aChar, int times);
void tabIndent();
bool labeledLine();
void tabIndent(void);
bool labeledLine(void);
void addText(char *buffer, char **bufferPtr, char *format, ...);
void moreTextOptional(char *buffer, char **bufferPtr, char *format, ...);
void moreText(char *format, ...);
void moreLabel(char *format, int arg1);
void startLine();
void endLine();
void flushExpressionString();
void startLine(void);
void endLine(void);
void flushExpressionString(void);
void expandExpression(char *toBuffer, char **toBufferPtr);
void expandNum(char *buffer, char **bufferPtr, int n);
void flushOperand(int n);
void expandOperands(int op);
void expandLabel();
void expandLabel(void);
void moreExpression(char *format, ...);
void startLineMarked();
void startLineMarked(void);
bool notListable(statementKindType statementKind);
#endif

135
lookups.c
View File

@ -36,14 +36,24 @@
lists that are sorted alphabetically.
*/
conditionType
lookupConditionCode(s, hashValue)
char *s;
int hashValue;
extern void botch (char *message, ...);
extern void freeValue (valueType *value);
extern void error (errorType theError, ...);
bool strcmplc (char *s1, char *s2);
int hashString (char *s);
extern int countParameters (operandListType *parameterList);
extern arrayType *allocArray (int size, valueType ***contentsPtr);
extern bool isUsable (valueType *value);
extern void moreExpression (char *format, ...);
extern bool isUndefined (valueType *value);
conditionType
lookupConditionCode(char *s, int hashValue)
{
conditionTableEntryType *result;
genericTableEntryType *prehashedStringLookup();
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
result = (conditionTableEntryType *) prehashedStringLookup(s,
conditionTable, hashValue);
@ -54,13 +64,11 @@ lookupConditionCode(s, hashValue)
}
int
lookupKeyword(s, hashValue)
char *s;
int hashValue;
lookupKeyword(char *s, int hashValue)
{
keywordTableEntryType *result;
genericTableEntryType *prehashedStringLookup();
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
result = (keywordTableEntryType *) prehashedStringLookup(s,
keywordTable, hashValue);
@ -71,22 +79,18 @@ lookupKeyword(s, hashValue)
}
macroTableEntryType *
lookupMacroName(s, hashValue)
char *s;
int hashValue;
lookupMacroName(char *s, int hashValue)
{
genericTableEntryType *prehashedStringLookup();
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
return((macroTableEntryType *) prehashedStringLookup(s, macroTable,
hashValue));
}
opcodeTableEntryType *
lookupOpcode(s, hashValue)
char *s;
int hashValue;
lookupOpcode(char *s, int hashValue)
{
genericTableEntryType *prehashedStringLookup();
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
return((opcodeTableEntryType *) prehashedStringLookup(s,
opcodeTable, hashValue));
@ -97,14 +101,12 @@ lookupOpcode(s, hashValue)
the given kind and return *that* */
symbolTableEntryType *
lookupOrEnterSymbol(s, kind)
stringType *s;
symbolUsageKindType kind;
lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind)
{
symbolTableEntryType *result;
genericTableEntryType *hashStringLookup();
genericTableEntryType *hashStringEnter();
symbolTableEntryType *buildSymbolTableEntry();
genericTableEntryType *hashStringLookup(char *s, genericTableEntryType **table);
genericTableEntryType *hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table);
symbolTableEntryType *buildSymbolTableEntry(stringType *name, symbolUsageKindType usage);
if (result = (symbolTableEntryType *)hashStringLookup(s,symbolTable)){
/* result->referenceCount++;*/
@ -116,8 +118,7 @@ lookupOrEnterSymbol(s, kind)
}
void
pushSymbol(symbol)
symbolTableEntryType *symbol;
pushSymbol(symbolTableEntryType *symbol)
{
symbolInContextType *newContext;
@ -127,8 +128,7 @@ pushSymbol(symbol)
}
void
popSymbol(symbol)
symbolTableEntryType *symbol;
popSymbol(symbolTableEntryType *symbol)
{
symbolInContextType *deadContext;
@ -146,16 +146,15 @@ popSymbol(symbol)
}
macroTableEntryType *
createMacro(macroName)
stringType *macroName;
createMacro(stringType *macroName)
{
macroTableEntryType *result;
symbolTableEntryType *testSymbol;
genericTableEntryType *hashStringLookup();
genericTableEntryType *hashStringEnter();
macroTableEntryType *buildMacroTableEntry();
symbolTableEntryType *lookupOrEnterSymbol();
genericTableEntryType *hashStringLookup(char *s, genericTableEntryType **table);
genericTableEntryType *hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table);
macroTableEntryType *buildMacroTableEntry(stringType *name);
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
testSymbol = lookupOrEnterSymbol(macroName, MACRO_SYMBOL);
if (testSymbol->context->usage != MACRO_SYMBOL) {
@ -179,10 +178,7 @@ createMacro(macroName)
*/
genericTableEntryType *
prehashedStringLookup(s, table, hashValue)
char *s;
genericTableEntryType *table[];
int hashValue;
prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue)
{
genericTableEntryType *result;
int test;
@ -202,17 +198,13 @@ prehashedStringLookup(s, table, hashValue)
}
genericTableEntryType *
hashStringLookup(s, table)
char *s;
genericTableEntryType *table[];
hashStringLookup(char *s, genericTableEntryType **table)
{
return(prehashedStringLookup(s, table, hashString(s)));
}
genericTableEntryType *
hashStringEnter(entry, table)
genericTableEntryType *entry;
genericTableEntryType *table[];
hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table)
{
genericTableEntryType *result;
genericTableEntryType *oldResult;
@ -252,8 +244,7 @@ hashStringEnter(entry, table)
}
int
hashString(s)
char *s;
hashString(char *s)
{
unsigned result;
@ -264,9 +255,9 @@ hashString(s)
}
bool
strcmplc(s1, s2) /* string compare in lower case */
char *s1; /* heavily optimized version */
char *s2;
strcmplc(char *s1, char *s2) /* string compare in lower case */
/* heavily optimized version */
{
char c1;
int result;
@ -284,9 +275,9 @@ strcmplc(s1, s2) /* string compare in lower case */
}
bool
strcmplct(s1, s2) /* For tables: s2 is already lower case */
char *s1; /* heavily optimized version. */
char *s2;
strcmplct(char *s1, char *s2) /* For tables: s2 is already lower case */
/* heavily optimized version. */
{
char c1;
int result;
@ -302,21 +293,18 @@ strcmplct(s1, s2) /* For tables: s2 is already lower case */
}
void
purgeSymbol(symbol)
symbolTableEntryType *symbol;
purgeSymbol(symbolTableEntryType *symbol)
{
symbolInContextType *context;
symbolInContextType *getWorkingContext();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
if ((context = getWorkingContext(symbol)) != NULL)
context->usage = DEAD_SYMBOL;
}
void
reincarnateSymbol(context, newUsage)
symbolInContextType *context;
symbolUsageKindType newUsage;
reincarnateSymbol(symbolInContextType *context, symbolUsageKindType newUsage)
{
context->attributes = 0;
dupValue(context->value, UndefinedValue);
@ -329,12 +317,9 @@ reincarnateSymbol(context, newUsage)
*/
void
pushBinding(symbol, newBinding, newUsage)
symbolTableEntryType *symbol;
valueType *newBinding;
symbolUsageKindType newUsage;
pushBinding(symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage)
{
valueType *newValue();
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
pushSymbol(symbol);
if (newBinding == NULL)
@ -347,17 +332,13 @@ pushBinding(symbol, newBinding, newUsage)
}
void
popBinding(symbol)
symbolTableEntryType *symbol;
popBinding(symbolTableEntryType *symbol)
{
popSymbol(symbol);
}
int /* returns number of bindings completed, negative this if failure */
bindMacroArguments(argumentList, parameterList, macroName)
argumentDefinitionListType *argumentList;
operandListType *parameterList;
stringType *macroName;
bindMacroArguments(argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *macroName)
{
int numberBound;
bool arrayTag;
@ -365,7 +346,7 @@ bindMacroArguments(argumentList, parameterList, macroName)
valueType **arrayContents;
int i;
valueType *newValue();
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
if (argumentList == NULL)
arrayTag = FALSE;
@ -417,10 +398,7 @@ bindMacroArguments(argumentList, parameterList, macroName)
}
int /* returns number of bindings completed, negative this if failure */
bindFunctionArguments(argumentList, parameterList, functionName)
argumentDefinitionListType *argumentList;
operandListType *parameterList;
stringType *functionName;
bindFunctionArguments(argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *functionName)
{
valueType *argument;
bool arrayTag;
@ -431,8 +409,8 @@ bindFunctionArguments(argumentList, parameterList, functionName)
valueType *firstArgument;
environmentType *saveEnvironment;
valueType *evaluateOperand();
valueType *newValue();
valueType *evaluateOperand(operandType *operand);
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
if (argumentList == NULL)
arrayTag = FALSE;
@ -515,9 +493,7 @@ bindFunctionArguments(argumentList, parameterList, functionName)
}
void
unbindArguments(argumentList, numberToUnbind)
argumentDefinitionListType *argumentList;
int numberToUnbind;
unbindArguments(argumentDefinitionListType *argumentList, int numberToUnbind)
{
while (argumentList != NULL && numberToUnbind-- > 0) {
popBinding(argumentList->theArgument);
@ -528,8 +504,7 @@ unbindArguments(argumentList, numberToUnbind)
}
void
unbindLocalVariables(identifierList)
identifierListType *identifierList;
unbindLocalVariables(identifierListType *identifierList)
{
identifierListType *deadEntry;

View File

@ -205,20 +205,20 @@ int operandClassTable[] = { /* indexed by operandKindType */
BLOCK_OPND_BIT,
};
int actionsRelative();
int actionsDir1();
int actionsDir2();
int actionsDirIndir();
int actionsDirX1();
int actionsDirX2();
int actionsDirX3();
int actionsDirY();
int actionsImmDir();
int actionsImmDirX();
int actionsImmDirY();
int actionsNone();
int actionsIndex();
int actionsImmIndex();
int actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsDir2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsDirX1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsImmDir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsImmDirX(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsImmDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
int actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
/* indexed by opcodeClass */
int (*instructionActionTable[])() = {
@ -303,53 +303,53 @@ valueType undefinedValueValue = { UNDEFINED_VALUE, 0,
EXPRESSION_OPND };
valueType *UndefinedValue = &undefinedValueValue;
valueType *addressModeBIF();
valueType *applyBIF();
valueType *arrayLengthBIF();
valueType *atasciiBIF();
valueType *atasciiColorBIF();
valueType *debugModeOffBIF();
valueType *debugModeOnBIF();
valueType *emitModeOffBIF();
valueType *emitModeOnBIF();
valueType *isAbsoluteValueBIF();
valueType *isARegisterBIF();
valueType *isBlockBIF();
valueType *isBuiltInFunctionBIF();
valueType *isConditionCodeBIF();
valueType *isDefinedBIF();
valueType *isDirectModeBIF();
valueType *isExternalBIF();
valueType *isFieldBIF();
valueType *isFunctionBIF();
valueType *isImmediateModeBIF();
valueType *isIndexedModeBIF();
valueType *isIndirectModeBIF();
valueType *isPostIndexedModeBIF();
valueType *isPreIndexedModeBIF();
valueType *isRelocatableValueBIF();
valueType *isStringBIF();
valueType *isStructBIF();
valueType *isSymbolBIF();
valueType *isXIndexedModeBIF();
valueType *isXRegisterBIF();
valueType *isYIndexedModeBIF();
valueType *isYRegisterBIF();
valueType *listingOffBIF();
valueType *listingOnBIF();
valueType *makeArrayBIF();
valueType *nthCharBIF();
valueType *printfBIF();
valueType *strcatBIF();
valueType *strcmpBIF();
valueType *strcmplcBIF();
valueType *strlenBIF();
valueType *substrBIF();
valueType *symbolDefineBIF();
valueType *symbolLookupBIF();
valueType *symbolNameBIF();
valueType *symbolUsageBIF();
valueType *valueTypeBIF();
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 *isARegisterBIF(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 *isDirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *isExternalBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *isFieldBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *isFunctionBIF(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 *isRelocatableValueBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *isStringBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *isStructBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *isSymbolBIF(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);
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 *symbolDefineBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *symbolLookupBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *symbolNameBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *symbolUsageBIF(operandListType *parameterList, fixupKindType kindOfFixup);
valueType *valueTypeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
/* Used to initialize symbols representing built-in functions */
struct {

14
main.c
View File

@ -30,16 +30,20 @@
#include "macrossTypes.h"
#include "macrossGlobals.h"
main(argc, argv)
int argc;
char *argv[];
extern void initializeStuff (int argc, char **argv);
extern int yyparse (void);
extern void finishUp (void);
extern void chokePukeAndDie (void);
main(int argc, char **argv)
{
#ifdef __APPLE__
char end = get_end();
#else
extern char end;
#endif
char *sbrk();
char *sbrk(int);
fflush(stdout);
initializeStuff(argc, argv);
@ -55,7 +59,7 @@ main(argc, argv)
}
void
printVersion()
printVersion(void)
{
printf("Macross %s version 4.20.\n", TARGET_CPU_STRING);
}

View File

@ -80,7 +80,7 @@ union overhead {
*/
#define NBUCKETS 30
static union overhead *nextf[NBUCKETS];
extern char *sbrk();
extern char *sbrk(int);
#ifdef MSTATS
/*
@ -109,8 +109,7 @@ static void morecore(int);
static int findbucket(union overhead *, int);
char *
malloc(nbytes)
register unsigned nbytes;
malloc(register unsigned int nbytes)
{
register union overhead *p;
register int bucket = 0;
@ -160,8 +159,7 @@ malloc(nbytes)
* Allocate more memory to the indicated bucket.
*/
static void
morecore(bucket)
register bucket;
morecore(register int bucket)
{
register union overhead *op;
register int rnu; /* 2^rnu bytes will be requested */
@ -209,8 +207,7 @@ morecore(bucket)
}
void
free(cp)
char *cp;
free(char *cp)
{
register int size;
register union overhead *op;
@ -252,9 +249,7 @@ free(cp)
int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
char *
realloc(cp, nbytes)
char *cp;
unsigned nbytes;
realloc(char *cp, unsigned int nbytes)
{
register u_int onb;
union overhead *op;
@ -304,9 +299,7 @@ realloc(cp, nbytes)
* Return bucket number, or -1 if not found.
*/
static
findbucket(freep, srchlen)
union overhead *freep;
int srchlen;
findbucket(union overhead *freep, int srchlen)
{
register union overhead *p;
register int i, j;

134
object.c
View File

@ -36,19 +36,28 @@ static int symbolTableSize;
static int symbolTableStringSize;
bool encodingFunction;
void
outputObjectFile()
extern void printCodeBuffers (void);
extern bool isExternal (symbolTableEntryType *symbol);
extern bool strcmplc (char *s1, char *s2);
bool hackableSymbol (symbolTableEntryType *symbol);
extern void printExpressionBuffer (void);
extern bool encodeRelocatableNumber (numberTermType number);
extern void freeExpression (expressionType *expression);
void
outputObjectFile(void)
{
void outputPartition();
void outputReferenceInfo();
void outputSymbolTableInfo();
void outputAbsoluteCode();
void outputRelocatableCode();
void outputReservations();
void outputExpressions();
void outputFunctions();
void dumpSymbolTable();
void enumerateAndCountSymbols();
void outputPartition(void);
void outputReferenceInfo(void);
void outputSymbolTableInfo(void);
void outputAbsoluteCode(void);
void outputRelocatableCode(void);
void outputReservations(void);
void outputExpressions(void);
void outputFunctions(void);
void dumpSymbolTable(void);
void enumerateAndCountSymbols(void);
if (debug || emitPrint)
printCodeBuffers();
@ -72,22 +81,20 @@ outputObjectFile()
}
void
outputWord(aWord)
int aWord;
outputWord(int aWord)
{
putc(aWord & 0xFF, objectFileOutput);
putc((aWord >> 8) & 0xFF, objectFileOutput);
}
void
outputPartition()
outputPartition(void)
{
outputWord(0xFFFF);
}
void
outputBigword(bigword)
unsigned long bigword;
outputBigword(long unsigned int bigword)
{
int i;
@ -98,15 +105,13 @@ outputBigword(bigword)
}
void
outputByte(aByte)
byte aByte;
outputByte(byte aByte)
{
putc(aByte, objectFileOutput);
}
void
outputString(string)
stringType *string;
outputString(stringType *string)
{
do {
putc(*string, objectFileOutput);
@ -114,8 +119,7 @@ outputString(string)
}
void
outputStartAddress(startAddress)
addressType startAddress;
outputStartAddress(addressType startAddress)
{
outputWord(startAddress);
if (produceLinkableObject) {
@ -128,14 +132,14 @@ outputStartAddress(startAddress)
}
void
outputRelocatableCode()
outputRelocatableCode(void)
{
int i;
addressType codeStartAddress;
addressType codeEndAddress;
void outputPseudoSegment();
void outputBreak();
void outputPseudoSegment(addressType codeStartAddress, addressType codeEndAddress);
void outputBreak(codeBreakType *codeBreak);
if (haveUserStartAddress && !fixupStartAddress && startAddress->
kindOfValue == RELOCATABLE_VALUE)
@ -161,8 +165,7 @@ outputRelocatableCode()
}
void
outputBreak(codeBreak)
codeBreakType *codeBreak;
outputBreak(codeBreakType *codeBreak)
{
switch (codeBreak->kindOfBreak) {
case BREAK_BREAK:
@ -185,13 +188,13 @@ outputBreak(codeBreak)
}
void
outputAbsoluteCode()
outputAbsoluteCode(void)
{
int i;
int startSegment;
int endSegment;
int nextSegment;
void outputOneCodeBuffer();
void outputOneCodeBuffer(codeSegmentType *segment);
if (haveUserStartAddress && !fixupStartAddress && startAddress->
kindOfValue==ABSOLUTE_VALUE)
@ -223,8 +226,7 @@ outputAbsoluteCode()
}
void
outputOneCodeBuffer(segment)
codeSegmentType *segment;
outputOneCodeBuffer(codeSegmentType *segment)
{
int i;
@ -238,9 +240,7 @@ outputOneCodeBuffer(segment)
}
void
outputPseudoSegment(codeStartAddress, codeEndAddress)
addressType codeStartAddress;
addressType codeEndAddress;
outputPseudoSegment(addressType codeStartAddress, addressType codeEndAddress)
{
int startSegment;
int endSegment;
@ -252,8 +252,8 @@ outputPseudoSegment(codeStartAddress, codeEndAddress)
int segment;
codeSegmentType *segmentPtr;
void outputWord();
void outputByte();
void outputWord(int aWord);
void outputByte(byte aByte);
outputWord(codeStartAddress);
outputWord(codeEndAddress);
@ -273,8 +273,7 @@ outputPseudoSegment(codeStartAddress, codeEndAddress)
}
bool
isObjectSymbol(symbol)
symbolTableEntryType *symbol;
isObjectSymbol(symbolTableEntryType *symbol)
{
return(symbol != NULL && symbol->context->value != NULL &&
symbol->context->value->kindOfValue != FUNCTION_VALUE &&
@ -289,7 +288,7 @@ isObjectSymbol(symbol)
}
void
enumerateAndCountSymbols()
enumerateAndCountSymbols(void)
{
int i;
symbolTableEntryType *symb;
@ -305,7 +304,7 @@ enumerateAndCountSymbols()
}
int
enumerateAndCountReferences()
enumerateAndCountReferences(void)
{
int result;
int codeMode;
@ -323,8 +322,7 @@ enumerateAndCountReferences()
}
void
outputReference(reference)
expressionReferenceType *reference;
outputReference(expressionReferenceType *reference)
{
byte funnyByte;
bigWord funnyWord;
@ -346,7 +344,7 @@ outputReference(reference)
static int referenceCount;
void
outputReferenceInfo()
outputReferenceInfo(void)
{
expressionReferenceListType *theReferences;
int codeMode;
@ -363,12 +361,11 @@ outputReferenceInfo()
}
void
outputOneSymbol(symbol)
symbolTableEntryType *symbol;
outputOneSymbol(symbolTableEntryType *symbol)
{
byte symbolClass;
valueType *symbolValue;
valueType *evaluateIdentifier();
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
if (symbol->context->usage == DEFINE_SYMBOL)
symbolValue = evaluateIdentifier(symbol, FALSE, NO_FIXUP_OK);
@ -390,7 +387,7 @@ outputOneSymbol(symbol)
}
void
outputSymbolTableInfo()
outputSymbolTableInfo(void)
{
int i;
symbolTableEntryType *symb;
@ -404,16 +401,13 @@ outputSymbolTableInfo()
}
int
symbolCompare(symbol1, symbol2)
symbolTableEntryType **symbol1;
symbolTableEntryType **symbol2;
symbolCompare(symbolTableEntryType **symbol1, symbolTableEntryType **symbol2)
{
return(strcmplc((*symbol1)->symbolName, (*symbol2)->symbolName));
}
bool
shouldDumpSymbol(symbol)
symbolTableEntryType *symbol;
shouldDumpSymbol(symbolTableEntryType *symbol)
{
return(symbolTableDumpOn == 2
|| (symbol->context->usage != BUILT_IN_FUNCTION_SYMBOL
@ -428,7 +422,7 @@ shouldDumpSymbol(symbol)
}
void
dumpSymbolTable()
dumpSymbolTable(void)
{
int i;
symbolTableEntryType *symb;
@ -437,8 +431,8 @@ dumpSymbolTable()
int symbolPtr;
valueType *value;
valueType *evaluateIdentifier();
void printValueTersely();
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
void printValueTersely(valueType *value);
numberOfSymbols = 0;
for (i=0; i<HASH_TABLE_SIZE; i++)
@ -505,16 +499,14 @@ dumpSymbolTable()
}
bool
hackableSymbol(symbol)
symbolTableEntryType *symbol;
hackableSymbol(symbolTableEntryType *symbol)
{
return(symbol->context->usage == DEFINE_SYMBOL || symbol->context->
usage == LABEL_SYMBOL);
}
void
printValueTersely(value)
valueType *value;
printValueTersely(valueType *value)
{
static char *valueKindTable[NUM_OF_VALUE_KINDS] = {
"ABS",
@ -542,7 +534,7 @@ printValueTersely(value)
}
void
outputReservations()
outputReservations(void)
{
while (reservationList != NULL) {
outputWord(reservationList->startAddress);
@ -552,7 +544,7 @@ outputReservations()
}
void
outputExpressionBuffer()
outputExpressionBuffer(void)
{
int i;
@ -564,13 +556,12 @@ outputExpressionBuffer()
}
void
outputOneExpression(expression)
expressionType *expression;
outputOneExpression(expressionType *expression)
{
expressionType *newExpression;
expressionType *generateFixupExpression();
bool encodeExpression();
expressionType *generateFixupExpression(expressionType *expression);
bool encodeExpression(expressionType *expression);
expressionBufferSize = 0;
if (expression == NULL) {
@ -585,7 +576,7 @@ outputOneExpression(expression)
}
void
outputExpressions()
outputExpressions(void)
{
int codeMode;
expressionReferenceListType *theReferences;
@ -604,12 +595,11 @@ outputExpressions()
}
void
outputOneFunction(function)
functionDefinitionType *function;
outputOneFunction(functionDefinitionType *function)
{
argumentDefinitionListType *argumentList;
bool encodeBlock();
int countArguments();
bool encodeBlock(blockType *block);
int countArguments(functionDefinitionType *function);
outputByte((byte)countArguments(function));
argumentList = function->arguments;
@ -623,7 +613,7 @@ outputOneFunction(function)
}
void
outputFunctions()
outputFunctions(void)
{
outputBigword(externalFunctionCount);
encodingFunction = TRUE;

View File

@ -33,10 +33,19 @@
/* corresponds to routines in buildStuff2.c */
operandType *
buildOperand(kindOfOperand, arg)
operandKindType kindOfOperand;
anyOldThing *arg;
extern void botch (char *message, ...);
extern void error (errorType theError, ...);
extern void freeExpression (expressionType *expression);
extern void freeSelectionList (selectionListType *selectionList);
extern void freeString (stringType *string);
extern void freeBlock (blockType *block);
extern void moreText (char *format, ...);
extern void expandExpression (char *toBuffer, char **toBufferPtr);
extern void assembleBlock (blockType *block);
operandType *
buildOperand(operandKindType kindOfOperand, anyOldThing *arg)
{
operandType *result;
@ -129,13 +138,11 @@ buildOperand(kindOfOperand, arg)
/* corresponds to routines in fixups.c */
operandListType *
duplicateOperandForFixup(operand, isSpecialFunctionOperand)
operandListType *operand;
bool isSpecialFunctionOperand;
duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand)
{
operandListType *result;
expressionType *duplicateExpressionForFixup();
expressionType *duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand);
result = typeAlloc(operandListType);
result->kindOfOperand = operand->kindOfOperand;
@ -182,8 +189,7 @@ duplicateOperandForFixup(operand, isSpecialFunctionOperand)
#define nullFree(thing) if (thing == NULL) return;
void
freeOperand(operand)
operandType *operand;
freeOperand(operandType *operand)
{
nullFree(operand);
switch (operand->kindOfOperand) {
@ -229,9 +235,7 @@ freeOperand(operand)
/* corresponds to routines in listing.c */
void
expandOperand(addressMode, buffer)
operandKindType addressMode;
char * buffer;
expandOperand(operandKindType addressMode, char *buffer)
{
switch (addressMode) {
case IMMEDIATE_OPND: moreText("#"); break;
@ -279,16 +283,15 @@ expandOperand(addressMode, buffer)
#define expansionOn() expandMacros=saveExpansion;
valueType *
evaluateOperand(operand)
operandType *operand;
evaluateOperand(operandType *operand)
{
valueType *result;
bool saveExpansion;
expressionType *expression;
valueType *evaluateExpression();
valueType *evaluateSelectionList();
valueType *newValue();
valueType *evaluateExpression(expressionType *expression, fixupKindType kindOfFixup);
valueType *evaluateSelectionList(selectionListType *selectionList);
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
nullEvaluate(operand);
if (operand->kindOfOperand != EXPRESSION_OPND)
@ -358,8 +361,7 @@ evaluateOperand(operand)
/* from parserMisc.c */
conditionType
invertConditionCode(conditionCode)
conditionType conditionCode;
invertConditionCode(conditionType conditionCode)
{
#define cc (int)conditionCode
@ -376,8 +378,7 @@ invertConditionCode(conditionCode)
/* from semanticMisc.c */
bool
shouldParenthesize(operand)
operandType *operand;
shouldParenthesize(operandType *operand)
{
expressionTermKindType kind;

View File

@ -37,12 +37,14 @@
#include <stdarg.h>
#include <string.h>
statementType *
addLabelToStatement(labelList, statement)
labelListType *labelList;
statementType *statement;
extern void chokePukeAndDie (void);
extern void puntOnError (errorType theError, ...);
statementType *
addLabelToStatement(labelListType *labelList, statementType *statement)
{
statementType *newStatement();
statementType *newStatement(statementKindType kind, statementBodyType body);
if (statement == NULL)
statement = newStatement(NULL_STATEMENT, (statementBodyType){ NULL });
@ -66,16 +68,14 @@ botch(char *message, ...)
}
void
checkDefineAssignmentOperator(assignmentOperator)
assignmentKindType assignmentOperator;
checkDefineAssignmentOperator(assignmentKindType assignmentOperator)
{
if (assignmentOperator != ASSIGN_ASSIGN)
puntOnError(DEFINE_ASSIGNMENT_WRONG_ERROR);
}
statementType *
convertDefineToMdefine(defineStatement)
statementType *defineStatement;
convertDefineToMdefine(statementType *defineStatement)
{
if (defineStatement->kindOfStatement != DEFINE_STATEMENT)
botch("convertDefineToMdefine got statement kind: %d\n",
@ -85,8 +85,7 @@ convertDefineToMdefine(defineStatement)
}
ifStatementBodyType *
extractIfBody(ifStatement)
statementType *ifStatement;
extractIfBody(statementType *ifStatement)
{
ifStatementBodyType *result;
@ -101,8 +100,7 @@ extractIfBody(ifStatement)
}
mifStatementBodyType *
extractMifBody(mifStatement)
statementType *mifStatement;
extractMifBody(statementType *mifStatement)
{
mifStatementBodyType *result;
@ -117,8 +115,7 @@ extractMifBody(mifStatement)
}
stringType *
extractString(textExpression)
operandType *textExpression;
extractString(operandType *textExpression)
{
stringType *result;
@ -131,22 +128,21 @@ extractString(textExpression)
}
void
popMacroOrFunctionNestingDepth()
popMacroOrFunctionNestingDepth(void)
{
if (--macroOrFunctionNestingDepth == 0)
unknownSymbolTag = UNKNOWN_SYMBOL;
}
void
pushMacroOrFunctionNestingDepth()
pushMacroOrFunctionNestingDepth(void)
{
macroOrFunctionNestingDepth++;
unknownSymbolTag = NESTED_UNKNOWN_SYMBOL;
}
char *
saveString(s)
char *s;
saveString(char *s)
{
char *result;

View File

@ -9,8 +9,8 @@ void convertDefineToMDefine(statementType *defineStatement);
ifStatementBodyType *extractIfBody(statementType *ifStatement);
mifStatementBodyType *extractMifBody(statementType *mifStatement);
stringType *extractString(operandType *textExpression);
void popMacroOrFunctionNestingDepth();
void pushMacroOrFunctionNestingDepth();
void popMacroOrFunctionNestingDepth(void);
void pushMacroOrFunctionNestingDepth(void);
char *saveString(char *s);
#endif

View File

@ -44,21 +44,37 @@
These are miscellaneous routines called by the primary semantics routines.
*/
bool
absoluteValue(address)
valueType *address;
extern void error (errorType theError, ...);
extern char *valueKindString (valueKindType valueKind);
extern void moreLabel (char *format, int arg1);
extern void reincarnateSymbol (symbolInContextType *context, symbolUsageKindType newUsage);
extern void printCreateFixup (expressionType *expression, addressType location, fixupKindType kindOfFixup);
extern void flushExpressionString (void);
extern void expandOperand (operandKindType addressMode, char *buffer);
extern void terminateListingFiles (void);
extern void outputObjectFile (void);
extern void outputListing (void);
extern void botch (char *message, ...);
extern void pokeByteValue (addressType location, valueType *value);
extern void pokeWordValue (addressType location, valueType *value);
extern void pokeLongValue (addressType location, valueType *value);
extern void pokeRelativeByteValue (addressType location, valueType *value);
extern void pokeRelativeWordValue (addressType location, valueType *value);
extern void pushBinding (symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage);
bool
absoluteValue(valueType *address)
{
return(address->kindOfValue == ABSOLUTE_VALUE);
}
void
addAttributeToSymbol(symbol, attribute)
symbolTableEntryType *symbol;
symbolAttributesType attribute;
addAttributeToSymbol(symbolTableEntryType *symbol, symbolAttributesType attribute)
{
symbolInContextType *context;
symbolInContextType *getBaseContext();
symbolInContextType *getBaseContext(symbolTableEntryType *identifier);
context = getBaseContext(symbol);
if (context != NULL)
@ -66,8 +82,7 @@ addAttributeToSymbol(symbol, attribute)
}
addressType
addressValue(value)
valueType *value;
addressValue(valueType *value)
{
if (value->kindOfValue==STRING_VALUE ||
value->kindOfValue==CONDITION_VALUE ||
@ -78,9 +93,7 @@ addressValue(value)
}
valueKindType
addValueKind(leftOperand, rightOperand)
valueType *leftOperand;
valueType *rightOperand;
addValueKind(valueType *leftOperand, valueType *rightOperand)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'valueKindType'. */
@ -211,15 +224,13 @@ addValueKind(leftOperand, rightOperand)
}
bool
alreadyDefined(context)
symbolInContextType *context;
alreadyDefined(symbolInContextType *context)
{
return((context->attributes & DEFINED_VARIABLE_ATT) != 0);
}
bool
booleanTest(expression)
expressionType *expression;
booleanTest(expressionType *expression)
{
bool result;
valueType *expressionResult;
@ -242,8 +253,7 @@ booleanTest(expression)
}
int
countArguments(function)
functionDefinitionType *function;
countArguments(functionDefinitionType *function)
{
int result;
argumentDefinitionListType *arguments;
@ -258,8 +268,7 @@ countArguments(function)
}
int
countParameters(parameterList)
operandListType *parameterList;
countParameters(operandListType *parameterList)
{
int result;
@ -272,9 +281,7 @@ countParameters(parameterList)
}
arrayType *
allocArray(size, contentsPtr)
int size;
valueType ***contentsPtr;
allocArray(int size, valueType ***contentsPtr)
{
arrayType *result;
int i;
@ -289,9 +296,7 @@ allocArray(size, contentsPtr)
}
valueType *
createArray(dimension, initializers)
expressionType *dimension;
expressionListType *initializers;
createArray(expressionType *dimension, expressionListType *initializers)
{
int initCount;
valueType *arraySizeValue;
@ -300,7 +305,7 @@ createArray(dimension, initializers)
arrayType *result;
int i;
valueType *newValue();
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
initCount = expressionListLength(initializers);
if ((int)dimension == -1) {
@ -327,8 +332,7 @@ createArray(dimension, initializers)
}
bool
decrementable(value)
valueType *value;
decrementable(valueType *value)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'valueKindType'. */
@ -358,8 +362,7 @@ decrementable(value)
}
int
expressionListLength(expressionList)
expressionListType *expressionList;
expressionListLength(expressionListType *expressionList)
{
int result;
@ -372,11 +375,10 @@ expressionListLength(expressionList)
}
int
fieldValue(symbol)
symbolTableEntryType *symbol;
fieldValue(symbolTableEntryType *symbol)
{
valueType *value;
valueType *evaluateIdentifier();
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
value = evaluateIdentifier(symbol, FALSE, NO_FIXUP);
if (value->kindOfValue != FIELD_VALUE) {
@ -388,8 +390,7 @@ fieldValue(symbol)
}
bool
incrementable(value)
valueType *value;
incrementable(valueType *value)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'valueKindType'. */
@ -419,8 +420,7 @@ incrementable(value)
}
int
intValue(value)
valueType *value;
intValue(valueType *value)
{
if (value->kindOfValue != ABSOLUTE_VALUE) {
error(VALUE_IS_NOT_AN_INT_ERROR);
@ -431,8 +431,7 @@ intValue(value)
}
bool
isAssignable(context)
symbolInContextType *context;
isAssignable(symbolInContextType *context)
{
return( context->usage==ARGUMENT_SYMBOL ||
context->usage==VARIABLE_SYMBOL ||
@ -440,15 +439,13 @@ isAssignable(context)
}
bool
isBuiltInFunction(context)
symbolInContextType *context;
isBuiltInFunction(symbolInContextType *context)
{
return(context!=NULL && context->usage==BUILT_IN_FUNCTION_SYMBOL);
}
bool
isDefinable(context)
symbolInContextType *context;
isDefinable(symbolInContextType *context)
{
return( context->usage==DEFINE_SYMBOL ||
context->usage==DEAD_SYMBOL ||
@ -457,12 +454,11 @@ isDefinable(context)
}
bool
isExternal(symbol)
symbolTableEntryType *symbol;
isExternal(symbolTableEntryType *symbol)
{
symbolInContextType *context;
symbolInContextType *getBaseContext();
symbolInContextType *getBaseContext(symbolTableEntryType *identifier);
context = getBaseContext(symbol);
return (context!=NULL && (context->attributes & GLOBAL_ATT)!=0 &&
@ -470,8 +466,7 @@ isExternal(symbol)
}
bool
isFailure(value)
valueType *value;
isFailure(valueType *value)
{
if (value == NULL)
return(FALSE);
@ -480,15 +475,13 @@ isFailure(value)
}
bool
isFunction(context)
symbolInContextType *context;
isFunction(symbolInContextType *context)
{
return(context!=NULL && context->usage==FUNCTION_SYMBOL);
}
bool
isLastStatementInBlock(statement)
statementType *statement;
isLastStatementInBlock(statementType *statement)
{
statement = statement->nextStatement;
while (statement != NULL) {
@ -521,8 +514,7 @@ isLastStatementInBlock(statement)
}
bool
isLogicalOp(op)
int op;
isLogicalOp(int op)
{
return (op==EQUAL_TO || op==GREATER_THAN || op==
GREATER_THAN_OR_EQUAL_TO || op==LESS_THAN || op==
@ -531,8 +523,7 @@ isLogicalOp(op)
}
bool
isPotentialVariable(context)
symbolInContextType *context;
isPotentialVariable(symbolInContextType *context)
{
return( context->usage == VARIABLE_SYMBOL ||
context->usage == DEAD_SYMBOL ||
@ -540,33 +531,26 @@ isPotentialVariable(context)
}
bool
isUndefined(value)
valueType *value;
isUndefined(valueType *value)
{
return(value==NULL || value->kindOfValue==UNDEFINED_VALUE);
}
bool
isUsable(value)
valueType *value;
isUsable(valueType *value)
{
return(value!=NULL && value->kindOfValue!=UNDEFINED_VALUE &&
value->kindOfValue!=FAIL);
}
bool
logicalXOR(int1, int2)
int int1;
int int2;
logicalXOR(int int1, int int2)
{
return((int1 && !int2) || (int2 && !int1));
}
valueType *
newValue(kindOfValue, value, addressMode)
valueKindType kindOfValue;
int value;
operandKindType addressMode;
newValue(valueKindType kindOfValue, int value, operandKindType addressMode)
{
valueType *result;
@ -578,9 +562,7 @@ newValue(kindOfValue, value, addressMode)
}
valueKindType
opValueKind(leftOperand, rightOperand)
valueType *leftOperand;
valueType *rightOperand;
opValueKind(valueType *leftOperand, valueType *rightOperand)
{
if (leftOperand->kindOfValue==ABSOLUTE_VALUE && rightOperand->
kindOfValue==ABSOLUTE_VALUE)
@ -607,17 +589,14 @@ opValueKind(leftOperand, rightOperand)
}
bool
relocatableValue(address)
valueType *address;
relocatableValue(valueType *address)
{
return( address->kindOfValue==DATA_VALUE ||
address->kindOfValue==RELOCATABLE_VALUE );
}
valueKindType
selectValueKind(leftOperand, rightOperand)
valueType *leftOperand;
valueType *rightOperand;
selectValueKind(valueType *leftOperand, valueType *rightOperand)
{
if (rightOperand->kindOfValue!=FIELD_VALUE ||
(leftOperand->kindOfValue!=ABSOLUTE_VALUE &&
@ -629,9 +608,7 @@ selectValueKind(leftOperand, rightOperand)
}
valueKindType
subValueKind(leftOperand, rightOperand)
valueType *leftOperand;
valueType *rightOperand;
subValueKind(valueType *leftOperand, valueType *rightOperand)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'valueKindType'. */
@ -762,25 +739,22 @@ subValueKind(leftOperand, rightOperand)
}
int
swab(i)
int i;
swab(int i)
{
return(((i & 0xFF) << 8) | ((i & 0xFF00) >> 8));
}
valueType *
swabValue(value)
valueType *value;
swabValue(valueType *value)
{
valueType *newValue();
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
return(newValue(value->kindOfValue, swab(value->value), value->
addressMode));
}
valueKindType
unopValueKind(operand)
valueType *operand;
unopValueKind(valueType *operand)
{
return(operand->kindOfValue==ABSOLUTE_VALUE || operand->kindOfValue==
UNDEFINED_VALUE || operand->kindOfValue==RELOCATABLE_VALUE ?
@ -788,14 +762,12 @@ unopValueKind(operand)
}
void
valueField(symbol, value)
symbolTableEntryType *symbol;
valueType *value;
valueField(symbolTableEntryType *symbol, valueType *value)
{
symbolInContextType *workingContext;
symbolInContextType *getWorkingContext();
symbolTableEntryType *effectiveSymbol();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
symbol = effectiveSymbol(symbol, &workingContext);
expand(moreLabel("%s:", symbol->symbolName));
@ -815,15 +787,13 @@ valueField(symbol, value)
}
void
valueLabel(symbol, value)
symbolTableEntryType *symbol;
valueType *value;
valueLabel(symbolTableEntryType *symbol, valueType *value)
{
symbolInContextType *workingContext;
symbolTableEntryType *generateLocalLabel();
symbolInContextType *getBaseContext();
symbolTableEntryType *effectiveSymbol();
symbolTableEntryType *generateLocalLabel(symbolTableEntryType *symbol);
symbolInContextType *getBaseContext(symbolTableEntryType *identifier);
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
symbol = effectiveSymbol(symbol, &workingContext);
expand(moreLabel("%s:", symbol->symbolName));
@ -864,16 +834,11 @@ valueLabel(symbol, value)
*/
void
createFixup(expression, location, kindOfFixup, codeMode, whichFixup)
expressionType *expression;
addressType location;
fixupKindType kindOfFixup;
codeBufferKindType codeMode;
int whichFixup;
createFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup, codeBufferKindType codeMode, int whichFixup)
{
fixupListType *newFixup;
expressionType *generateFixupExpression();
expressionType *generateFixupExpression(expressionType *expression);
if (debug || emitPrint)
printCreateFixup(expression, location, kindOfFixup);
@ -902,10 +867,10 @@ createFixup(expression, location, kindOfFixup, codeMode, whichFixup)
}
void
finishUp()
finishUp(void)
{
void performFixups();
void performStartAddressFixup();
void performFixups(fixupListType *fixups);
void performStartAddressFixup(void);
if (listingOn)
terminateListingFiles();
@ -936,7 +901,7 @@ isReferenceToRemember(reference)
}
*/
void
noteAnonymousReference()
noteAnonymousReference(void)
{
expressionReferenceListType *newReference;
@ -958,11 +923,7 @@ noteAnonymousReference()
}
void
noteReference(expression, kindOfFixup, location, codeMode)
expressionType *expression;
fixupKindType kindOfFixup;
addressType location;
codeBufferKindType codeMode;
noteReference(expressionType *expression, fixupKindType kindOfFixup, addressType location, codeBufferKindType codeMode)
{
expressionReferenceListType *newReference;
@ -1010,8 +971,7 @@ noteReference(expression, kindOfFixup, location, codeMode)
}
void
performFixups(fixups)
fixupListType *fixups;
performFixups(fixupListType *fixups)
{
valueType *valueToPoke;
@ -1072,11 +1032,11 @@ performFixups(fixups)
}
void
performStartAddressFixup()
performStartAddressFixup(void)
{
expressionType *startAddressExpression;
expressionType *generateFixupExpression();
expressionType *generateFixupExpression(expressionType *expression);
startAddressExpression = (expressionType *)startAddress;
startAddress = evaluateExpression(startAddressExpression,NO_FIXUP_OK);
@ -1094,9 +1054,7 @@ performStartAddressFixup()
}
void
putFixupsHere(kindOfFixupsToPut, whichFixup)
fixupKindType kindOfFixupsToPut;
int whichFixup;
putFixupsHere(fixupKindType kindOfFixupsToPut, int whichFixup)
{
int location;
@ -1187,8 +1145,7 @@ putReferencesHere(kindOfReferencesToPut, whichReference)
*/
void
addNewLocalVariable(symbol)
symbolTableEntryType *symbol;
addNewLocalVariable(symbolTableEntryType *symbol)
{
identifierListType *newLocalVariable;
@ -1199,16 +1156,14 @@ addNewLocalVariable(symbol)
}
symbolTableEntryType *
effectiveSymbol(symbol, assignmentTargetContext)
symbolTableEntryType *symbol;
symbolInContextType **assignmentTargetContext;
effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext)
{
symbolInContextType *context;
operandType *operand;
expressionType *expression;
environmentType *saveEnvironment;
symbolInContextType *getWorkingContext();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
context = getWorkingContext(symbol);
saveEnvironment = currentEnvironment;
@ -1236,18 +1191,16 @@ effectiveSymbol(symbol, assignmentTargetContext)
}
symbolTableEntryType *
generateLocalLabel(symbol)
symbolTableEntryType *symbol;
generateLocalLabel(symbolTableEntryType *symbol)
{
stringType *localLabelString();
symbolTableEntryType *lookupOrEnterSymbol();
stringType *localLabelString(symbolTableEntryType *symbol);
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
return(lookupOrEnterSymbol(localLabelString(symbol), LABEL_SYMBOL));
}
symbolInContextType *
getBaseContext(identifier)
symbolTableEntryType *identifier;
getBaseContext(symbolTableEntryType *identifier)
{
symbolInContextType *result;
@ -1259,8 +1212,7 @@ getBaseContext(identifier)
}
symbolInContextType *
getWorkingContext(identifier)
symbolTableEntryType *identifier;
getWorkingContext(symbolTableEntryType *identifier)
{
symbolInContextType *result;
@ -1274,13 +1226,12 @@ getWorkingContext(identifier)
}
stringType *
localLabelString(symbol)
symbolTableEntryType *symbol;
localLabelString(symbolTableEntryType *symbol)
{
#define TEMP_SYMBOL_SIZE_LIMIT 200
char nameUnderConstruction[TEMP_SYMBOL_SIZE_LIMIT];
stringType *saveString();
stringType *saveString(char *s);
sprintf(nameUnderConstruction, "_%d_", localLabelTagValue(symbol));
strncat(nameUnderConstruction, &(symbName(symbol)[1]),
@ -1289,13 +1240,12 @@ localLabelString(symbol)
}
int
localLabelTagValue(symbol)
symbolTableEntryType *symbol;
localLabelTagValue(symbolTableEntryType *symbol)
{
symbolInContextType *context;
symbolInContextType *getWorkingContext();
void addNewLocalVariable();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
void addNewLocalVariable(symbolTableEntryType *symbol);
context = getWorkingContext(symbol);
if (context == NULL)
@ -1311,12 +1261,10 @@ localLabelTagValue(symbol)
}
void
addBreak(kind, data)
codeBreakKindType kind;
int data;
addBreak(codeBreakKindType kind, int data)
{
codeBreakType *newBreak;
codeBreakType *buildCodeBreak();
codeBreakType *buildCodeBreak(codeBreakKindType kind, addressType address, int data);
newBreak = buildCodeBreak(kind, currentLocationCounter.value, data);
if (codeBreakList == NULL) {
@ -1328,11 +1276,9 @@ addBreak(kind, data)
}
void
reserveAbsolute(startAddress, blockSize)
addressType startAddress;
int blockSize;
reserveAbsolute(addressType startAddress, int blockSize)
{
reservationListType *buildReservation();
reservationListType *buildReservation(addressType startAddress, int blockSize, reservationListType *nextReservation);
if (reservationList != NULL && reservationList->startAddress +
reservationList->blockSize == startAddress)
@ -1343,8 +1289,7 @@ reserveAbsolute(startAddress, blockSize)
}
bool
listableStatement(kind)
statementKindType kind;
listableStatement(statementKindType kind)
{
return( kind == ALIGN_STATEMENT || kind == BLOCK_STATEMENT ||
kind == BYTE_STATEMENT || kind == CONSTRAIN_STATEMENT ||

View File

@ -44,11 +44,11 @@ void valueLabel(symbolTableEntryType *symbol, valueType *value);
/* Fixups and references */
void createFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup, codeBufferKindType codeMode, int whichFixup);
void finishUp();
void noteAnonymousReference();
void finishUp(void);
void noteAnonymousReference(void);
void noteReference(expressionType *expression, fixupKindType kindOfFixup, addressType location, codeBufferKindType codeMode);
void performFixups(fixupListType *fixups);
void performStartAddressFixup();
void performStartAddressFixup(void);
void putFixupsHere(fixupKindType kindOfFixupsToPut, int whichFixup);
/* Contexts and dynamic symbol creation */

View File

@ -54,28 +54,63 @@ bool nullStatementFlag = FALSE;
#define expansionOff() {saveExpansion=expandMacros; expandMacros=FALSE;}
#define expansionOn() expandMacros=saveExpansion;
void
assembleBlock(block)
blockType *block;
extern void error (errorType theError, ...);
extern void moreText (char *format, ...);
extern void expandOperands (int op);
extern void endLine (void);
extern int bindMacroArguments (argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *macroName);
extern void unbindArguments (argumentDefinitionListType *argumentList, int numberToUnbind);
extern void unbindLocalVariables (identifierListType *identifierList);
extern void expandExpression (char *toBuffer, char **toBufferPtr);
extern void emitByte (byte byteValue);
extern void emitString (stringType *string);
extern void emitByteValue (valueType *byteValue);
extern void startLineMarked (void);
extern void tabIndent (void);
extern void emitWordValue (valueType *wordValue);
extern void reincarnateSymbol (symbolInContextType *context, symbolUsageKindType newUsage);
extern char *conditionString (conditionType condition);
extern char *usageString (symbolUsageKindType usageKind);
extern symbolTableEntryType *lookupOrEnterSymbol (stringType *s, symbolUsageKindType kind);
extern bool isDefined (valueType *value);
extern void fixupBranch (valueType *location, valueType target);
extern void fixupJump (simpleFixupListType *locations, valueType target);
extern void pushInputFileStack (stringType *fileName);
extern void saveIndexForListing (statementKindType kindOfStatement, int cumulativeLineNumber);
extern void startLine (void);
extern void expandLabel (void);
extern void emitLongValue (valueType *longValue);
extern void pushBinding (symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage);
extern void saveEndMifForListing (int cumulativeLineNumber);
extern char *valueKindString (valueKindType valueKind);
extern bool strcmplc (char *s1, char *s2);
extern void warning (errorType theError, ...);
extern expressionType *generateFixupExpression (expressionType *expression);
extern void instantiateStruct (structStatementBodyType *structStatement);
extern void assembleStructDefinition (structStatementBodyType *structStatement);
extern void purgeSymbol (symbolTableEntryType *symbol);
extern bool labeledLine (void);
extern void flushExpressionString (void);
extern void freeStatement (statementType *statement);
extern void printStatement (statementType *statement);
void
assembleBlock(blockType *block)
{
nullAssemble(block);
assembleStatement(block, FALSE, NULL);
}
simpleFixupListType *
assembleBlockInsideIf(block, ongoingFixupList)
blockType *block;
simpleFixupListType *ongoingFixupList;
assembleBlockInsideIf(blockType *block, simpleFixupListType *ongoingFixupList)
{
nullAssembleNULL(block);
return(assembleStatement(block, TRUE, ongoingFixupList));
}
bool
operandCheck(opcode, numberOfOperands, evaluatedOperands)
opcodeTableEntryType *opcode;
int numberOfOperands;
valueType *evaluatedOperands[];
operandCheck(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
{
int i;
@ -91,9 +126,7 @@ operandCheck(opcode, numberOfOperands, evaluatedOperands)
}
void
assembleMachineInstruction(opcode, operands)
opcodeTableEntryType *opcode;
operandListType *operands;
assembleMachineInstruction(opcodeTableEntryType *opcode, operandListType *operands)
{
int i;
int op;
@ -140,9 +173,7 @@ assembleMachineInstruction(opcode, operands)
}
void
assembleMacro(macroInstruction, operands)
macroTableEntryType *macroInstruction;
operandListType *operands;
assembleMacro(macroTableEntryType *macroInstruction, operandListType *operands)
{
int numberBound;
identifierListType *savedLocalVariableList;
@ -186,8 +217,7 @@ assembleMacro(macroInstruction, operands)
}
void
assembleAlignStatement(alignStatement)
alignStatementBodyType *alignStatement;
assembleAlignStatement(alignStatementBodyType *alignStatement)
{
int alignment;
bool saveExpansion;
@ -218,8 +248,7 @@ assembleAlignStatement(alignStatement)
}
void
assembleAssertStatement(assertStatement)
assertStatementBodyType *assertStatement;
assembleAssertStatement(assertStatementBodyType *assertStatement)
{
valueType *test;
valueType *message;
@ -249,8 +278,7 @@ assembleAssertStatement(assertStatement)
}
void
assembleBlockStatement(blockStatement)
blockStatementBodyType *blockStatement;
assembleBlockStatement(blockStatementBodyType *blockStatement)
{
valueType *blockIncrement;
int blockSize;
@ -286,8 +314,7 @@ assembleBlockStatement(blockStatement)
}
void
assembleByteStatement(byteStatement)
byteStatementBodyType *byteStatement;
assembleByteStatement(byteStatementBodyType *byteStatement)
{
valueType *byteValue;
@ -311,8 +338,7 @@ assembleByteStatement(byteStatement)
}
void
assembleConstrainStatement(constrainStatement)
constrainStatementBodyType *constrainStatement;
assembleConstrainStatement(constrainStatementBodyType *constrainStatement)
{
valueType *constraintValue;
int constraint;
@ -355,8 +381,7 @@ assembleConstrainStatement(constrainStatement)
}
void
assembleDbyteStatement(dbyteStatement)
dbyteStatementBodyType *dbyteStatement;
assembleDbyteStatement(dbyteStatementBodyType *dbyteStatement)
{
valueType *wordValue;
@ -376,8 +401,7 @@ assembleDbyteStatement(dbyteStatement)
}
void
assembleDefineStatement(defineStatement)
defineStatementBodyType *defineStatement;
assembleDefineStatement(defineStatementBodyType *defineStatement)
{
symbolTableEntryType *symbolToDefine;
symbolInContextType *contextToDefine;
@ -417,8 +441,7 @@ assembleDefineStatement(defineStatement)
}
void
assembleDoUntilStatement(doUntilStatement)
doUntilStatementBodyType *doUntilStatement;
assembleDoUntilStatement(doUntilStatementBodyType *doUntilStatement)
{
valueType topOfLoop;
@ -442,8 +465,7 @@ assembleDoUntilStatement(doUntilStatement)
}
void
assembleDoWhileStatement(doWhileStatement)
doWhileStatementBodyType *doWhileStatement;
assembleDoWhileStatement(doWhileStatementBodyType *doWhileStatement)
{
valueType topOfLoop;
@ -467,8 +489,7 @@ assembleDoWhileStatement(doWhileStatement)
}
void
assembleExternStatement(externStatement)
externStatementBodyType *externStatement;
assembleExternStatement(externStatementBodyType *externStatement)
{
symbolInContextType *context;
symbolTableEntryType *theSymbol;
@ -496,8 +517,7 @@ assembleExternStatement(externStatement)
}
void
assembleFreturnStatement(freturnStatement)
freturnStatementBodyType *freturnStatement;
assembleFreturnStatement(freturnStatementBodyType *freturnStatement)
{
freturnExit = TRUE;
resultOfLastFunctionCall = evaluateExpression(freturnStatement,
@ -505,8 +525,7 @@ assembleFreturnStatement(freturnStatement)
}
void
assembleFunctionStatement(functionStatement)
functionStatementBodyType *functionStatement;
assembleFunctionStatement(functionStatementBodyType *functionStatement)
{
symbolTableEntryType *newFunctionSymbol;
functionDefinitionType *newFunction;
@ -545,8 +564,7 @@ assembleFunctionStatement(functionStatement)
}
void
assembleGroupStatement(groupStatement)
blockType *groupStatement;
assembleGroupStatement(blockType *groupStatement)
{
expand((startLineMarked(), tabIndent(), moreText("{"), endLine(),
tabCount++));
@ -556,10 +574,7 @@ assembleGroupStatement(groupStatement)
}
simpleFixupListType *
assembleIfStatement(ifStatement, terminalIf, ongoingFixupList)
ifStatementBodyType *ifStatement;
bool terminalIf;
simpleFixupListType *ongoingFixupList;
assembleIfStatement(ifStatementBodyType *ifStatement, bool terminalIf, simpleFixupListType *ongoingFixupList)
{
valueType fixupLocation1[COMPOUND_BRANCH_MAX];
simpleFixupListType *fixupLocation2;
@ -609,8 +624,7 @@ assembleIfStatement(ifStatement, terminalIf, ongoingFixupList)
}
void
assembleIfStatementOldStyle(ifStatement)
ifStatementBodyType *ifStatement;
assembleIfStatementOldStyle(ifStatementBodyType *ifStatement)
{
valueType fixupLocation1[COMPOUND_BRANCH_MAX];
simpleFixupListType *fixupLocation2;
@ -642,8 +656,7 @@ assembleIfStatementOldStyle(ifStatement)
}
void
assembleIncludeStatement(includeStatement)
includeStatementBodyType *includeStatement;
assembleIncludeStatement(includeStatementBodyType *includeStatement)
{
stringType *fileName;
valueType *possibleFileName;
@ -663,9 +676,7 @@ assembleIncludeStatement(includeStatement)
}
void
assembleInstructionStatement(instructionStatement, cumulativeLineNumber)
instructionStatementBodyType *instructionStatement;
int cumulativeLineNumber;
assembleInstructionStatement(instructionStatementBodyType *instructionStatement, int cumulativeLineNumber)
{
nullAssemble(instructionStatement);
switch(instructionStatement->kindOfInstruction) {
@ -695,8 +706,7 @@ assembleInstructionStatement(instructionStatement, cumulativeLineNumber)
}
void
assembleLongStatement(longStatement)
longStatementBodyType *longStatement;
assembleLongStatement(longStatementBodyType *longStatement)
{
valueType *longValue;
@ -716,8 +726,7 @@ assembleLongStatement(longStatement)
}
void
assembleMacroStatement(macroStatement)
macroStatementBodyType *macroStatement;
assembleMacroStatement(macroStatementBodyType *macroStatement)
{
macroTableEntryType *newMacro;
@ -739,8 +748,7 @@ assembleMacroStatement(macroStatement)
}
void
assembleMdefineStatement(mdefineStatement)
defineStatementBodyType *mdefineStatement;
assembleMdefineStatement(defineStatementBodyType *mdefineStatement)
{
bool saveExpansion;
@ -753,8 +761,7 @@ assembleMdefineStatement(mdefineStatement)
}
void
assembleMdoUntilStatement(mdoUntilStatement)
mdoUntilStatementBodyType *mdoUntilStatement;
assembleMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
{
bool saveListingOn;
@ -768,8 +775,7 @@ assembleMdoUntilStatement(mdoUntilStatement)
}
void
assembleMdoWhileStatement(mdoWhileStatement)
mdoWhileStatementBodyType *mdoWhileStatement;
assembleMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
{
bool saveListingOn;
@ -783,8 +789,7 @@ assembleMdoWhileStatement(mdoWhileStatement)
}
void
assembleMforStatement(mforStatement)
mforStatementBodyType *mforStatement;
assembleMforStatement(mforStatementBodyType *mforStatement)
{
bool saveListingOn;
bool saveExpansion;
@ -805,9 +810,7 @@ assembleMforStatement(mforStatement)
}
void
assembleMifStatement(mifStatement, cumulativeLineNumber)
mifStatementBodyType *mifStatement;
int cumulativeLineNumber;
assembleMifStatement(mifStatementBodyType *mifStatement, int cumulativeLineNumber)
{
while (mifStatement != NULL) {
if (mifStatement->mifCondition == NULL) {
@ -826,8 +829,7 @@ assembleMifStatement(mifStatement, cumulativeLineNumber)
}
void
assembleMswitchStatement(mswitchStatement)
mswitchStatementBodyType *mswitchStatement;
assembleMswitchStatement(mswitchStatementBodyType *mswitchStatement)
{
valueType *switchValue;
caseListType *caseList;
@ -888,8 +890,7 @@ assembleMswitchStatement(mswitchStatement)
}
void
assembleMvariableStatement(mvariableStatement)
mvariableStatementBodyType *mvariableStatement;
assembleMvariableStatement(mvariableStatementBodyType *mvariableStatement)
{
identifierListType *newLocalVariable;
int initCount;
@ -923,8 +924,7 @@ assembleMvariableStatement(mvariableStatement)
}
void
assembleMwhileStatement(mwhileStatement)
mwhileStatementBodyType *mwhileStatement;
assembleMwhileStatement(mwhileStatementBodyType *mwhileStatement)
{
bool saveListingOn;
@ -938,8 +938,7 @@ assembleMwhileStatement(mwhileStatement)
}
void
assembleOrgStatement(orgStatement)
orgStatementBodyType *orgStatement;
assembleOrgStatement(orgStatementBodyType *orgStatement)
{
valueType *orgAddress;
bool saveExpansion;
@ -967,8 +966,7 @@ assembleOrgStatement(orgStatement)
}
void
assemblePerformStatement(performStatement)
performStatementBodyType *performStatement;
assemblePerformStatement(performStatementBodyType *performStatement)
{
nullAssemble(performStatement);
sideEffectFlag = FALSE;
@ -978,8 +976,7 @@ assemblePerformStatement(performStatement)
}
void
assembleRelStatement(relStatement)
relStatementBodyType *relStatement;
assembleRelStatement(relStatementBodyType *relStatement)
{
targetOffset = 0;
if (!relocatableValue(&currentLocationCounter)) {
@ -992,8 +989,7 @@ assembleRelStatement(relStatement)
}
void
assembleStartStatement(startStatement)
startStatementBodyType *startStatement;
assembleStartStatement(startStatementBodyType *startStatement)
{
nullAssemble(startStatement);
expand(moreText("start\t"));
@ -1020,8 +1016,7 @@ assembleStartStatement(startStatement)
}
void
assembleStringStatement(stringStatement)
stringStatementBodyType *stringStatement;
assembleStringStatement(stringStatementBodyType *stringStatement)
{
valueType *byteValue;
@ -1046,8 +1041,7 @@ assembleStringStatement(stringStatement)
}
void
assembleStructStatement(structStatement)
structStatementBodyType *structStatement;
assembleStructStatement(structStatementBodyType *structStatement)
{
nullAssemble(structStatement);
if (structStatement->structBody == NULL)
@ -1057,8 +1051,7 @@ assembleStructStatement(structStatement)
}
void
assembleTargetStatement(targetStatement)
targetStatementBodyType *targetStatement;
assembleTargetStatement(targetStatementBodyType *targetStatement)
{
valueType *targetAddress;
bool saveExpansion;
@ -1081,8 +1074,7 @@ assembleTargetStatement(targetStatement)
}
void
assembleUndefineStatement(undefineStatement)
undefineStatementBodyType *undefineStatement;
assembleUndefineStatement(undefineStatementBodyType *undefineStatement)
{
expand(moreText("undefine\t"));
while (undefineStatement != NULL) {
@ -1096,8 +1088,7 @@ assembleUndefineStatement(undefineStatement)
}
void
assembleVariableStatement(variableStatement)
variableStatementBodyType *variableStatement;
assembleVariableStatement(variableStatementBodyType *variableStatement)
{
symbolTableEntryType *newVariable;
symbolInContextType *contextForVariable;
@ -1143,8 +1134,7 @@ assembleVariableStatement(variableStatement)
}
void
assembleWhileStatement(whileStatement)
whileStatementBodyType *whileStatement;
assembleWhileStatement(whileStatementBodyType *whileStatement)
{
valueType topOfLoop;
valueType fixupLocation[COMPOUND_BRANCH_MAX];
@ -1175,8 +1165,7 @@ assembleWhileStatement(whileStatement)
}
void
assembleWordStatement(wordStatement)
wordStatementBodyType *wordStatement;
assembleWordStatement(wordStatementBodyType *wordStatement)
{
valueType *word;
@ -1411,8 +1400,7 @@ assembleStatementBody(kind, body, cumulativeLineNumber, worryAboutIf,
}
void
assembleLabelList(labelList)
labelListType *labelList;
assembleLabelList(labelListType *labelList)
{
while (labelList != NULL) {
if (structNestingDepth == 0)
@ -1428,10 +1416,7 @@ assembleLabelList(labelList)
}
simpleFixupListType *
assembleStatement(statement, insideIf, ongoingFixupList)
statementType *statement;
bool insideIf;
simpleFixupListType *ongoingFixupList;
assembleStatement(statementType *statement, bool insideIf, simpleFixupListType *ongoingFixupList)
{
char *saveFileName;
int saveLineNumber;
@ -1477,8 +1462,7 @@ assembleStatement(statement, insideIf, ongoingFixupList)
}
void
eatStatement(statement)
statementType *statement;
eatStatement(statementType *statement)
{
if (debug) {
printf("assembling:\n");

View File

@ -30,10 +30,22 @@
#include "macrossTypes.h"
#include "macrossGlobals.h"
void
putStructFixups(base, fixups)
int base;
fixupListType *fixups;
extern void botch (char *message, ...);
extern void error (errorType theError, ...);
extern void moreText (char *format, ...);
extern void endLine (void);
extern void emitByte (byte byteValue);
extern bool listableStatement (statementKindType kind);
extern void startLine (void);
extern void assembleLabelList (labelListType *labelList);
extern void expandLabel (void);
extern void tabIndent (void);
extern bool assembleStatementBody (statementKindType kind, statementBodyType body, int cumulativeLineNumber, bool worryAboutIf, simpleFixupListType **ifFixupList);
extern void startLineMarked (void);
void
putStructFixups(int base, fixupListType *fixups)
{
fixupListType *newFixup;
@ -54,9 +66,7 @@ putStructFixups(base, fixups)
}
void
putStructReferences(base, references)
int base;
expressionReferenceListType *references;
putStructReferences(int base, expressionReferenceListType *references)
{
expressionReferenceListType *newReference;
int currentMode;
@ -80,14 +90,13 @@ putStructReferences(base, references)
}
void
instantiateStruct(structStatement)
structStatementBodyType *structStatement;
instantiateStruct(structStatementBodyType *structStatement)
{
int i;
int base;
symbolInContextType *context;
symbolInContextType *getWorkingContext();
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
#define structInstance ((structInstanceType *) context->value->value)
@ -112,8 +121,7 @@ instantiateStruct(structStatement)
}
structInstanceType *
assembleStructDefinitionBody(structBody)
structBodyType *structBody;
assembleStructDefinitionBody(structBodyType *structBody)
{
int i;
simpleFixupListType *dummy;
@ -144,13 +152,12 @@ assembleStructDefinitionBody(structBody)
}
void
assembleStructDefinition(structStatement)
structStatementBodyType *structStatement;
assembleStructDefinition(structStatementBodyType *structStatement)
{
symbolTableEntryType *name;
symbolInContextType *context;
symbolTableEntryType *effectiveSymbol();
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
name = effectiveSymbol(structStatement->structName, &context);
if (context == NULL)

View File

@ -34,8 +34,7 @@
/* conditionString similarly deals with condition codes */
char *
conditionString(condition)
conditionType condition;
conditionString(conditionType condition)
{
/* This table MUST be maintained congruently with the definition of the
enumerated type 'conditionType' */
@ -67,8 +66,7 @@ conditionString(condition)
/* tokenString similarly deals with parser tokens */
char *
tokenString(token)
int token;
tokenString(int token)
{
/* This table MUST be maintained congruently with the token definitions in
the file 'y.tab.h' as output by yacc. */