⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asm.c

📁 window下的c编译器。
💻 C
📖 第 1 页 / 共 5 页
字号:
1064	.COMMon length (%d.) <0!
1065	not used
1066	Missing operand value
1067	Expression too complex:
1068	Relocation error.
1069	Division by 0
2070	Partial line at end of file ignored
1071	Length of .comm \"%s\" is already %d
1072	Expected comma after name
1073	BSS length (%d.) <0! Ignored.
1074	Ignoring attempt to re-define symbol
1075	Expected comma after name
1076	Repeat < 0,in .space
2077	Rest of line ignored.
1078	need a comma after symbol's name
1079	want a comma after the n_type expression
1080	want a comma after the n_other expression
1081	I want a comma after the n_desc expression
1082	Missing expression
1083	%s number illegal
1084	No expression
1085	expression too complex
1086	Unknown expression
1087	Substracting expression too complicated
1088	number illegal
1089	missing expression
1090	Value x%x truncated to x%x
1091	Expected "-ed string
1092	Bad escaped character in string
1093	Expected address expression: absolute 0 assumed
1094	Symbols are undefined
1095	Symbol is undefined
1096	Bad Absolute Expression
2097	This string may not contain zeros
1098	Missing string
1099	Illegal segment %d.
1100	Negative of non-absolute symbol
1101	Can't emit reloc
1102	Fixup of %d too large for field width
1103	Bad case in cleanup_expression
1104	Bad case in function expr
1105	Bad case in function stab
1106	not used
1107	Bad case in cons
1108	Bad case in md_convert_frag
1109	Bad case in WriteCoffFile
1110	Bad case in relax_segment
1111	Bad case in relax_segment
1112	Bad case in fixup_segment
1113    Null pointer in symbol->FnInfo field
1114    input and output file names are the same
1115    error in adding up symbol types info
1116    Relocation to another special section needed
*/
#undef __
#define __ (42)         /* blatently illegal digit value */
						/* exceeds any normal radix */
static const char hex_value[256] = {    /* for fast ASCII -> binary */
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, __, __, __, __, __, __,
	__, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
	__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __
};
static char *xmalloc(long n)
{
	char *retval;
	if (!(retval = malloc((unsigned) n))) {
		error(StrTab[392]);// <virtual memory exceeded>
		exit(1);
	}
	memset(retval, 0, n);
	return (retval);
}
/* Append a string onto another string */
static void StringAppend(char **charPP, char *fromP, unsigned long length)
{
	if (length) {       /* Don't trust bcopy() of 0 chars. */
		memcpy(*charPP, fromP, (int) length);
		*charPP += length;
	}
}
static const int        /* in: segT   out: N_TYPE bits */
seg_N_TYPE[] = {
	N_ABS,
	N_TEXT,
	N_DATA,
	N_BSS,
	N_UNDF,
	N_UNDF,
	N_UNDF,
	N_UNDF,
	N_UNDF,
	N_UNDF
};
static const segT N_TYPE_seg[N_TYPE + 2] =  /* N_TYPE == 0x1E = 32-2 */
{
	SEG_UNKNOWN,        /* N_UNDF == 0 */
	SEG_GOOF,
	SEG_ABSOLUTE,       /* N_ABS == 2 */
	SEG_GOOF,
	SEG_TEXT,           /* N_TEXT == 4 */
	SEG_GOOF,
	SEG_DATA,           /* N_DATA == 6 */
	SEG_GOOF,
	SEG_BSS,            /* N_BSS == 8 */
	SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
	SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
	SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF
};
static void subsegs_begin(void)
{
	/* Check table(s) seg_name[], seg_N_TYPE[] is in correct order */
	know(SEG_ABSOLUTE == 0);
	know(SEG_TEXT == 1);
	know(SEG_DATA == 2);
	know(SEG_BSS == 3);
	know(SEG_UNKNOWN == 4);
	know(SEG_NONE == 5);
	know(SEG_PASS1 == 6);
	know(SEG_GOOF == 7);
	know(SEG_BIG == 8);
	know(SEG_DIFFERENCE == 9);
	know(SEG_MAXIMUM_ORDINAL == SEG_DIFFERENCE);
	obstack_begin(&frags, 50000);
	frchain_root = NULL;
	frchain_now = NULL; /* Warn new_subseg() that we are booting. */
	/* Fake up 1st frag. */
	/* It won't be used=> is ok if obstack... */
	/* pads the end of it for alignment. */
	frag_now = (fragS *) obstack_alloc(&frags, SIZEOF_STRUCT_FRAG);
	/* obstack_1blank( &frags, SIZEOF_STRUCT_FRAG, & frag_now ); */
	/* This 1st frag will not be in any frchain. */
	/* We simply give subseg_new somewhere to scribble. */
	now_subseg = 42;    /* Lie for 1st call to subseg_new. */
	subseg_new(SEG_DATA, 0);    /* .data 0 */
	data0_frchainP = frchain_now;
	IsSpecialSection = 0;
	NumberOfSpecialSections = 0;
	if (glevel > 1)
		NumberOfDebugSections = 2;
	else
		NumberOfDebugSections = 0;
}
/* subseg_change()
 * Change the subsegment we are in, BUT DO NOT MAKE A NEW FRAG for the
 * subsegment. If we are already in the correct subsegment, change nothing.
 * This is used eg as a worker for subseg_new [which does make a new frag_now]
 * and for changing segments after we have read the source. We construct eg
 * fixSs even after the source file is read, so we do have to keep the
 * segment context correct.
 */
static void subseg_change(register segT seg, register int subseg)
{
	now_seg = seg;
	now_subseg = subseg;
	if (seg == SEG_DATA) {
		seg_fix_rootP = &data_fix_root;
	}
	else {
		know(seg == SEG_TEXT);
		seg_fix_rootP = &text_fix_root;
	}
}
/* subseg_new()
 * If you attempt to change to the current subsegment, nothing happens.
 * In:  segT, subsegT code for new subsegment.
 *  frag_now -> incomplete frag for current subsegment.
 *  If frag_now==NULL, then there is no old, incomplete frag, so
 *  the old frag is not closed off.
 * Out: now_subseg, now_seg updated.
 *  Frchain_now points to the (possibly new) struct frchain for this
 *  sub-segment.
 *  Frchain_root updated if needed.
 */
static void subseg_new(register segT seg,register subsegT subseg) /* begin assembly for a new sub-segment */
{
	long tmp;           /* JF for obstack alignment hacking */
	know(seg == SEG_DATA || seg == SEG_TEXT);
	if (seg != now_seg || subseg != now_subseg) {   /* we just changed
						sub-segments */
		register frchainS *frcP;    /* crawl frchain chain */
		register frchainS **lastPP; /* address of last pointer */
		frchainS *newP; /* address of new frchain */
		register fragS *former_last_fragP;
		register fragS *new_fragP;
		if (frag_now) { /* If not bootstrapping. */
			frag_now->fr_fix = obstack_next_free(&frags) - frag_now->fr_literal;
			frag_wane(frag_now);    /* Close off any frag in old subseg. */
		}
		/* It would be nice to keep an obstack for each subsegment, if we
		swap subsegments a lot. Hence we would have much fewer
		frag_wanes(). */
		obstack_finish(&frags);
		/* If we don't do the above, the next object we put on obstack frags
		will appear to start at the fr_literal of the current frag. Also,
		above ensures that the next object will begin on a address that is
		aligned correctly for the engine that runs this program. */
		subseg_change(seg, (int) subseg);
		/* Attempt to find or make a frchain for that sub seg. Crawl along
		chain of frchainSs, begins @ frchain_root. If we need to make a
		frchainS, link it into correct position of chain rooted in
		frchain_root. */
		lastPP = &frchain_root;
		frcP = *(lastPP);
		for (; frcP && (int) (frcP->frch_seg) <= (int) seg; frcP = *(lastPP = &frcP->frch_next)) {
			if ((int) (frcP->frch_seg) == (int) seg && frcP->frch_subseg >= subseg) {
				break;
			}
		}
		/* frcP:      Address of the 1st frchainS in correct segment with
		frch_subseg >= subseg. We want to either use this frchainS, or we
		want to insert a new frchainS just before it.

		If frcP==NULL, then we are at the end of the chain of frchainS-s. A
		NULL frcP means we fell off the end of the chain looking for a
		frch_subseg >= subseg, so we must make a new frchainS.

		If we ever maintain a pointer to the last frchainS in the chain, we
		change that pointer ONLY when frcP==NULL.

		lastPP:    Address of the pointer with value frcP; Never NULL. May
		point to frchain_root.

		*/
		if (!frcP
				|| ((int) (frcP->frch_seg) > (int) seg
					|| frcP->frch_subseg > subseg)) {   /* Kinky logic only
						works with 2 segments. */
			/* This should be the only code that creates a frchainS. */
			newP = (frchainS *) obstack_alloc(&frags, sizeof(frchainS));
			/* obstack_1blank( &frags, sizeof(frchainS), &newP);This begines on a
			good boundary because a obstack_done() preceeded  it.
			It implies an obstack_done(), so we expect the next object allocated
			to begin on a correct boundary. */
			*lastPP = newP;
			newP->frch_next = frcP; /* perhaps NULL */
			(frcP = newP)->frch_subseg = subseg;
			newP->frch_seg = seg;
			newP->frch_last = NULL;
		}
		/* Here with frcP ->ing to the frchainS for subseg. */
		frchain_now = frcP;
		/* Make a fresh frag for the subsegment. We expect this to happen on a
		correct boundary since it was proceeded by a obstack_done(). */
		tmp = obstack_alignment_mask(&frags);
		obstack_alignment_mask(&frags) = 0;
		frag_now = (fragS *) obstack_alloc(&frags, SIZEOF_STRUCT_FRAG);
		obstack_alignment_mask(&frags) = tmp;
		/* But we want any more chars to come immediately after the structure we
		just made. */
		new_fragP = frag_now;
		new_fragP->fr_next = NULL;
		/* Append new frag to current frchain. */
		former_last_fragP = frcP->frch_last;
		if (former_last_fragP) {
			know(former_last_fragP->fr_next == NULL);
			know(frchain_now->frch_root);
			former_last_fragP->fr_next = new_fragP;
		}
		else {
			frcP->frch_root = new_fragP;
		}
		frcP->frch_last = new_fragP;
	}                   /* if (changing subsegments) */
}                       /* subseg_new() */

/* symbol_new()
 * Return a pointer to a new symbol. Die if we can't make a new symbol.
 * Fill in the symbol's values. Add symbol to end of symbol chain.
 */
static symbolS *symbol_new(
	char *name,         /* We copy this: OK to alter your copy. */
	unsigned char type, /* One of the types defined in the table seg_N_TYPE */
	valueT value,       /* As in <a.out.h>, often an address. */
						/* Often used as offset from frag address. */
	struct frag *frag)  /* For sy_frag. */
{
	register symbolS *symbolP;
	register char *preserved_copy_of_name;
	register unsigned int name_length;
	char *p;
	name_length = strlen(name) + 1;
	obstack_grow(&notes, name, name_length);
	p = obstack_finish(&notes);
	preserved_copy_of_name = p;
	p = obstack_alloc(&notes, sizeof(symbolS));
	symbolP = (symbolS *) p;
	symbolP->Name = preserved_copy_of_name;
	symbolP->sy_type = type;
	symbolP->SymbolValue = value;
	symbolP->sy_frag = frag;
	symbolP->Next = NULL;    /* End of chain. */
	symbolP->sy_forward = NULL;
	SetFlags(symbolP);
	/* Link to end of symbol chain. */
	if (symbol_lastP) {
		symbol_lastP->Next = symbolP;
	}
	else {
		symbol_rootP = symbolP;
	}
	symbol_lastP = symbolP;
	return (symbolP);
}
/* colon()
 * We have just seen "<name>:". Creates a struct symbol unless it already exists.
 * Gripes if we are redefining a symbol incompatibly (and ignores it).
 */
static void colon(register char *sym_name)
{                       /* just seen "x:" - rattle symbols & frags */
	/* symbol name, as a cannonical string  We copy this string: OK to alter
	later. */
	register symbolS *symbolP;    /* symbol we are working with */

	if ((symbolP = symbol_table_lookup(sym_name)) != NULL) {
		/* Now check for undefined symbols */
		if ((symbolP->sy_type & N_TYPE) == N_UNDF) {
			if (symbolP->SymbolValue == 0) {
				symbolP->sy_frag = frag_now;
				symbolP->SymbolValue = obstack_next_free(&frags) - frag_now->fr_literal;
				know(N_UNDF == 0);
				symbolP->sy_type |= seg_N_TYPE[(int) now_seg];  /* keep N_EXT bit */

				if (symbolP->StorageClass == 0) {
					if (now_seg == SEG_TEXT)
						symbolP->StorageClass = 6;    /* Code label within a module */
					else
						symbolP->StorageClass = 3;

				}
				SetFlags(symbolP);
				if (symbolP->Flags & IS_TEXT) {
					symbolP->SectionNumber = SECTION_TEXT;
				}
				else if (symbolP->Flags & IS_DATA) {
					symbolP->SectionNumber = SECTION_DATA;
				}
			}
			else {
				InternalError(1000);
			}
		}
		else {
			error("asm: label %s: redefined\n",sym_name);
		}
	}
	else {
		symbolP = symbol_new(sym_name,
							(unsigned char) (seg_N_TYPE[(int) now_seg]),
				(valueT) (obstack_next_free(&frags) - frag_now->fr_literal),
							frag_now);
		symbol_table_insert(symbolP);
		if (symbolP->StorageClass == 0) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -