- fragS *f;
- long value;
- /* calculate the current address by running through the previous frags */
- /* and adding our current offset */
- for (value = 0, f = frchain_now->frch_root; f; f = f->fr_next)
- value += f->fr_fix + f->fr_offset;
+ fragS * sym_frag;
+ fragS * f;
+ unsigned long current_position;
+ unsigned long symbol_position;
+ unsigned long value;
+ boolean found_symbol;
+
+ /* Calculate the address of the current instruction
+ and the address of the symbol. Do this by summing
+ the offsets of previous frags until we reach the
+ frag containing the symbol, and the current frag. */
+ sym_frag = symbol_get_frag (myops[opnum].X_add_symbol);
+ found_symbol = false;
+
+ current_position = obstack_next_free (&frchain_now->frch_obstack) - frag_now->fr_literal;
+ symbol_position = S_GET_VALUE (myops[opnum].X_add_symbol);
+
+ for (f = frchain_now->frch_root; f; f = f->fr_next)
+ {
+ current_position += f->fr_fix + f->fr_offset;
+
+ if (f == sym_frag)
+ found_symbol = true;
+
+ if (! found_symbol)
+ symbol_position += f->fr_fix + f->fr_offset;
+ }