Add yasm_intnum_set_int().

svn path=/branches/new-optimizer/; revision=1573
0.6.0
Peter Johnson 19 years ago
parent c4553529c5
commit 7ebf4d268e
  1. 21
      libyasm/intnum.c
  2. 6
      libyasm/intnum.h

@ -594,6 +594,27 @@ yasm_intnum_set_uint(yasm_intnum *intn, unsigned long val)
intn->val.ul = val;
}
void
yasm_intnum_set_int(yasm_intnum *intn, long val)
{
/* positive numbers can go through the uint() function */
if (i >= 0) {
yasm_intnum_set_uint(intn, (unsigned long)i);
return;
}
BitVector_Empty(conv_bv);
BitVector_Chunk_Store(conv_bv, 32, 0, (unsigned long)(-i));
BitVector_Negate(conv_bv, conv_bv);
if (intn->type == INTNUM_BV)
BitVector_Copy(intn->val.bv, conv_bv);
else {
intn->val.bv = BitVector_Clone(conv_bv);
intn->type = INTNUM_BV;
}
}
int
yasm_intnum_is_zero(const yasm_intnum *intn)
{

@ -136,6 +136,12 @@ void yasm_intnum_zero(yasm_intnum *intn);
*/
void yasm_intnum_set_uint(yasm_intnum *intn, unsigned long val);
/** Set an intnum to an signed integer.
* \param intn intnum
* \param val integer value
*/
void yasm_intnum_set_int(yasm_intnum *intn, long val);
/** Simple value check for 0.
* \param acc intnum
* \return Nonzero if acc==0.

Loading…
Cancel
Save