-/* $OpenBSD: bcode.c,v 1.59 2017/12/05 14:05:22 otto Exp $ */
+/* $OpenBSD: bcode.c,v 1.60 2017/12/12 18:58:59 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
badd(void)
{
struct number *a, *b;
- struct number *r;
a = pop_number();
if (a == NULL)
return;
}
- r = new_number();
- r->scale = max(a->scale, b->scale);
- if (r->scale > a->scale)
- normalize(a, r->scale);
- else if (r->scale > b->scale)
- normalize(b, r->scale);
- bn_check(BN_add(r->number, a->number, b->number));
- push_number(r);
+ if (b->scale > a->scale)
+ normalize(a, b->scale);
+ else if (a->scale > b->scale)
+ normalize(b, a->scale);
+ bn_check(BN_add(b->number, a->number, b->number));
free_number(a);
- free_number(b);
+ push_number(b);
}
static void
bsub(void)
{
struct number *a, *b;
- struct number *r;
a = pop_number();
if (a == NULL)
return;
}
- r = new_number();
-
- r->scale = max(a->scale, b->scale);
- if (r->scale > a->scale)
- normalize(a, r->scale);
- else if (r->scale > b->scale)
- normalize(b, r->scale);
- bn_check(BN_sub(r->number, b->number, a->number));
- push_number(r);
+ if (b->scale > a->scale)
+ normalize(a, b->scale);
+ else if (a->scale > b->scale)
+ normalize(b, a->scale);
+ bn_check(BN_sub(b->number, b->number, a->number));
free_number(a);
- free_number(b);
+ push_number(b);
}
void
bmul(void)
{
struct number *a, *b;
- struct number *r;
a = pop_number();
if (a == NULL)
return;
}
- r = new_number();
- bmul_number(r, a, b, bmachine.scale);
-
- push_number(r);
+ bmul_number(b, a, b, bmachine.scale);
free_number(a);
- free_number(b);
+ push_number(b);
}
static void