+void sc_sub(const void *value1, const void *value2, void *buffer) {
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s - ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ do_sub(value1, value2, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_neg(const void *value1, void *buffer) {
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("- %s ->", sc_print_hex(value1)));
+
+ do_negate(value1, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_and(const void *value1, const void *value2, void *buffer) {
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s & ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ do_bitand(value1, value2, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_or(const void *value1, const void *value2, void *buffer) {
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s | ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ do_bitor(value1, value2, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_xor(const void *value1, const void *value2, void *buffer) {
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s ^ ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ do_bitxor(value1, value2, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_not(const void *value1, void *buffer) {
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("~ %s ->", sc_print_hex(value1)));
+
+ do_bitnot(value1, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_mul(const void *value1, const void *value2, void *buffer) {
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s * ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ do_mul(value1, value2, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_div(const void *value1, const void *value2, void *buffer) {
+ /* temp buffer holding unused result of divmod */
+ char *unused_res = alloca(calc_buffer_size);
+
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s / ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ do_divmod(value1, value2, calc_buffer, unused_res);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_mod(const void *value1, const void *value2, void *buffer) {
+ /* temp buffer holding unused result of divmod */
+ char *unused_res = alloca(calc_buffer_size);
+
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s %% ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ do_divmod(value1, value2, unused_res, calc_buffer);
+
+ DEBUGPRINTF_COMPUTATION(("%s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memcpy(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+void sc_divmod(const void *value1, const void *value2, void *div_buffer, void *mod_buffer) {
+ CLEAR_BUFFER(calc_buffer);
+ carry_flag = 0;
+
+ DEBUGPRINTF_COMPUTATION(("%s %% ", sc_print_hex(value1)));
+ DEBUGPRINTF_COMPUTATION(("%s -> ", sc_print_hex(value2)));
+
+ 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 shift_cnt, int bitsize, int sign, void *buffer) {
+ carry_flag = 0;
+
+ 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)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memmove(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+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, bitsize, sign, 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), shift_cnt));
+ do_shr(val1, calc_buffer, shift_cnt, bitsize, sign, 0);
+
+ DEBUGPRINTF_COMPUTATION(("-> %s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memmove(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+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, shift_cnt, bitsize, sign, 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));
+ do_shr(val1, calc_buffer, offset, bitsize, sign, 1);
+
+ DEBUGPRINTF_COMPUTATION(("-> %s\n", sc_print_hex(calc_buffer)));
+
+ if ((buffer != NULL) && (buffer != calc_buffer)) {
+ memmove(buffer, calc_buffer, calc_buffer_size);
+ }
+}
+
+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));
+ do_rotl(val1, calc_buffer, offset, bitsize, sign);
+
+ DEBUGPRINTF_COMPUTATION(("-> %s\n", sc_print_hex(calc_buffer)));