Added pseudo function .DEFINEDINSTR
This commit is contained in:
@@ -62,6 +62,7 @@
|
|||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "toklist.h"
|
#include "toklist.h"
|
||||||
#include "ulabel.h"
|
#include "ulabel.h"
|
||||||
|
#include "macro.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -417,6 +418,33 @@ static ExprNode* FuncDefined (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static ExprNode* FuncDefinedInstr (void)
|
||||||
|
/* Handle the .DEFINEDINSTR builtin function */
|
||||||
|
{
|
||||||
|
int Instr = 0;
|
||||||
|
|
||||||
|
/* Check for a macro or an instruction depending on UbiquitousIdents */
|
||||||
|
|
||||||
|
if (CurTok.Tok == TOK_IDENT) {
|
||||||
|
if (UbiquitousIdents) {
|
||||||
|
/* Macros CAN be instructions, so check for them first */
|
||||||
|
if (FindMacro(&CurTok.SVal) == 0) {
|
||||||
|
Instr = FindInstruction (&CurTok.SVal);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Macros and symbols may NOT use the names of instructions, so just check for the instruction */
|
||||||
|
Instr = FindInstruction(&CurTok.SVal);
|
||||||
|
}
|
||||||
|
NextTok();
|
||||||
|
} else {
|
||||||
|
Error("Idenitifier expected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return GenLiteralExpr(Instr > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExprNode* FuncHiByte (void)
|
ExprNode* FuncHiByte (void)
|
||||||
/* Handle the .HIBYTE builtin function */
|
/* Handle the .HIBYTE builtin function */
|
||||||
{
|
{
|
||||||
@@ -1065,6 +1093,10 @@ static ExprNode* Factor (void)
|
|||||||
N = Function (FuncDefined);
|
N = Function (FuncDefined);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TOK_DEFINEDINSTR:
|
||||||
|
N = Function (FuncDefinedInstr);
|
||||||
|
break;
|
||||||
|
|
||||||
case TOK_HIBYTE:
|
case TOK_HIBYTE:
|
||||||
N = Function (FuncHiByte);
|
N = Function (FuncHiByte);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ static const char* FeatureKeys[FEAT_COUNT] = {
|
|||||||
"force_range",
|
"force_range",
|
||||||
"underline_in_numbers",
|
"underline_in_numbers",
|
||||||
"addrsize",
|
"addrsize",
|
||||||
|
"definedinstr",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -121,6 +122,7 @@ feature_t SetFeature (const StrBuf* Key)
|
|||||||
case FEAT_FORCE_RANGE: ForceRange = 1; break;
|
case FEAT_FORCE_RANGE: ForceRange = 1; break;
|
||||||
case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= 1; break;
|
case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= 1; break;
|
||||||
case FEAT_ADDRSIZE: AddrSize = 1; break;
|
case FEAT_ADDRSIZE: AddrSize = 1; break;
|
||||||
|
case FEAT_DEFINEDINSTR: DefinedInstr = 1; break;
|
||||||
default: /* Keep gcc silent */ break;
|
default: /* Keep gcc silent */ break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ typedef enum {
|
|||||||
FEAT_FORCE_RANGE,
|
FEAT_FORCE_RANGE,
|
||||||
FEAT_UNDERLINE_IN_NUMBERS,
|
FEAT_UNDERLINE_IN_NUMBERS,
|
||||||
FEAT_ADDRSIZE,
|
FEAT_ADDRSIZE,
|
||||||
|
FEAT_DEFINEDINSTR,
|
||||||
|
|
||||||
/* Special value: Number of features available */
|
/* Special value: Number of features available */
|
||||||
FEAT_COUNT
|
FEAT_COUNT
|
||||||
|
|||||||
@@ -83,3 +83,4 @@ unsigned char CComments = 0; /* Allow C like comments */
|
|||||||
unsigned char ForceRange = 0; /* Force values into expected range */
|
unsigned char ForceRange = 0; /* Force values into expected range */
|
||||||
unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */
|
unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */
|
||||||
unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */
|
unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */
|
||||||
|
unsigned char DefinedInstr = 0; /* Allow .DEFINEDINSTR function */
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ extern unsigned char CComments; /* Allow C like comments */
|
|||||||
extern unsigned char ForceRange; /* Force values into expected range */
|
extern unsigned char ForceRange; /* Force values into expected range */
|
||||||
extern unsigned char UnderlineInNumbers; /* Allow underlines in numbers */
|
extern unsigned char UnderlineInNumbers; /* Allow underlines in numbers */
|
||||||
extern unsigned char AddrSize; /* Allow .ADDRSIZE function */
|
extern unsigned char AddrSize; /* Allow .ADDRSIZE function */
|
||||||
|
extern unsigned char DefinedInstr; /* Allow .DEFINEDINSTR function */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1989,6 +1989,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
|||||||
{ ccNone, DoDebugInfo },
|
{ ccNone, DoDebugInfo },
|
||||||
{ ccNone, DoDefine },
|
{ ccNone, DoDefine },
|
||||||
{ ccNone, DoUnexpected }, /* .DEFINED */
|
{ ccNone, DoUnexpected }, /* .DEFINED */
|
||||||
|
{ ccNone, DoUnexpected }, /* .DEFINEDINSTR */
|
||||||
{ ccNone, DoDelMac },
|
{ ccNone, DoDelMac },
|
||||||
{ ccNone, DoDestructor },
|
{ ccNone, DoDestructor },
|
||||||
{ ccNone, DoDWord },
|
{ ccNone, DoDWord },
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ struct DotKeyword {
|
|||||||
{ ".DEF", TOK_DEFINED },
|
{ ".DEF", TOK_DEFINED },
|
||||||
{ ".DEFINE", TOK_DEFINE },
|
{ ".DEFINE", TOK_DEFINE },
|
||||||
{ ".DEFINED", TOK_DEFINED },
|
{ ".DEFINED", TOK_DEFINED },
|
||||||
|
{ ".DEFINEDINSTR", TOK_DEFINEDINSTR },
|
||||||
{ ".DELMAC", TOK_DELMAC },
|
{ ".DELMAC", TOK_DELMAC },
|
||||||
{ ".DELMACRO", TOK_DELMAC },
|
{ ".DELMACRO", TOK_DELMAC },
|
||||||
{ ".DESTRUCTOR", TOK_DESTRUCTOR },
|
{ ".DESTRUCTOR", TOK_DESTRUCTOR },
|
||||||
@@ -736,6 +737,13 @@ static token_t FindDotKeyword (void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TOK_DEFINEDINSTR:
|
||||||
|
/* Disallow .DEFINEDINSTR function by default */
|
||||||
|
if (DefinedInstr == 0) {
|
||||||
|
return TOK_NONE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ typedef enum token_t {
|
|||||||
TOK_DEBUGINFO,
|
TOK_DEBUGINFO,
|
||||||
TOK_DEFINE,
|
TOK_DEFINE,
|
||||||
TOK_DEFINED,
|
TOK_DEFINED,
|
||||||
|
TOK_DEFINEDINSTR,
|
||||||
TOK_DELMAC,
|
TOK_DELMAC,
|
||||||
TOK_DESTRUCTOR,
|
TOK_DESTRUCTOR,
|
||||||
TOK_DWORD,
|
TOK_DWORD,
|
||||||
|
|||||||
Reference in New Issue
Block a user