mirror of
https://github.com/Museum-of-Art-and-Digital-Entertainment/macross.git
synced 2024-06-12 21:29:51 +00:00
Push everything into headers for Slinky
This commit is contained in:
parent
cefd64ed6f
commit
fa1c08008e
|
@ -30,6 +30,11 @@
|
|||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "slinkyExpressions.h"
|
||||
#include "builtins.h"
|
||||
#include "errorStuff.h"
|
||||
#include "expr.h"
|
||||
#include "link.h"
|
||||
#include "relocate.h"
|
||||
#include <string.h>
|
||||
|
||||
#define getSymbol() ((symbolType *)getNumber())
|
||||
|
@ -409,7 +414,6 @@ symbolLookupBIF(argCount)
|
|||
{
|
||||
symbolType *symbol;
|
||||
stringType *symbolName;
|
||||
symbolType *lookupGlobalSymbol();
|
||||
|
||||
if (argCount < 1) {
|
||||
tooFewArgs(argCount, "symbolLookup");
|
||||
|
|
24
slinky/builtins.h
Normal file
24
slinky/builtins.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef BUILTINS_H_
|
||||
#define BUILTINS_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void tooFewArgs(int argCount, stringType *name);
|
||||
void tooManyArgs(int argCount, stringType *name);
|
||||
stringType *atasciiBIF(int argCount);
|
||||
stringType *atasciiColorBIF(int argCount);
|
||||
bool isAbsoluteValueBIF(int argCount);
|
||||
bool isConditionCodeBIF(int argCount);
|
||||
bool isDefinedBIF(int argCount);
|
||||
bool isExternalBIF(int argCount);
|
||||
int nthCharBIF(int argCount);
|
||||
int printfBIF(int argCount);
|
||||
stringType *strcatBIF(int argCount);
|
||||
int strcmpBIF(int argCount);
|
||||
int strcmplcBIF(int argCount);
|
||||
int strlenBIF(int argCount);
|
||||
char *substrBIF(int argCount);
|
||||
addressType symbolLookupBIF(int argCount);
|
||||
stringType *symbolNameBIF(int argCount);
|
||||
|
||||
#endif
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
|
||||
#include "debugPrint.h"
|
||||
|
||||
static char *modeStrings[2] = {
|
||||
"abs",
|
||||
|
|
14
slinky/debugPrint.h
Normal file
14
slinky/debugPrint.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef DEBUG_PRINT_H_
|
||||
#define DEBUG_PRINT_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void printCode(int startAddress, int endAddress, int mode);
|
||||
void printReference(expressionReferenceType *reference);
|
||||
void printReferenceFixup(expressionReferenceType *reference);
|
||||
void printSymbol(int symbolTag, symbolType *symbol);
|
||||
void printLoadMapSymbol(symbolType *symbol);
|
||||
void printGlobalSymbols(void);
|
||||
void printExpression(expressionPCType expression, int length);
|
||||
|
||||
#endif
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "errorStuff.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
|
8
slinky/errorStuff.h
Normal file
8
slinky/errorStuff.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef ERROR_STUFF_H_
|
||||
#define ERROR_STUFF_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void error(errorType theError, ...);
|
||||
|
||||
#endif
|
|
@ -30,6 +30,9 @@
|
|||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "slinkyExpressions.h"
|
||||
#include "expr.h"
|
||||
#include "errorStuff.h"
|
||||
#include "initialize.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
#define overSymbol() (pc+=sizeof(symbolType *))
|
||||
|
@ -41,12 +44,6 @@
|
|||
#define nextByte(byt) (byt = *pc++)
|
||||
#define intOp(byt) (byt+256)
|
||||
|
||||
addressType evaluateExpression();
|
||||
void skipArray();
|
||||
void skipClause();
|
||||
void skipString();
|
||||
void skipExpression();
|
||||
|
||||
static bool hitFreturn = FALSE;
|
||||
static addressType functionResult;
|
||||
|
||||
|
|
57
slinky/expr.h
Normal file
57
slinky/expr.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
#ifndef EXPR_H_
|
||||
#define EXPR_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
int getNumber(void);
|
||||
addressType evaluateArray(void);
|
||||
addressType evaluateAssert(void);
|
||||
addressType evaluateBinop(void);
|
||||
addressType evaluateBlock(void);
|
||||
addressType evaluateConditionCode(void);
|
||||
void pushSymbol(symbolType *symbol, addressType value);
|
||||
void bindFunctionArguments(functionType *theFunction, int argCount);
|
||||
void undoBindings(void);
|
||||
addressType evaluateFreturn(void);
|
||||
addressType evaluateBuiltinFunctionCall(void);
|
||||
addressType evaluateFunctionCall(void);
|
||||
addressType evaluateHere(void);
|
||||
addressType evaluateMdefine(void);
|
||||
addressType evaluateMdoUntil(void);
|
||||
addressType evaluateMdoWhile(void);
|
||||
addressType evaluateMfor(void);
|
||||
addressType evaluateMif(void);
|
||||
bool evaluateClause(addressType pattern);
|
||||
addressType evaluateMswitch(void);
|
||||
addressType evaluateMwhile(void);
|
||||
addressType evaluateMvariable(void);
|
||||
addressType evaluateNumber(void);
|
||||
addressType evaluateRelocatableNumber(void);
|
||||
addressType evaluatePerform(void);
|
||||
addressType evaluatePostop(void);
|
||||
addressType evaluatePreop(void);
|
||||
addressType evaluateString(void);
|
||||
addressType evaluateSymbol(void);
|
||||
addressType evaluateUnop(void);
|
||||
addressType evaluateExpression(void);
|
||||
void skipArray(void);
|
||||
void skipAssert(void);
|
||||
void skipBinop(void);
|
||||
void skipBlock(void);
|
||||
void skipFunctionCall(void);
|
||||
void skipMdefine(void);
|
||||
void skipMdoUntil(void);
|
||||
void skipMdoWhile(void);
|
||||
void skipMfor(void);
|
||||
void skipMif(void);
|
||||
void skipClause(void);
|
||||
void skipMswitch(void);
|
||||
void skipMvariable(void);
|
||||
void skipMwhile(void);
|
||||
void skipPostop(void);
|
||||
void skipPreop(void);
|
||||
void skipString(void);
|
||||
void skipUnop(void);
|
||||
void skipExpression(void);
|
||||
|
||||
#endif
|
|
@ -29,6 +29,12 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "initialize.h"
|
||||
#include "errorStuff.h"
|
||||
#include "main.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static char *outputFileName;
|
||||
|
||||
|
@ -52,9 +58,6 @@ initializeStuff(argc, argv)
|
|||
int mapFilesFound;
|
||||
char *mapFileName;
|
||||
|
||||
void queueInputFile();
|
||||
void queueLoadAddress();
|
||||
|
||||
currentFileName = "<command line>";
|
||||
errorFlag = FALSE;
|
||||
packFlag = FALSE;
|
||||
|
|
11
slinky/initialize.h
Normal file
11
slinky/initialize.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef INITIALIZE_H_
|
||||
#define INITIALIZE_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void chokePukeAndDie(void);
|
||||
void initializeStuff(int argc, char **argv);
|
||||
void queueInputFile(char *name);
|
||||
void queueLoadAddress(char *addressString);
|
||||
|
||||
#endif
|
|
@ -31,6 +31,9 @@
|
|||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "slinkyExpressions.h"
|
||||
#include "errorStuff.h"
|
||||
#include "expr.h"
|
||||
#include "instantiate.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
#define overFunction() (pc+=sizeof(functionType *))
|
||||
|
@ -38,10 +41,6 @@
|
|||
#define overByte() pc++
|
||||
#define nextByte(byt) (byt = *pc++)
|
||||
|
||||
void putSymbolPointersIntoArray();
|
||||
void putSymbolPointersIntoClause();
|
||||
void putSymbolPointersIntoExpression();
|
||||
|
||||
void
|
||||
putNumber(number)
|
||||
int number;
|
||||
|
|
29
slinky/instantiate.h
Normal file
29
slinky/instantiate.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef INSTANTIATE_H_
|
||||
#define INSTANTIATE_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void putNumber(int number);
|
||||
void instantiateSymbol(void);
|
||||
void instantiateFunction(void);
|
||||
void putSymbolPointersIntoArray(void);
|
||||
void putSymbolPointersIntoAssert(void);
|
||||
void putSymbolPointersIntoBinop(void);
|
||||
void putSymbolPointersIntoBlock(void);
|
||||
void putSymbolPointersIntoBuiltinFunctionCall(void);
|
||||
void putSymbolPointersIntoFunctionCall(void);
|
||||
void putSymbolPointersIntoMdefine(void);
|
||||
void putSymbolPointersIntoMdoUntil(void);
|
||||
void putSymbolPointersIntoMdoWhile(void);
|
||||
void putSymbolPointersIntoMfor(void);
|
||||
void putSymbolPointersIntoMif(void);
|
||||
void putSymbolPointersIntoClause(void);
|
||||
void putSymbolPointersIntoMswitch(void);
|
||||
void putSymbolPointersIntoMvariable(void);
|
||||
void putSymbolPointersIntoMwhile(void);
|
||||
void putSymbolPointersIntoPostop(void);
|
||||
void putSymbolPointersIntoPreop(void);
|
||||
void putSymbolPointersIntoUnop(void);
|
||||
void putSymbolPointersIntoExpression(void);
|
||||
|
||||
#endif
|
|
@ -29,6 +29,15 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "link.h"
|
||||
#include "debugPrint.h"
|
||||
#include "errorStuff.h"
|
||||
#include "instantiate.h"
|
||||
#include "poke.h"
|
||||
#include "read.h"
|
||||
#include "relocate.h"
|
||||
#include "write.h"
|
||||
|
||||
/*#define readWord(f,fn) ((getc(f) & 0xFF) | ((getc(f) & 0xFF)<<8))*/
|
||||
|
||||
/*
|
||||
|
@ -102,7 +111,6 @@ internalizeOneObjectFile(objectFile)
|
|||
int mode;
|
||||
addressType startAddress;
|
||||
addressType endAddress;
|
||||
bool compareSymbolValues();
|
||||
|
||||
currentFileName = objectFile->name;
|
||||
if ((objectFildes = fopen(objectFile->name, "r")) == NULL) {
|
||||
|
|
19
slinky/link.h
Normal file
19
slinky/link.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef LINK_H_
|
||||
#define LINK_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
bool internalizeOneObjectFile(objectFileListType *objectFile);
|
||||
bool strcmplc(char *s1, char *s2);
|
||||
bool compareSymbols(symbolType **symbol1, symbolType **symbol2);
|
||||
void buildGlobalSymbolTable(objectFileListType *inputFileList);
|
||||
bool readem(void);
|
||||
codeSegmentHeaderType *locateConflictingSegment(codeSegmentHeaderType *codeSegment);
|
||||
void reserveSegment(addressType start, addressType end);
|
||||
codeSegmentHeaderType *allocateAbsolute(codeSegmentHeaderType *codeSegment);
|
||||
void reserveReservations(void);
|
||||
void installSegment(codeSegmentHeaderType *codeSegment);
|
||||
void installAbsoluteCodeSegment(codeSegmentHeaderType *codeSegment);
|
||||
void linkem(void);
|
||||
|
||||
#endif
|
|
@ -29,7 +29,11 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "main.h"
|
||||
#include "initialize.h"
|
||||
#include "link.h"
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
|
@ -38,8 +42,7 @@ main(argc, argv)
|
|||
linkem();
|
||||
if (errorFlag)
|
||||
chokePukeAndDie();
|
||||
else
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
8
slinky/main.h
Normal file
8
slinky/main.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef MAIN_H_
|
||||
#define MAIN_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void printVersion(void);
|
||||
|
||||
#endif
|
|
@ -30,11 +30,9 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
|
||||
typedef struct {
|
||||
symbolType *symbol;
|
||||
stringType *fileName;
|
||||
} loadMapTableEntryType;
|
||||
#include "map.h"
|
||||
#include "debugPrint.h"
|
||||
#include "link.h"
|
||||
|
||||
int
|
||||
compareLoadMapEntries(entry1, entry2)
|
||||
|
|
14
slinky/map.h
Normal file
14
slinky/map.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef MAP_H_
|
||||
#define MAP_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
typedef struct {
|
||||
symbolType *symbol;
|
||||
stringType *fileName;
|
||||
} loadMapTableEntryType;
|
||||
|
||||
int compareLoadMapEntries(loadMapTableEntryType *entry1, loadMapTableEntryType *entry2);
|
||||
void outputLoadMap(void);
|
||||
|
||||
#endif
|
|
@ -31,6 +31,10 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "poke.h"
|
||||
#include "debugPrint.h"
|
||||
#include "errorStuff.h"
|
||||
#include "expr.h"
|
||||
|
||||
bool
|
||||
isWordSized(value)
|
||||
|
|
15
slinky/poke.h
Normal file
15
slinky/poke.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef POKE_H_
|
||||
#define POKE_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
bool isWordSized(int value);
|
||||
bool isByteSized(int value);
|
||||
bool isByteOffset(int value);
|
||||
int computeRelativeValue(int valueToPoke, codeSegmentHeaderType *codeSegment, int offset);
|
||||
int getBaseValue(byte *codeBuffer, int offset, int referenceKind);
|
||||
void pokeValue(int value, byte *codeBuffer, int offset, int referenceKind, int trueAddress);
|
||||
void fixupReference(expressionReferenceType *reference, codeSegmentHeaderType *codeSegment);
|
||||
void pokem(void);
|
||||
|
||||
#endif
|
|
@ -31,6 +31,12 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "read.h"
|
||||
#include "debugPrint.h"
|
||||
#include "errorStuff.h"
|
||||
#include "initialize.h"
|
||||
#include "instantiate.h"
|
||||
#include "link.h"
|
||||
|
||||
#define isAbsolute(symbol) (((symbol)->symbolClass & SYMBOL_ABSOLUTE) != 0)
|
||||
#define isRelocatable(symbol) (((symbol)->symbolClass &SYMBOL_RELOCATABLE)!=0)
|
||||
|
@ -520,7 +526,6 @@ readReservations(objectFile, objectFildes)
|
|||
FILE *objectFildes;
|
||||
{
|
||||
addressType startAddress;
|
||||
reservationListType *buildReservation();
|
||||
|
||||
if (debug)
|
||||
printf(" reservations\n");
|
||||
|
|
28
slinky/read.h
Normal file
28
slinky/read.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef READ_H_
|
||||
#define READ_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void fileCheck(FILE *fildes, char *fileName);
|
||||
wordType readWord(FILE *file, char *fileName);
|
||||
byte readByte(FILE *file, char *fileName);
|
||||
bigWord readBigword(FILE *file, char *fileName);
|
||||
bigWord read3ByteWord(FILE *file, char *fileName);
|
||||
int readString(char *buffer, FILE *fildes, char *fileName);
|
||||
void readChunk(byte *buffer, int numberOfBytes, FILE *fildes, char *fileName);
|
||||
void readCode(addressType startAddress, addressType endAddress, int mode, objectFileListType *objectFile, FILE *objectFildes);
|
||||
bool compareReferences(expressionReferenceType *reference1, expressionReferenceType *reference2);
|
||||
void sortReferences(expressionReferenceType *theReferences, int numberOfReferences);
|
||||
void readReference(expressionReferenceType *reference, FILE *fildes, char *fileName);
|
||||
void readReferences(objectFileListType *objectFile, FILE *objectFildes);
|
||||
bool compareSymbolValues(symbolType **symbol1, symbolType **symbol2);
|
||||
void readSymbols(objectFileListType *objectFile, FILE *objectFildes);
|
||||
expressionPCType readOneExpression(objectFileListType *objectFile, FILE *objectFildes);
|
||||
void readExpressions(objectFileListType *objectFile, FILE *objectFildes);
|
||||
argumentListType *readArgumentList(objectFileListType *objectFile, FILE *objectFildes);
|
||||
void readFunctions(objectFileListType *objectFile, FILE *objectFildes);
|
||||
void instantiateExpressionAndSymbolPointers(objectFileListType *objectFile);
|
||||
void readReservations(objectFileListType *objectFile, FILE *objectFildes);
|
||||
reservationListType *buildReservation(addressType startAddress, int blockSize, reservationListType *nextReservation);
|
||||
|
||||
#endif
|
|
@ -30,6 +30,11 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "relocate.h"
|
||||
#include "debugPrint.h"
|
||||
#include "errorStuff.h"
|
||||
#include "link.h"
|
||||
#include "map.h"
|
||||
|
||||
#define isUndefined(symbol) (((symbol)->symbolClass & ~SYMBOL_EXTERNAL) == 0)
|
||||
|
||||
|
|
22
slinky/relocate.h
Normal file
22
slinky/relocate.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef RELOCATE_H_
|
||||
#define RELOCATE_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void removeZeroPageFromFreeList(void);
|
||||
addressType align(addressType address, int alignment);
|
||||
addressType constrain(addressType address, int size, addressType constraint);
|
||||
void moveRelocationBase(addressType newBase);
|
||||
addressType allocateRelocatable(codeSegmentHeaderType *codeSegment);
|
||||
void relocateOneCodeSegment(codeSegmentHeaderType *codeSegment, addressType targetLocation);
|
||||
void relocatem(void);
|
||||
codeSegmentHeaderType *matchModes(symbolType *symbol, codeSegmentHeaderType *codeSegment);
|
||||
bool matchedModes(symbolType *symbol, codeSegmentHeaderType *codeSegment);
|
||||
codeSegmentHeaderType *synchronizeCodeSegment(symbolType *symbol, codeSegmentHeaderType *codeSegment);
|
||||
void handleGlobalSymbol(symbolType *symbol);
|
||||
void valueSymbol(symbolType *symbol, codeSegmentHeaderType *codeSegment);
|
||||
symbolType *lookupGlobalSymbol(char *symbolName);
|
||||
void valueUndefinedSymbol(symbolType *symbol);
|
||||
void valuem(void);
|
||||
|
||||
#endif
|
|
@ -28,23 +28,7 @@
|
|||
*/
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
addressType atasciiBIF();
|
||||
addressType atasciiColorBIF();
|
||||
addressType isAbsoluteValueBIF();
|
||||
addressType isConditionCodeBIF();
|
||||
addressType isDefinedBIF();
|
||||
addressType isExternalBIF();
|
||||
addressType nthCharBIF();
|
||||
addressType printfBIF();
|
||||
addressType strcatBIF();
|
||||
addressType strcmpBIF();
|
||||
addressType strcmplcBIF();
|
||||
addressType strlenBIF();
|
||||
addressType substrBIF();
|
||||
addressType symbolDefineBIF();
|
||||
addressType symbolLookupBIF();
|
||||
addressType symbolNameBIF();
|
||||
#include "builtins.h"
|
||||
|
||||
/* Used to initialize symbols representing built-in functions */
|
||||
struct {
|
||||
|
|
7
slinky/slinkyTables.h
Normal file
7
slinky/slinkyTables.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef SLINKY_TABLES_H_
|
||||
#define SLINKY_TABLES_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
|
||||
#endif
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
8-March-1985
|
||||
*/
|
||||
#ifndef SLINKY_TYPES_H_
|
||||
#define SLINKY_TYPES_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -188,3 +190,5 @@ typedef enum {
|
|||
|
||||
#define typeAlloc(type) (type *)malloc(sizeof(type))
|
||||
#define typeAllocBlock(type, size) (type *)malloc(sizeof(type) * (size))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "slinkyTypes.h"
|
||||
#include "slinkyGlobals.h"
|
||||
#include "write.h"
|
||||
|
||||
#define writeWord(aWord) putc(aWord & 0xFF, loadFileOutput);\
|
||||
putc((aWord >> 8) & 0xFF, loadFileOutput)
|
||||
|
|
10
slinky/write.h
Normal file
10
slinky/write.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef WRITE_H_
|
||||
#define WRITE_H_
|
||||
|
||||
#include "slinkyTypes.h"
|
||||
|
||||
void writeEntryPoint(void);
|
||||
void writeCodeSegment(codeSegmentHeaderType *codeSegment);
|
||||
void writem(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user