Пример #1
0
/*
 * Get a string equate's value
 */
char *
sym_GetStringValue(char *tzSym)
{
	struct sSymbol *pSym;

	if ((pSym = sym_FindSymbol(tzSym)) != NULL)
		return (pSym->pMacro);
	else {
		yyerror("Stringsymbol '%s' not defined", tzSym);
	}

	return (NULL);
}
Пример #2
0
void fstk_RunString(char *s)
{
	struct sSymbol *pSym;

	if ((pSym = sym_FindSymbol(s)) != NULL) {
		pushcontext();
		nCurrentStatus = STAT_isMacroArg;
		strcpy(tzCurrentFileName, s);
		CurrentFlexHandle =
		    yy_scan_bytes(pSym->pMacro, strlen(pSym->pMacro));
		yy_switch_to_buffer(CurrentFlexHandle);
	} else
		yyerror("No such string symbol");
}
Пример #3
0
void rpn_Symbol(struct Expression *expr, char *tzSym)
{
	if (!sym_isConstant(tzSym)) {
		struct sSymbol *psym;

		rpn_Reset(expr);

		psym = sym_FindSymbol(tzSym);

		if (psym == NULL || psym->pSection == pCurrentSection
		    || psym->pSection == NULL)
			expr->isPCRel = 1;
		expr->isReloc = 1;
		pushbyte(expr, RPN_SYM);
		while (*tzSym)
			pushbyte(expr, *tzSym++);
		pushbyte(expr, 0);
	} else
		rpn_Number(expr, sym_GetConstantValue(tzSym));
}
Пример #4
0
void rpn_Bank(struct Expression *expr, char *tzSym)
{
	if (!sym_isConstant(tzSym)) {
		struct sSymbol *psym;

		rpn_Reset(expr);

		psym = sym_FindSymbol(tzSym);
		if (nPass == 2 && psym == NULL) {
			sprintf(temptext, "'%s' not defined", tzSym);
			yyerror(temptext);
		}
		expr->isReloc = 1;
		pushbyte(expr, RPN_BANK);
		while (*tzSym)
			pushbyte(expr, *tzSym++);
		pushbyte(expr, 0);
	} else
		yyerror("BANK argument must be a relocatable identifier");
}
Пример #5
0
/*
 * Create a new patch (includes the rpn expr)
 */
void 
createpatch(ULONG type, struct Expression * expr)
{
	struct Patch *pPatch;
	UWORD rpndata;
	UBYTE rpnexpr[2048];
	char tzSym[512];
	ULONG rpnptr = 0, symptr;

	pPatch = allocpatch();
	pPatch->nType = type;
	strcpy(pPatch->tzFilename, tzCurrentFileName);
	pPatch->nLine = nLineNo;
	pPatch->nOffset = nPC;

	while ((rpndata = rpn_PopByte(expr)) != 0xDEAD) {
		switch (rpndata) {
		case RPN_CONST:
			rpnexpr[rpnptr++] = RPN_CONST;
			rpnexpr[rpnptr++] = rpn_PopByte(expr);
			rpnexpr[rpnptr++] = rpn_PopByte(expr);
			rpnexpr[rpnptr++] = rpn_PopByte(expr);
			rpnexpr[rpnptr++] = rpn_PopByte(expr);
			break;
		case RPN_SYM:
			symptr = 0;
			while ((tzSym[symptr++] = rpn_PopByte(expr)) != 0);
			if (sym_isConstant(tzSym)) {
				ULONG value;

				value = sym_GetConstantValue(tzSym);
				rpnexpr[rpnptr++] = RPN_CONST;
				rpnexpr[rpnptr++] = value & 0xFF;
				rpnexpr[rpnptr++] = value >> 8;
				rpnexpr[rpnptr++] = value >> 16;
				rpnexpr[rpnptr++] = value >> 24;
			} else {
				struct sSymbol *sym;
				if ((sym = sym_FindSymbol(tzSym)) == NULL)
					break;
				symptr = addsymbol(sym);
				rpnexpr[rpnptr++] = RPN_SYM;
				rpnexpr[rpnptr++] = symptr & 0xFF;
				rpnexpr[rpnptr++] = symptr >> 8;
				rpnexpr[rpnptr++] = symptr >> 16;
				rpnexpr[rpnptr++] = symptr >> 24;
			}
			break;
		case RPN_BANK: {
			struct sSymbol *sym;
			symptr = 0;
			while ((tzSym[symptr++] = rpn_PopByte(expr)) != 0);
			if ((sym = sym_FindSymbol(tzSym)) == NULL)
				break;
			symptr = addsymbol(sym);
			rpnexpr[rpnptr++] = RPN_BANK;
			rpnexpr[rpnptr++] = symptr & 0xFF;
			rpnexpr[rpnptr++] = symptr >> 8;
			rpnexpr[rpnptr++] = symptr >> 16;
			rpnexpr[rpnptr++] = symptr >> 24;
			}
			break;
		default:
			rpnexpr[rpnptr++] = rpndata;
			break;
		}
	}