static void get_common_setup(Init_Entry *vals, int i) { /* set up flt */ BitVector_Block_Store(flt->mantissa, vals[i].mantissa, MANT_BYTES); flt->sign = vals[i].sign; flt->exponent = vals[i].exponent; flt->flags = vals[i].flags; /* set failure messages */ strcpy(ret_msg, vals[i].ascii); strcat(ret_msg, ": incorrect return value"); strcpy(result_msg, vals[i].ascii); strcat(result_msg, ": incorrect result generated"); }
static void POT_Table_Init_Entry(/*@out@*/ POT_Entry *e, POT_Entry_Source *s, int dec_exp) { /* Save decimal exponent */ e->dec_exponent = dec_exp; /* Initialize mantissa */ e->f.mantissa = BitVector_Create(MANT_BITS, FALSE); BitVector_Block_Store(e->f.mantissa, s->mantissa, MANT_BYTES); /* Initialize exponent */ e->f.exponent = s->exponent; /* Set sign to 0 (positive) */ e->f.sign = 0; /* Clear flags */ e->f.flags = 0; }
void yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, size_t destsize, size_t valsize, int shift, int bigendian, int warn) { wordptr op1 = op1static, op2; unsigned char *buf; unsigned int len; size_t rshift = shift < 0 ? (size_t)(-shift) : 0; int carry_in; /* Currently don't support destinations larger than our native size */ if (destsize*8 > BITVECT_NATIVE_SIZE) yasm_internal_error(N_("destination too large")); /* General size warnings */ if (warn<0 && !yasm_intnum_check_size(intn, valsize, rshift, 1)) yasm_warn_set(YASM_WARN_GENERAL, N_("value does not fit in signed %d bit field"), valsize); if (warn>0 && !yasm_intnum_check_size(intn, valsize, rshift, 2)) yasm_warn_set(YASM_WARN_GENERAL, N_("value does not fit in %d bit field"), valsize); /* Read the original data into a bitvect */ if (bigendian) { /* TODO */ yasm_internal_error(N_("big endian not implemented")); } else BitVector_Block_Store(op1, ptr, (N_int)destsize); /* If not already a bitvect, convert value to be written to a bitvect */ op2 = intnum_tobv(op2static, intn); /* Check low bits if right shifting and warnings enabled */ if (warn && rshift > 0) { BitVector_Copy(conv_bv, op2); BitVector_Move_Left(conv_bv, (N_int)(BITVECT_NATIVE_SIZE-rshift)); if (!BitVector_is_empty(conv_bv)) yasm_warn_set(YASM_WARN_GENERAL, N_("misaligned value, truncating to boundary")); } /* Shift right if needed */ if (rshift > 0) { carry_in = BitVector_msb_(op2); while (rshift-- > 0) BitVector_shift_right(op2, carry_in); shift = 0; } /* Write the new value into the destination bitvect */ BitVector_Interval_Copy(op1, op2, (unsigned int)shift, 0, (N_int)valsize); /* Write out the new data */ buf = BitVector_Block_Read(op1, &len); if (bigendian) { /* TODO */ yasm_internal_error(N_("big endian not implemented")); } else memcpy(ptr, buf, destsize); yasm_xfree(buf); }