%{
#include "comm0.h"
#include "comm1.h"
+
+static item_t *last_it, *o_it;
%}
/* ========== Machine independent Yacc definitions ========== */
%token COMMON
%token BASE
%token SYMB
+%token SYMD
%token ALIGN
%token ASSERT
%token SPACE
{ if ($2.val == 0 && pass == PASS_3)
warning("assertion failed");
}
- | SYMB STRING ',' expr optabs2 optabs2
+ | SYMB STRING ',' expr { o_it = last_it; }
+ optabs2 optabs2
{ if ((sflag & SYM_SMB) && PASS_SYMB) {
#ifndef ASLD
if (
serror("expression undefined");
relonami = -1;
}
+ if (
+ PASS_SYMB
+ &&
+ ($4.typ & S_COM)
+ ) {
+ /* No value is known at
+ assembler time.
+ Generate reference to other
+ entry in name table
+ */
+ $4.typ = S_CRS;
+ $4.val = new_string(o_it->i_name);
+ relonami = 0;
+ }
#endif
+
newsymb(
- stringbuf+1,
+ *(stringbuf+1) ? stringbuf+1 : (char *) 0,
(short)(
($4.typ & (S_EXT|S_TYP))
|
- ((ushort)$5<<8)
+ ((ushort)$6<<8)
),
- (short)$6,
+ (short)$7,
$4.val
);
}
}
+ | SYMD STRING ',' absexp ',' absexp
+ { if ((sflag & SYM_SMB) && PASS_SYMB) {
+ newsymb(
+ *(stringbuf+1) ? stringbuf+1 : (char *) 0,
+ (short)(
+ (DOTTYP & (S_EXT|S_TYP))
+ |
+ ((ushort)$4<<8)
+ ),
+ (short)$6,
+ (valu_t)DOTVAL
+ );
+ }
+ }
| LINE optabs1
{ if ((sflag & SYM_LIN) && PASS_SYMB) {
if ($2)
{ $$.val = $1; $$.typ = S_ABS;}
| id_fb
{ $$.val = load($1);
+ last_it = $1;
$$.typ = $1->i_type & ~S_EXT;
}
| STRING
}
#endif
+long
+new_string(s)
+ char *s;
+{
+ long r = 0;
+
+ if (s) {
+ long len = strlen(s) + 1;
+
+ r = outhead.oh_nchar;
+ if (pass == PASS_3) wr_string(s, len);
+ outhead.oh_nchar += len;
+ }
+ return r;
+}
+
newsymb(name, type, desc, valu)
register char *name;
short type;
name = 0;
assert(PASS_SYMB);
if (pass != PASS_3) {
- if (name)
- outhead.oh_nchar += strlen(name)+1;
+ new_string(name);
outhead.oh_nname++;
return;
}
nname++;
- if (name) {
- long len = strlen(name) + 1;
-
- wr_string(name, len);
- outname.on_foff = outhead.oh_nchar;
- outhead.oh_nchar += len;
- } else
- outname.on_foff = 0;
+ outname.on_foff = new_string(name);
outname.on_type = type;
outname.on_desc = desc;
outname.on_valu = valu & ~(((0xFFFFFFFF)<<(4*sizeof(valu_t)))<<(4*sizeof(valu_t)));