2017-01-15 10:51:37 +00:00
|
|
|
|
2017-01-30 21:39:23 +00:00
|
|
|
word_t emit_hi(struct expr_t* expr, int is_signed)
|
2017-01-15 10:51:37 +00:00
|
|
|
{
|
|
|
|
/* If this is a symbol reference, discard the symbol and keep only the
|
|
|
|
* offset part. */
|
2017-01-30 21:15:02 +00:00
|
|
|
word_t type = expr->typ & S_TYP;
|
|
|
|
word_t val = expr->val;
|
2017-01-15 10:51:37 +00:00
|
|
|
uint16_t hi = val >> 16;
|
|
|
|
uint16_t lo = val & 0xffff;
|
|
|
|
|
|
|
|
if (type != S_ABS)
|
|
|
|
newrelo(expr->typ, RELOPPC | FIXUPFLAGS);
|
|
|
|
|
|
|
|
/* If the low half of this relocation is going to be a memory operation,
|
|
|
|
* then it'll be treated as a signed value. That means that values greater
|
|
|
|
* than 0x7fff will cause the high word to have 1 subtracted from it; so
|
|
|
|
* we apply an adjustment here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (is_signed && (lo > 0x7fff))
|
|
|
|
hi++;
|
|
|
|
|
|
|
|
return hi;
|
|
|
|
}
|
|
|
|
|
2017-01-30 21:15:02 +00:00
|
|
|
word_t emit_lo(struct expr_t* expr)
|
2017-01-15 10:51:37 +00:00
|
|
|
{
|
2017-01-30 21:15:02 +00:00
|
|
|
word_t type = expr->typ & S_TYP;
|
|
|
|
word_t val = expr->val;
|
2017-01-15 10:51:37 +00:00
|
|
|
|
|
|
|
/* If the assembler stored a symbol for relocation later, we need to
|
|
|
|
* abandon it (because the relocation was generated by emit_ha). */
|
|
|
|
|
|
|
|
if (type != S_ABS)
|
|
|
|
relonami = 0;
|
|
|
|
|
|
|
|
return val & 0xffff;
|
|
|
|
}
|