- number_to_chars_bigendian (buf, val, n);
-}
-
-void
-md_number_to_imm (buf, val, n, fixP)
- char *buf;
- long val;
- int n;
- fixS *fixP;
-{
- enum reloc_type reloc = fixP->fx_r_type & 0xf;
- enum highlow_type highlow = (fixP->fx_r_type >> 4) & 0x3;
-
- assert (buf);
- assert (n == 4); /* always on i860 */
-
- switch (highlow)
- {
-
- case HIGHADJ: /* adjusts the high-order 16-bits */
- if (val & (1 << 15))
- val += (1 << 16);
-
- /*FALLTHROUGH*/
-
- case HIGH: /* selects the high-order 16-bits */
- val >>= 16;
- break;
-
- case PAIR: /* selects the low-order 16-bits */
- val = val & 0xffff;
- break;
-
- default:
- break;
- }
-
- switch (reloc)
- {
-
- case BRADDR: /* br,call,bc,bc.t,bnc,bnc.t w/26-bit immediate */
- if (fixP->fx_pcrel != 1)
- as_bad (_("26-bit branch w/o pc relative set: 0x%08x"), val);
- val >>= 2; /* align pcrel offset, see manual */
-
- if (val >= (1 << 25) || val < -(1 << 25)) /* check for overflow */
- as_bad (_("26-bit branch offset overflow: 0x%08x"), val);
- buf[0] = (buf[0] & 0xfc) | ((val >> 24) & 0x3);
- buf[1] = val >> 16;
- buf[2] = val >> 8;
- buf[3] = val;
- break;
-
- case SPLIT2: /* 16 bit immediate, 4-byte aligned */
- if (val & 0x3)
- as_bad (_("16-bit immediate 4-byte alignment error: 0x%08x"), val);
- val &= ~0x3; /* 4-byte align value */
- /*FALLTHROUGH*/
- case SPLIT1: /* 16 bit immediate, 2-byte aligned */
- if (val & 0x1)
- as_bad (_("16-bit immediate 2-byte alignment error: 0x%08x"), val);
- val &= ~0x1; /* 2-byte align value */
- /*FALLTHROUGH*/
- case SPLIT0: /* st,bla,bte,btne w/16-bit immediate */
- if (fixP->fx_pcrel == 1)
- val >>= 2; /* align pcrel offset, see manual */
- /* check for bounds */
- if (highlow != PAIR && (val >= (1 << 16) || val < -(1 << 15)))
- as_bad (_("16-bit branch offset overflow: 0x%08x"), val);
- buf[1] = (buf[1] & ~0x1f) | ((val >> 11) & 0x1f);
- buf[2] = (buf[2] & ~0x7) | ((val >> 8) & 0x7);
- buf[3] |= val; /* perserve bottom opcode bits */
- break;
-
- case LOW4: /* fld,pfld,pst,flush 16-byte aligned */
- if (val & 0xf)
- as_bad (_("16-bit immediate 16-byte alignment error: 0x%08x"), val);
- val &= ~0xf; /* 16-byte align value */
- /*FALLTHROUGH*/
- case LOW3: /* fld,pfld,pst,flush 8-byte aligned */
- if (val & 0x7)
- as_bad (_("16-bit immediate 8-byte alignment error: 0x%08x"), val);
- val &= ~0x7; /* 8-byte align value */
- /*FALLTHROUGH*/
- case LOW2: /* 16 bit immediate, 4-byte aligned */
- if (val & 0x3)
- as_bad (_("16-bit immediate 4-byte alignment error: 0x%08x"), val);
- val &= ~0x3; /* 4-byte align value */
- /*FALLTHROUGH*/
- case LOW1: /* 16 bit immediate, 2-byte aligned */
- if (val & 0x1)
- as_bad (_("16-bit immediate 2-byte alignment error: 0x%08x"), val);
- val &= ~0x1; /* 2-byte align value */
- /*FALLTHROUGH*/
- case LOW0: /* 16 bit immediate, byte aligned */
- /* check for bounds */
- if (highlow != PAIR && (val >= (1 << 16) || val < -(1 << 15)))
- as_bad (_("16-bit immediate overflow: 0x%08x"), val);
- buf[2] = val >> 8;
- buf[3] |= val; /* perserve bottom opcode bits */
- break;
-
- case NO_RELOC:
- default:
- as_bad (_("bad relocation type: 0x%02x"), reloc);
- break;
- }