mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
asm: moved includes to include/asm/
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
This commit is contained in:
36
include/asm/asm.h
Normal file
36
include/asm/asm.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* asm.h
|
||||
*
|
||||
* Contains some assembler-wide defines and externs
|
||||
*
|
||||
* Copyright 1997 Carsten Sorensen
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ASMOTOR_ASM_ASM_H
|
||||
#define ASMOTOR_ASM_ASM_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "asm/types.h"
|
||||
#include "asm/symbol.h"
|
||||
|
||||
#include "localasm.h"
|
||||
|
||||
#include "asmotor.h"
|
||||
|
||||
extern SLONG nLineNo;
|
||||
extern ULONG nTotalLines;
|
||||
extern ULONG nPC;
|
||||
extern ULONG nPass;
|
||||
extern ULONG nIFDepth;
|
||||
extern char tzCurrentFileName[_MAX_PATH + 1];
|
||||
extern struct Section *pCurrentSection;
|
||||
extern struct sSymbol *tHashedSymbols[HASHSIZE];
|
||||
extern struct sSymbol *pPCSymbol;
|
||||
extern UBYTE oDontExpandStrings;
|
||||
|
||||
#define MAXMACROARGS 9
|
||||
#define MAXINCPATHS 16
|
||||
|
||||
#endif // ASM_H
|
||||
41
include/asm/fstack.h
Normal file
41
include/asm/fstack.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* fstack.h
|
||||
*
|
||||
* Contains some assembler-wide defines and externs
|
||||
*
|
||||
* Copyright 1997 Carsten Sorensen
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ASMOTOR_ASM_FSTACK_H
|
||||
#define ASMOTOR_ASM_FSTACK_H
|
||||
|
||||
#include "asm/asm.h"
|
||||
#include "asm/types.h"
|
||||
#include "asm/lexer.h"
|
||||
|
||||
struct sContext {
|
||||
YY_BUFFER_STATE FlexHandle;
|
||||
struct sSymbol *pMacro;
|
||||
struct sContext *pNext;
|
||||
char tzFileName[_MAX_PATH + 1];
|
||||
char *tzMacroArgs[MAXMACROARGS + 1];
|
||||
SLONG nLine;
|
||||
ULONG nStatus;
|
||||
FILE *pFile;
|
||||
char *pREPTBlock;
|
||||
ULONG nREPTBlockCount;
|
||||
ULONG nREPTBlockSize;
|
||||
};
|
||||
|
||||
extern ULONG fstk_RunInclude(char *s);
|
||||
extern void fstk_RunMacroArg(SLONG s);
|
||||
extern ULONG fstk_Init(char *s);
|
||||
extern void fstk_Dump(void);
|
||||
extern void fstk_AddIncludePath(char *s);
|
||||
extern ULONG fstk_RunMacro(char *s);
|
||||
extern void fstk_RunRept(ULONG count);
|
||||
extern void fstk_FindFile(char *s);
|
||||
|
||||
extern int yywrap(void);
|
||||
|
||||
#endif
|
||||
65
include/asm/lexer.h
Normal file
65
include/asm/lexer.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef ASMOTOR_ASM_LEXER_H
|
||||
#define ASMOTOR_ASM_LEXER_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "asm/types.h"
|
||||
|
||||
#define LEXHASHSIZE 512
|
||||
|
||||
struct sLexInitString {
|
||||
char *tzName;
|
||||
ULONG nToken;
|
||||
};
|
||||
|
||||
struct sLexFloat {
|
||||
ULONG(*Callback) (char *s, ULONG size);
|
||||
ULONG nToken;
|
||||
};
|
||||
|
||||
struct yy_buffer_state {
|
||||
char *pBufferStart;
|
||||
char *pBuffer;
|
||||
ULONG nBufferSize;
|
||||
ULONG oAtLineStart;
|
||||
};
|
||||
|
||||
enum eLexerState {
|
||||
LEX_STATE_NORMAL,
|
||||
LEX_STATE_MACROARGS
|
||||
};
|
||||
|
||||
#define INITIAL 0
|
||||
#define macroarg 3
|
||||
|
||||
typedef struct yy_buffer_state *YY_BUFFER_STATE;
|
||||
|
||||
extern void yy_set_state(enum eLexerState i);
|
||||
extern YY_BUFFER_STATE yy_create_buffer(FILE * f);
|
||||
extern YY_BUFFER_STATE yy_scan_bytes(char *mem, ULONG size);
|
||||
extern void yy_delete_buffer(YY_BUFFER_STATE);
|
||||
extern void yy_switch_to_buffer(YY_BUFFER_STATE);
|
||||
extern ULONG lex_FloatAlloc(struct sLexFloat *tok);
|
||||
extern void lex_FloatAddRange(ULONG id, UWORD start, UWORD end);
|
||||
extern void lex_FloatDeleteRange(ULONG id, UWORD start, UWORD end);
|
||||
extern void lex_FloatAddFirstRange(ULONG id, UWORD start, UWORD end);
|
||||
extern void lex_FloatDeleteFirstRange(ULONG id, UWORD start, UWORD end);
|
||||
extern void lex_FloatAddSecondRange(ULONG id, UWORD start, UWORD end);
|
||||
extern void lex_FloatDeleteSecondRange(ULONG id, UWORD start, UWORD end);
|
||||
extern void lex_Init(void);
|
||||
extern void lex_AddStrings(struct sLexInitString *lex);
|
||||
extern void lex_SetBuffer(char *buffer, ULONG len);
|
||||
extern ULONG yylex(void);
|
||||
extern void yyunput(char c);
|
||||
extern void yyunputstr(char *s);
|
||||
extern void yyskipbytes(ULONG count);
|
||||
extern void yyunputbytes(ULONG count);
|
||||
|
||||
extern YY_BUFFER_STATE pCurrentBuffer;
|
||||
|
||||
#ifdef __GNUC__
|
||||
extern void strupr(char *s);
|
||||
extern void strlwr(char *s);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
34
include/asm/main.h
Normal file
34
include/asm/main.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef ASMOTOR_MAIN_H
|
||||
#define ASMOTOR_MAIN_H
|
||||
|
||||
struct sOptions {
|
||||
ULONG endian;
|
||||
char gbgfx[4];
|
||||
char binary[2];
|
||||
SLONG fillchar; // -1 == random
|
||||
};
|
||||
|
||||
extern char *tzNewMacro;
|
||||
extern ULONG ulNewMacroSize;
|
||||
extern SLONG nGBGfxID;
|
||||
extern SLONG nBinaryID;
|
||||
|
||||
extern struct sOptions DefaultOptions;
|
||||
extern struct sOptions CurrentOptions;
|
||||
extern void opt_Push(void);
|
||||
extern void opt_Pop(void);
|
||||
extern void opt_Parse(char *s);
|
||||
|
||||
void fatalerror(char *s);
|
||||
void yyerror(char *s);
|
||||
|
||||
extern char temptext[1024];
|
||||
|
||||
#define YY_FATAL_ERROR fatalerror
|
||||
|
||||
#ifdef YYLMAX
|
||||
#undef YYLMAX
|
||||
#endif
|
||||
#define YYLMAX 65536
|
||||
|
||||
#endif
|
||||
119
include/asm/mylink.h
Normal file
119
include/asm/mylink.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef ASMOTOR_ASM_LINK_H
|
||||
#define ASMOTOR_ASM_LINK_H
|
||||
|
||||
/* RGB0 .obj format:
|
||||
*
|
||||
* Header
|
||||
* Symbols
|
||||
* Sections
|
||||
*
|
||||
* Header:
|
||||
* "RGB0"
|
||||
* LONG NumberOfSymbols
|
||||
* LONG NumberOfSections
|
||||
*
|
||||
* Symbols:
|
||||
* Symbol[NumberOfSymbols]
|
||||
*
|
||||
* Symbol:
|
||||
* char Name (NULL terminated)
|
||||
* char nType
|
||||
* if( nType!=SYM_IMPORT )
|
||||
* {
|
||||
* LONG SectionID
|
||||
* LONG Offset
|
||||
* }
|
||||
*
|
||||
* Sections:
|
||||
* Section[NumberOfSections]
|
||||
*
|
||||
* Section:
|
||||
* LONG SizeInBytes
|
||||
* char Type
|
||||
* if( Type!=BSS )
|
||||
* {
|
||||
* char Data[SizeInBytes]
|
||||
* Patches
|
||||
* }
|
||||
*
|
||||
* Patches:
|
||||
* LONG NumberOfPatches
|
||||
* Patch[NumberOfPatches]
|
||||
*
|
||||
* Patch:
|
||||
* char Filename NULL-terminated
|
||||
* LONG LineNo
|
||||
* LONG Offset
|
||||
* char Type
|
||||
* LONG RpnByteSize
|
||||
* Rpn[RpnByteSize]
|
||||
*
|
||||
* Rpn:
|
||||
* Operators: 0x00-0x7F
|
||||
* Constants: 0x80 0x00000000
|
||||
* Symbols : 0x81 0x00000000
|
||||
*
|
||||
*/
|
||||
|
||||
enum {
|
||||
RPN_ADD = 0,
|
||||
RPN_SUB,
|
||||
RPN_MUL,
|
||||
RPN_DIV,
|
||||
RPN_MOD,
|
||||
RPN_UNSUB,
|
||||
|
||||
RPN_OR,
|
||||
RPN_AND,
|
||||
RPN_XOR,
|
||||
RPN_UNNOT,
|
||||
|
||||
RPN_LOGAND,
|
||||
RPN_LOGOR,
|
||||
RPN_LOGUNNOT,
|
||||
|
||||
RPN_LOGEQ,
|
||||
RPN_LOGNE,
|
||||
RPN_LOGGT,
|
||||
RPN_LOGLT,
|
||||
RPN_LOGGE,
|
||||
RPN_LOGLE,
|
||||
|
||||
RPN_SHL,
|
||||
RPN_SHR,
|
||||
|
||||
RPN_BANK,
|
||||
|
||||
RPN_HRAM,
|
||||
|
||||
RPN_PCEZP,
|
||||
|
||||
RPN_RANGECHECK,
|
||||
|
||||
RPN_CONST = 0x80,
|
||||
RPN_SYM = 0x81
|
||||
};
|
||||
|
||||
enum {
|
||||
SECT_BSS = 0,
|
||||
SECT_VRAM,
|
||||
SECT_CODE,
|
||||
SECT_HOME,
|
||||
SECT_HRAM
|
||||
};
|
||||
|
||||
enum {
|
||||
SYM_LOCAL = 0,
|
||||
SYM_IMPORT,
|
||||
SYM_EXPORT
|
||||
};
|
||||
|
||||
enum {
|
||||
PATCH_BYTE = 0,
|
||||
PATCH_WORD_L,
|
||||
PATCH_LONG_L,
|
||||
PATCH_WORD_B,
|
||||
PATCH_LONG_B
|
||||
};
|
||||
|
||||
#endif
|
||||
18
include/asm/mymath.h
Normal file
18
include/asm/mymath.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef ASMOTOR_ASM_MATH_H
|
||||
#define ASMOTOR_ASM_MATH_H
|
||||
|
||||
#include "asm/types.h"
|
||||
|
||||
void math_DefinePI(void);
|
||||
void math_Print(SLONG i);
|
||||
SLONG math_Sin(SLONG i);
|
||||
SLONG math_Cos(SLONG i);
|
||||
SLONG math_Tan(SLONG i);
|
||||
SLONG math_ASin(SLONG i);
|
||||
SLONG math_ACos(SLONG i);
|
||||
SLONG math_ATan(SLONG i);
|
||||
SLONG math_ATan2(SLONG i, SLONG j);
|
||||
SLONG math_Mul(SLONG i, SLONG j);
|
||||
SLONG math_Div(SLONG i, SLONG j);
|
||||
|
||||
#endif
|
||||
35
include/asm/output.h
Normal file
35
include/asm/output.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef ASMOTOR_ASM_OUTPUT_H
|
||||
#define ASMOTOR_ASM_OUTPUT_H
|
||||
|
||||
#include "asm/rpn.h"
|
||||
#include "asm/types.h"
|
||||
|
||||
struct Section {
|
||||
char *pzName;
|
||||
UBYTE nType;
|
||||
ULONG nPC;
|
||||
ULONG nOrg;
|
||||
ULONG nBank;
|
||||
struct Section *pNext;
|
||||
struct Patch *pPatches;
|
||||
UBYTE *tData;
|
||||
};
|
||||
|
||||
void out_PrepPass2(void);
|
||||
void out_SetFileName(char *s);
|
||||
void out_NewSection(char *pzName, ULONG secttype);
|
||||
void out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank);
|
||||
void out_AbsByte(int b);
|
||||
void out_RelByte(struct Expression *expr);
|
||||
void out_RelWord(struct Expression *expr);
|
||||
void out_PCRelByte(struct Expression *expr);
|
||||
void out_WriteObject(void);
|
||||
void out_Skip(int skip);
|
||||
void out_BinaryFile(char *s);
|
||||
void out_String(char *s);
|
||||
void out_AbsLong(SLONG b);
|
||||
void out_RelLong(struct Expression *expr);
|
||||
void out_PushSection(void);
|
||||
void out_PopSection(void);
|
||||
|
||||
#endif
|
||||
68
include/asm/rpn.h
Normal file
68
include/asm/rpn.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef ASMOTOR_ASM_RPN_H
|
||||
#define ASMOTOR_ASM_RPN_H
|
||||
|
||||
struct Expression {
|
||||
SLONG nVal;
|
||||
UBYTE tRPN[256];
|
||||
ULONG nRPNLength;
|
||||
ULONG nRPNOut;
|
||||
ULONG isReloc;
|
||||
ULONG isPCRel;
|
||||
};
|
||||
|
||||
ULONG rpn_isReloc(struct Expression *expr);
|
||||
ULONG rpn_isPCRelative(struct Expression *expr);
|
||||
void rpn_Symbol(struct Expression *expr, char *tzSym);
|
||||
void rpn_Number(struct Expression *expr, ULONG i);
|
||||
void rpn_LOGNOT(struct Expression *expr, struct Expression *src1);
|
||||
void rpn_LOGOR(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_LOGAND(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_LOGEQU(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_LOGGT(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_LOGLT(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_LOGGE(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_LOGLE(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_LOGNE(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_ADD(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_SUB(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_XOR(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_OR(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_AND(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_SHL(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_SHR(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_MUL(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_DIV(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_MOD(struct Expression *expr, struct Expression *src1,
|
||||
struct Expression *src2);
|
||||
void rpn_UNNEG(struct Expression *expr, struct Expression *src);
|
||||
void rpn_UNNOT(struct Expression *expr, struct Expression *src);
|
||||
UWORD rpn_PopByte(struct Expression *expr);
|
||||
void rpn_Bank(struct Expression *expr, char *tzSym);
|
||||
void rpn_Reset(struct Expression *expr);
|
||||
int rpn_RangeCheck(struct Expression *expr, struct Expression *src, SLONG low,
|
||||
SLONG high);
|
||||
#ifdef GAMEBOY
|
||||
void rpn_CheckHRAM(struct Expression *expr, struct Expression *src1);
|
||||
#endif
|
||||
#ifdef PCENGINE
|
||||
void rpn_CheckZP(struct Expression *expr, struct Expression *src);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
67
include/asm/symbol.h
Normal file
67
include/asm/symbol.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef ASMOTOR_SYMBOL_H
|
||||
#define ASMOTOR_SYMBOL_H
|
||||
|
||||
#include "asm/types.h"
|
||||
|
||||
#define HASHSIZE 73
|
||||
#define MAXSYMLEN 256
|
||||
|
||||
struct sSymbol {
|
||||
char tzName[MAXSYMLEN + 1];
|
||||
SLONG nValue;
|
||||
ULONG nType;
|
||||
struct sSymbol *pScope;
|
||||
struct sSymbol *pNext;
|
||||
struct Section *pSection;
|
||||
ULONG ulMacroSize;
|
||||
char *pMacro;
|
||||
SLONG(*Callback) (struct sSymbol *);
|
||||
};
|
||||
|
||||
#define SYMF_RELOC 0x001 /* symbol will be reloc'ed during linking, it's absolute value is unknown */
|
||||
#define SYMF_EQU 0x002 /* symbol is defined using EQU, will not be changed during linking */
|
||||
#define SYMF_SET 0x004 /* symbol is (re)defined using SET, will not be changed during linking */
|
||||
#define SYMF_EXPORT 0x008 /* symbol should be exported */
|
||||
#define SYMF_IMPORT 0x010 /* symbol is imported, it's value is unknown */
|
||||
#define SYMF_LOCAL 0x020 /* symbol is a local symbol */
|
||||
#define SYMF_DEFINED 0x040 /* symbol has been defined, not only referenced */
|
||||
#define SYMF_MACRO 0x080 /* symbol is a macro */
|
||||
#define SYMF_STRING 0x100 /* symbol is a stringsymbol */
|
||||
#define SYMF_CONST 0x200 /* symbol has a constant value, will not be changed during linking */
|
||||
|
||||
void sym_PrepPass1(void);
|
||||
void sym_PrepPass2(void);
|
||||
void sym_AddLocalReloc(char *tzSym);
|
||||
void sym_AddReloc(char *tzSym);
|
||||
void sym_Export(char *tzSym);
|
||||
void sym_PrintSymbolTable(void);
|
||||
struct sSymbol *sym_FindMacro(char *s);
|
||||
void sym_InitNewMacroArgs(void);
|
||||
void sym_AddNewMacroArg(char *s);
|
||||
void sym_SaveCurrentMacroArgs(char *save[]);
|
||||
void sym_RestoreCurrentMacroArgs(char *save[]);
|
||||
void sym_UseNewMacroArgs(void);
|
||||
void sym_FreeCurrentMacroArgs(void);
|
||||
void sym_AddEqu(char *tzSym, SLONG value);
|
||||
void sym_AddSet(char *tzSym, SLONG value);
|
||||
void sym_Init(void);
|
||||
ULONG sym_GetConstantValue(char *s);
|
||||
void sym_Import(char *tzSym);
|
||||
ULONG sym_isConstant(char *s);
|
||||
struct sSymbol *sym_FindSymbol(char *tzName);
|
||||
void sym_Global(char *tzSym);
|
||||
char *sym_FindMacroArg(SLONG i);
|
||||
char *sym_GetStringValue(char *tzSym);
|
||||
void sym_UseCurrentMacroArgs(void);
|
||||
void sym_SetMacroArgID(ULONG nMacroCount);
|
||||
ULONG sym_isString(char *tzSym);
|
||||
void sym_AddMacro(char *tzSym);
|
||||
void sym_ShiftCurrentMacroArgs(void);
|
||||
void sym_AddString(char *tzSym, char *tzValue);
|
||||
ULONG sym_GetValue(char *s);
|
||||
ULONG sym_GetDefinedValue(char *s);
|
||||
ULONG sym_isDefined(char *tzName);
|
||||
void sym_Purge(char *tzName);
|
||||
ULONG sym_isConstDefined(char *tzName);
|
||||
|
||||
#endif
|
||||
18
include/asm/types.h
Normal file
18
include/asm/types.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef ASMOTOR_ASM_TYPES_H
|
||||
#define ASMOTOR_ASM_TYPES_H
|
||||
|
||||
#if defined(AMIGA) || defined(__GNUC__)
|
||||
#define _MAX_PATH 512
|
||||
#endif
|
||||
|
||||
typedef unsigned char UBYTE;
|
||||
typedef signed char SBYTE;
|
||||
typedef unsigned short UWORD;
|
||||
typedef signed short SWORD;
|
||||
typedef unsigned long ULONG;
|
||||
typedef signed long SLONG;
|
||||
|
||||
#define ASM_LITTLE_ENDIAN 0
|
||||
#define ASM_BIG_ENDIAN 1
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user