X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Fstrcalc.c;h=4e4472e4ec241f1c3ac5bbdcec61bd437c12957d;hb=45ecc187cee7107c83c1f9618a1e1e586df73644;hp=27e8a20191f429a4d2ad342e6168eb7b5196a19a;hpb=e584b3b2de14050a3b249d95d94976e72ef70a19;p=libfirm diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c index 27e8a2019..4e4472e4e 100644 --- a/ir/tv/strcalc.c +++ b/ir/tv/strcalc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -41,6 +41,7 @@ #include "strcalc.h" #include "xmalloc.h" +#include "error.h" /* * local definitions and macros @@ -447,7 +448,7 @@ static void _fail_char(const char *str, size_t len, const char fchar, int pos, /** * implements the bitwise NOT operation */ -static void _bitnot(const char *val, char *buffer) { +static void do_bitnot(const char *val, char *buffer) { int counter; for (counter = 0; counter> 2; @@ -507,7 +508,7 @@ static int _bit(const char *val, int pos) { /** * Implements a fast ADD + 1 */ -static void _inc(const char *val, char *buffer) { +static void do_inc(const char *val, char *buffer) { int counter = 0; while (counter++ < calc_buffer_size) { @@ -527,9 +528,9 @@ static void _inc(const char *val, char *buffer) { /** * Implements a unary MINUS */ -static void _negate(const char *val, char *buffer) { - _bitnot(val, buffer); - _inc(buffer, buffer); +static void do_negate(const char *val, char *buffer) { + do_bitnot(val, buffer); + do_inc(buffer, buffer); } /** @@ -538,7 +539,7 @@ static void _negate(const char *val, char *buffer) { * @todo The implementation of carry is wrong, as it is the * calc_buffer_size carry, not the mode depending */ -static void _add(const char *val1, const char *val2, char *buffer) { +static void do_add(const char *val1, const char *val2, char *buffer) { int counter; const char *add1, *add2; char carry = SC_0; @@ -556,17 +557,17 @@ static void _add(const char *val1, const char *val2, char *buffer) { /** * Implements a binary SUB */ -static void _sub(const char *val1, const char *val2, char *buffer) { +static void do_sub(const char *val1, const char *val2, char *buffer) { char *temp_buffer = alloca(calc_buffer_size); /* intermediate buffer to hold -val2 */ - _negate(val2, temp_buffer); - _add(val1, temp_buffer, buffer); + do_negate(val2, temp_buffer); + do_add(val1, temp_buffer, buffer); } /** * Implements a binary MUL */ -static void _mul(const char *val1, const char *val2, char *buffer) { +static void do_mul(const char *val1, const char *val2, char *buffer) { char *temp_buffer; /* result buffer */ char *neg_val1; /* abs of val1 */ char *neg_val2; /* abs of val2 */ @@ -580,18 +581,18 @@ static void _mul(const char *val1, const char *val2, char *buffer) { neg_val1 = alloca(calc_buffer_size); neg_val2 = alloca(calc_buffer_size); - /* init result buffer to zeroes */ + /* init result buffer to zeros */ memset(temp_buffer, SC_0, calc_buffer_size); /* the multiplication works only for positive values, for negative values * * it is necessary to negate them and adjust the result accordingly */ - if (_sign(val1) == -1) { - _negate(val1, neg_val1); + if (do_sign(val1) == -1) { + do_negate(val1, neg_val1); val1 = neg_val1; sign ^= 1; } - if (_sign(val2) == -1) { - _negate(val2, neg_val2); + if (do_sign(val2) == -1) { + do_negate(val2, neg_val2); val2 = neg_val2; sign ^= 1; } @@ -634,7 +635,7 @@ static void _mul(const char *val1, const char *val2, char *buffer) { } if (sign) - _negate(temp_buffer, buffer); + do_negate(temp_buffer, buffer); else memcpy(buffer, temp_buffer, calc_buffer_size); } @@ -642,7 +643,7 @@ static void _mul(const char *val1, const char *val2, char *buffer) { /** * Shift the buffer to left and add a 4 bit digit */ -static void _push(const char digit, char *buffer) { +static void do_push(const char digit, char *buffer) { int counter; for (counter = calc_buffer_size - 2; counter >= 0; counter--) { @@ -656,7 +657,7 @@ static void _push(const char digit, char *buffer) { * * Note: This is MOST slow */ -static void _divmod(const char *rDividend, const char *divisor, char *quot, char *rem) { +static void do_divmod(const char *rDividend, const char *divisor, char *quot, char *rem) { const char *dividend = rDividend; const char *minus_divisor; char *neg_val1; @@ -681,15 +682,15 @@ static void _divmod(const char *rDividend, const char *divisor, char *quot, char if (sc_comp(dividend, quot) == 0) return; - if (_sign(dividend) == -1) { - _negate(dividend, neg_val1); + if (do_sign(dividend) == -1) { + do_negate(dividend, neg_val1); div_sign ^= 1; rem_sign ^= 1; dividend = neg_val1; } - _negate(divisor, neg_val2); - if (_sign(divisor) == -1) { + do_negate(divisor, neg_val2); + if (do_sign(divisor) == -1) { div_sign ^= 1; minus_divisor = divisor; divisor = neg_val2; @@ -712,21 +713,21 @@ static void _divmod(const char *rDividend, const char *divisor, char *quot, char } for (c_dividend = calc_buffer_size - 1; c_dividend >= 0; c_dividend--) { - _push(dividend[c_dividend], rem); - _push(SC_0, quot); + do_push(dividend[c_dividend], rem); + do_push(SC_0, quot); if (sc_comp(rem, divisor) != -1) { /* remainder >= divisor */ /* subtract until the remainder becomes negative, this should * be faster than comparing remainder with divisor */ - _add(rem, minus_divisor, rem); + do_add(rem, minus_divisor, rem); - while (_sign(rem) == 1) { + while (do_sign(rem) == 1) { quot[0] = add_table[_val(quot[0])][SC_1][0]; - _add(rem, minus_divisor, rem); + do_add(rem, minus_divisor, rem); } /* subtracted one too much */ - _add(rem, divisor, rem); + do_add(rem, divisor, rem); } } end: @@ -734,10 +735,10 @@ end: carry_flag = !sc_is_zero(rem); if (div_sign) - _negate(quot, quot); + do_negate(quot, quot); if (rem_sign) - _negate(rem, rem); + do_negate(rem, rem); } /** @@ -746,7 +747,7 @@ end: * * @todo Assertions seems to be wrong */ -static void _shl(const char *val1, char *buffer, long offset, int radius, unsigned is_signed) { +static void do_shl(const char *val1, char *buffer, long shift_cnt, int bitsize, unsigned is_signed) { const char *shl; char shift; char carry = SC_0; @@ -754,52 +755,52 @@ static void _shl(const char *val1, char *buffer, long offset, int radius, unsign int counter; int bitoffset = 0; - assert((offset >= 0) || (0 && "negative leftshift")); - assert(((_sign(val1) != -1) || is_signed) || (0 && "unsigned mode and negative value")); - assert(((!_bitisset(val1[(radius-1)/4], (radius-1)%4)) || !is_signed || (_sign(val1) == -1)) || (0 && "value is positive, should be negative")); - assert(((_bitisset(val1[(radius-1)/4], (radius-1)%4)) || !is_signed || (_sign(val1) == 1)) || (0 && "value is negative, should be positive")); + assert((shift_cnt >= 0) || (0 && "negative leftshift")); + assert(((do_sign(val1) != -1) || is_signed) || (0 && "unsigned mode and negative value")); + assert(((!_bitisset(val1[(bitsize-1)/4], (bitsize-1)%4)) || !is_signed || (do_sign(val1) == -1)) || (0 && "value is positive, should be negative")); + assert(((_bitisset(val1[(bitsize-1)/4], (bitsize-1)%4)) || !is_signed || (do_sign(val1) == 1)) || (0 && "value is negative, should be positive")); /* if shifting far enough the result is zero */ - if (offset >= radius) { + if (shift_cnt >= bitsize) { memset(buffer, SC_0, calc_buffer_size); return; } - shift = shift_table[_val(offset%4)]; /* this is 2 ** (offset % 4) */ - offset = offset / 4; + shift = shift_table[_val(shift_cnt%4)]; /* this is 2 ** (offset % 4) */ + shift_cnt = shift_cnt / 4; /* shift the single digits some bytes (offset) and some bits (table) * to the left */ - for (counter = 0; counter < radius/4 - offset; counter++) { + for (counter = 0; counter < bitsize/4 - shift_cnt; counter++) { shl = mul_table[_val(val1[counter])][_val(shift)]; - buffer[counter + offset] = or_table[_val(shl[0])][_val(carry)]; + buffer[counter + shift_cnt] = or_table[_val(shl[0])][_val(carry)]; carry = shl[1]; } - if (radius%4 > 0) { + if (bitsize%4 > 0) { shl = mul_table[_val(val1[counter])][_val(shift)]; - buffer[counter + offset] = or_table[_val(shl[0])][_val(carry)]; + buffer[counter + shift_cnt] = or_table[_val(shl[0])][_val(carry)]; bitoffset = counter; } else { bitoffset = counter - 1; } /* fill with zeroes */ - for (counter = 0; counter < offset; counter++) + for (counter = 0; counter < shift_cnt; counter++) buffer[counter] = SC_0; /* if the mode was signed, change sign when the mode's msb is now 1 */ - offset = bitoffset + offset; - bitoffset = (radius-1) % 4; - if (is_signed && _bitisset(buffer[offset], bitoffset)) { + shift_cnt = bitoffset + shift_cnt; + bitoffset = (bitsize-1) % 4; + if (is_signed && _bitisset(buffer[shift_cnt], bitoffset)) { /* this sets the upper bits of the leftmost digit */ - buffer[offset] = or_table[_val(buffer[offset])][_val(min_digit[bitoffset])]; - for (counter = offset+1; counter < calc_buffer_size; counter++) { + buffer[shift_cnt] = or_table[_val(buffer[shift_cnt])][_val(min_digit[bitoffset])]; + for (counter = shift_cnt+1; counter < calc_buffer_size; counter++) { buffer[counter] = SC_F; } - } else if (is_signed && !_bitisset(buffer[offset], bitoffset)) { + } else if (is_signed && !_bitisset(buffer[shift_cnt], bitoffset)) { /* this clears the upper bits of the leftmost digit */ - buffer[offset] = and_table[_val(buffer[offset])][_val(max_digit[bitoffset])]; - for (counter = offset+1; counter < calc_buffer_size; counter++) { + buffer[shift_cnt] = and_table[_val(buffer[shift_cnt])][_val(max_digit[bitoffset])]; + for (counter = shift_cnt+1; counter < calc_buffer_size; counter++) { buffer[counter] = SC_0; } } @@ -809,26 +810,28 @@ static void _shl(const char *val1, char *buffer, long offset, int radius, unsign * Implements a Shift Right, which can either preserve the sign bit * or not. * + * @param bitsize bitsize of the value to be shifted + * * @todo Assertions seems to be wrong */ -static void _shr(const char *val1, char *buffer, long offset, int radius, unsigned is_signed, int signed_shift) { +static void do_shr(const char *val1, char *buffer, long shift_cnt, int bitsize, unsigned is_signed, int signed_shift) { const char *shrs; char sign; char msd; - int shift; + int shift_mod, shift_nib; int counter; int bitoffset = 0; - assert((offset >= 0) || (0 && "negative rightshift")); - assert(((!_bitisset(val1[(radius-1)/4], (radius-1)%4)) || !is_signed || (_sign(val1) == -1)) || (0 && "value is positive, should be negative")); - assert(((_bitisset(val1[(radius-1)/4], (radius-1)%4)) || !is_signed || (_sign(val1) == 1)) || (0 && "value is negative, should be positive")); + assert((shift_cnt >= 0) || (0 && "negative rightshift")); + assert(((!_bitisset(val1[(bitsize-1)/4], (bitsize-1)%4)) || !is_signed || (do_sign(val1) == -1)) || (0 && "value is positive, should be negative")); + assert(((_bitisset(val1[(bitsize-1)/4], (bitsize-1)%4)) || !is_signed || (do_sign(val1) == 1)) || (0 && "value is negative, should be positive")); - sign = ((signed_shift) && (_sign(val1) == -1))?(SC_F):(SC_0); + sign = signed_shift && do_bit(val1, bitsize - 1) ? SC_F : SC_0; /* if shifting far enough the result is either 0 or -1 */ - if (offset >= radius) { + if (shift_cnt >= bitsize) { if (!sc_is_zero(val1)) { carry_flag = 1; } @@ -836,50 +839,51 @@ static void _shr(const char *val1, char *buffer, long offset, int radius, unsign return; } - shift = offset % 4; - offset = offset / 4; + shift_mod = shift_cnt & 3; + shift_nib = shift_cnt >> 2; /* check if any bits are lost, and set carry_flag if so */ - for (counter = 0; counter < offset; counter++) { + for (counter = 0; counter < shift_nib; ++counter) { if (val1[counter] != 0) { carry_flag = 1; break; } } - if ((_val(val1[counter]) & ((1< 0) { - buffer[counter] = shrs_table[_val(val1[offset])][shift][0]; + if ((bitsize >> 2) > shift_nib) { + buffer[counter] = shrs_table[_val(val1[shift_nib])][shift_mod][0]; counter = 1; } - for (; counter < radius/4 - offset; counter++) { - shrs = shrs_table[_val(val1[counter + offset])][shift]; + for (; counter < bitsize/4 - shift_nib; counter++) { + shrs = shrs_table[_val(val1[counter + shift_nib])][shift_mod]; buffer[counter] = shrs[0]; buffer[counter-1] = or_table[_val(buffer[counter-1])][_val(shrs[1])]; } /* the last digit is special in regard of signed/unsigned shift */ - bitoffset = radius%4; - msd = (radius/4 0) buffer[counter - 1] = or_table[_val(buffer[counter-1])][_val(shrs[1])]; + if (counter > 0) + buffer[counter - 1] = or_table[_val(buffer[counter-1])][_val(shrs[1])]; /* fill with SC_F or SC_0 depending on sign */ for (counter++; counter < calc_buffer_size; counter++) { @@ -888,10 +892,10 @@ static void _shr(const char *val1, char *buffer, long offset, int radius, unsign } /** - * Implements a Rotate Right. + * Implements a Rotate Left. * positive: low-order -> high order, negative other direction */ -static void _rot(const char *val1, char *buffer, long offset, int radius, unsigned is_signed) { +static void do_rotl(const char *val1, char *buffer, long offset, int radius, unsigned is_signed) { char *temp1, *temp2; temp1 = alloca(calc_buffer_size); temp2 = alloca(calc_buffer_size); @@ -904,9 +908,9 @@ static void _rot(const char *val1, char *buffer, long offset, int radius, unsign return; } - _shl(val1, temp1, offset, radius, is_signed); - _shr(val1, temp2, radius - offset, radius, is_signed, 0); - _bitor(temp1, temp2, buffer); + do_shl(val1, temp1, offset, radius, is_signed); + do_shr(val1, temp2, radius - offset, radius, is_signed, 0); + do_bitor(temp1, temp2, buffer); carry_flag = 0; /* set by shr, but due to rot this is false */ } @@ -1071,8 +1075,8 @@ void sc_val_from_str(const char *str, unsigned int len, void *buffer, ir_mode *m /* Radix conversion from base b to base B: * (UnUn-1...U1U0)b == ((((Un*b + Un-1)*b + ...)*b + U1)*b + U0)B */ - _mul(base, calc_buffer, calc_buffer); /* multiply current value with base */ - _add(val, calc_buffer, calc_buffer); /* add next digit to current value */ + do_mul(base, calc_buffer, calc_buffer); /* multiply current value with base */ + do_add(val, calc_buffer, calc_buffer); /* add next digit to current value */ /* get ready for the next letter */ str++; @@ -1080,7 +1084,7 @@ void sc_val_from_str(const char *str, unsigned int len, void *buffer, ir_mode *m } /* while (len > 0 ) */ if (sign) - _negate(calc_buffer, calc_buffer); + do_negate(calc_buffer, calc_buffer); /* beware: even if hex numbers have no sign, we need sign extension here */ sign_extend(calc_buffer, mode); @@ -1113,9 +1117,9 @@ void sc_val_from_long(long value, void *buffer) { if (sign) { if (is_minlong) - _inc(buffer, buffer); + do_inc(buffer, buffer); - _negate(buffer, buffer); + do_negate(buffer, buffer); } } @@ -1205,8 +1209,8 @@ int sc_comp(const void* value1, const void* value2) { /* compare signs first: * the loop below can only compare values of the same sign! */ - if (_sign(val1) != _sign(val2)) - return (_sign(val1) == 1)?(1):(-1); + if (do_sign(val1) != do_sign(val2)) + return (do_sign(val1) == 1)?(1):(-1); /* loop until two digits differ, the values are equal if there * are no such two digits */ @@ -1285,7 +1289,7 @@ int sc_is_zero(const void *value) { } int sc_is_negative(const void *value) { - return _sign(value) == -1; + return do_sign(value) == -1; } int sc_had_carry(void) { @@ -1306,8 +1310,8 @@ unsigned char sc_sub_bits(const void *value, int len, unsigned byte_ofs) { res |= _val(val[nibble_ofs + 1]) << 4; /* kick bits outsize */ - if (len < (int) (8*byte_ofs)) { - res &= 0xFF >> (8*byte_ofs - len); + if (len - 8 * byte_ofs < 8) { + res &= (1 << (len - 8 * byte_ofs)) - 1; } return res; } @@ -1321,7 +1325,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig static const char small_digits[] = "0123456789abcdef"; char *base_val, *div1_res, *div2_res, *rem_res; - int counter, nibbles, i, sign; + int counter, nibbles, i, sign, mask; char x; const char *val = (const char *)value; @@ -1361,7 +1365,8 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig /* last nibble must be masked */ if (bits & 3) { - x = and_table[_val(val[++counter])][bits & 3]; + mask = zex_digit[bits & 3]; + x = and_table[_val(val[counter++])][mask]; *(--pos) = digits[_val(x)]; } @@ -1387,7 +1392,8 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig /* last nibble must be masked */ if (bits & 3) { - x = and_table[_val(val[++counter])][bits & 3]; + mask = zex_digit[bits & 3]; + x = and_table[_val(val[counter++])][mask]; pos -= 4; p = binary_table[_val(x)]; @@ -1412,8 +1418,8 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig sign = 0; if (signed_mode && base == SC_DEC) { /* check for negative values */ - if (_bit(val, bits - 1)) { - _negate(val, div2_res); + if (do_bit(val, bits - 1)) { + do_negate(val, div2_res); sign = 1; p = div2_res; } @@ -1426,15 +1432,15 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig /* last nibble must be masked */ if (bits & 3) { + mask = zex_digit[bits & 3]; + div1_res[counter] = and_table[_val(p[counter])][mask]; ++counter; - - div1_res[counter] = and_table[_val(p[counter])][bits & 3]; } m = div1_res; n = div2_res; for (;;) { - _divmod(m, base_val, n, rem_res); + do_divmod(m, base_val, n, rem_res); t = m; m = n; n = t; @@ -1452,9 +1458,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig break; default: - printf("%i\n", base); - assert(0); - return NULL; + panic("Unsupported base %d", base); } return pos; } @@ -1470,8 +1474,8 @@ void init_strcalc(int precision) { calc_buffer_size = (precision / 2); max_value_size = (precision / 4); - calc_buffer = xmalloc(calc_buffer_size+1 * sizeof(char)); - output_buffer = xmalloc(bit_pattern_size+1 * sizeof(char)); + calc_buffer = XMALLOCN(char, calc_buffer_size + 1); + output_buffer = XMALLOCN(char, bit_pattern_size + 1); DEBUGPRINTF(("init strcalc: \n\tPRECISION: %d\n\tCALC_BUFFER_SIZE = %d\n\tMAX_VALUE_SIZE = %d\n\tbuffer pointer: %p\n", precision, calc_buffer_size, max_value_size, calc_buffer)); } @@ -1495,7 +1499,7 @@ void sc_add(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s + ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _add(value1, value2, calc_buffer); + do_add(value1, value2, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1511,7 +1515,7 @@ void sc_sub(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s - ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _sub(value1, value2, calc_buffer); + do_sub(value1, value2, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1525,7 +1529,7 @@ void sc_neg(const void *value1, void *buffer) { DEBUGPRINTF_COMPUTATION(("- %s ->", sc_print_hex(value1))); - _negate(value1, calc_buffer); + do_negate(value1, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1541,7 +1545,7 @@ void sc_and(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s & ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _bitand(value1, value2, calc_buffer); + do_bitand(value1, value2, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1557,7 +1561,7 @@ void sc_or(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s | ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _bitor(value1, value2, calc_buffer); + do_bitor(value1, value2, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1573,7 +1577,7 @@ void sc_xor(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s ^ ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _bitxor(value1, value2, calc_buffer); + do_bitxor(value1, value2, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1588,7 +1592,7 @@ void sc_not(const void *value1, void *buffer) { DEBUGPRINTF_COMPUTATION(("~ %s ->", sc_print_hex(value1))); - _bitnot(value1, calc_buffer); + do_bitnot(value1, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1604,7 +1608,7 @@ void sc_mul(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s * ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _mul(value1, value2, calc_buffer); + do_mul(value1, value2, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1623,7 +1627,7 @@ void sc_div(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s / ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _divmod(value1, value2, calc_buffer, unused_res); + do_divmod(value1, value2, calc_buffer, unused_res); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1642,7 +1646,7 @@ void sc_mod(const void *value1, const void *value2, void *buffer) { DEBUGPRINTF_COMPUTATION(("%s %% ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _divmod(value1, value2, unused_res, calc_buffer); + do_divmod(value1, value2, unused_res, calc_buffer); DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer))); @@ -1658,17 +1662,17 @@ void sc_divmod(const void *value1, const void *value2, void *div_buffer, void *m DEBUGPRINTF_COMPUTATION(("%s %% ", sc_print_hex(value1))); DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2))); - _divmod(value1, value2, div_buffer, mod_buffer); + do_divmod(value1, value2, div_buffer, mod_buffer); DEBUGPRINTF_COMPUTATION(("%s:%s\n", sc_print_hex(div_buffer), sc_print_hex(mod_buffer))); } -void sc_shlI(const void *val1, long offset, int radius, int sign, void *buffer) { +void sc_shlI(const void *val1, long shift_cnt, int bitsize, int sign, void *buffer) { carry_flag = 0; - DEBUGPRINTF_COMPUTATION(("%s << %ld ", sc_print_hex(value1), offset)); - _shl(val1, calc_buffer, offset, radius, sign); + DEBUGPRINTF_COMPUTATION(("%s << %ld ", sc_print_hex(value1), shift_cnt)); + do_shl(val1, calc_buffer, shift_cnt, bitsize, sign); DEBUGPRINTF_COMPUTATION(("-> %s\n", sc_print_hex(calc_buffer))); @@ -1677,17 +1681,17 @@ void sc_shlI(const void *val1, long offset, int radius, int sign, void *buffer) } } -void sc_shl(const void *val1, const void *val2, int radius, int sign, void *buffer) { +void sc_shl(const void *val1, const void *val2, int bitsize, int sign, void *buffer) { long offset = sc_val_to_long(val2); - sc_shlI(val1, offset, radius, sign, buffer); + sc_shlI(val1, offset, bitsize, sign, buffer); } -void sc_shrI(const void *val1, long offset, int radius, int sign, void *buffer) { +void sc_shrI(const void *val1, long shift_cnt, int bitsize, int sign, void *buffer) { carry_flag = 0; - DEBUGPRINTF_COMPUTATION(("%s >>u %ld ", sc_print_hex(value1), offset)); - _shr(val1, calc_buffer, offset, radius, sign, 0); + DEBUGPRINTF_COMPUTATION(("%s >>u %ld ", sc_print_hex(value1), shift_cnt)); + do_shr(val1, calc_buffer, shift_cnt, bitsize, sign, 0); DEBUGPRINTF_COMPUTATION(("-> %s\n", sc_print_hex(calc_buffer))); @@ -1696,19 +1700,19 @@ void sc_shrI(const void *val1, long offset, int radius, int sign, void *buffer) } } -void sc_shr(const void *val1, const void *val2, int radius, int sign, void *buffer) { - long offset = sc_val_to_long(val2); +void sc_shr(const void *val1, const void *val2, int bitsize, int sign, void *buffer) { + long shift_cnt = sc_val_to_long(val2); - sc_shrI(val1, offset, radius, sign, buffer); + sc_shrI(val1, shift_cnt, bitsize, sign, buffer); } -void sc_shrs(const void *val1, const void *val2, int radius, int sign, void *buffer) { +void sc_shrs(const void *val1, const void *val2, int bitsize, int sign, void *buffer) { long offset = sc_val_to_long(val2); carry_flag = 0; DEBUGPRINTF_COMPUTATION(("%s >>s %ld ", sc_print_hex(value1), offset)); - _shr(val1, calc_buffer, offset, radius, sign, 1); + do_shr(val1, calc_buffer, offset, bitsize, sign, 1); DEBUGPRINTF_COMPUTATION(("-> %s\n", sc_print_hex(calc_buffer))); @@ -1717,13 +1721,13 @@ void sc_shrs(const void *val1, const void *val2, int radius, int sign, void *buf } } -void sc_rot(const void *val1, const void *val2, int radius, int sign, void *buffer) { +void sc_rotl(const void *val1, const void *val2, int bitsize, int sign, void *buffer) { long offset = sc_val_to_long(val2); carry_flag = 0; DEBUGPRINTF_COMPUTATION(("%s <<>> %ld ", sc_print_hex(value1), offset)); - _rot(val1, calc_buffer, offset, radius, sign); + do_rotl(val1, calc_buffer, offset, bitsize, sign); DEBUGPRINTF_COMPUTATION(("-> %s\n", sc_print_hex(calc_buffer)));