From e757fc652191872e7d8d79ae0ce46d3fa9f3f7de Mon Sep 17 00:00:00 2001 From: David Griffith Date: Sat, 21 Sep 2019 16:59:53 -0700 Subject: [PATCH] Convert math.c to K&R style. --- src/common/math.c | 121 +++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 67 deletions(-) diff --git a/src/common/math.c b/src/common/math.c index 2d087a8..afb51b7 100644 --- a/src/common/math.c +++ b/src/common/math.c @@ -27,11 +27,10 @@ * zargs[1] = second value * */ -void z_add (void) +void z_add(void) { - store ((zword) ((short) zargs[0] + (short) zargs[1])); - -}/* z_add */ + store((zword) ((short) zargs[0] + (short) zargs[1])); +} /* z_add */ /* @@ -41,11 +40,10 @@ void z_add (void) * zargs[1] = second value * */ -void z_and (void) +void z_and(void) { store ((zword) (zargs[0] & zargs[1])); - -}/* z_and */ +} /* z_and */ /* @@ -55,14 +53,14 @@ void z_and (void) * zargs[1] = #positions to shift left (positive) or right * */ -void z_art_shift (void) +void z_art_shift(void) { - if ((short) zargs[1] > 0) - store ((zword) ((short) zargs[0] << (short) zargs[1])); - else - store ((zword) ((short) zargs[0] >> - (short) zargs[1])); + if ((short) zargs[1] > 0) + store((zword) ((short) zargs[0] << (short) zargs[1])); + else + store((zword) ((short) zargs[0] >> - (short) zargs[1])); -}/* z_art_shift */ +} /* z_art_shift */ /* @@ -72,14 +70,13 @@ void z_art_shift (void) * zargs[1] = second value * */ -void z_div (void) +void z_div(void) { - if (zargs[1] == 0) - runtime_error (ERR_DIV_ZERO); + if (zargs[1] == 0) + runtime_error(ERR_DIV_ZERO); + store((zword) ((short) zargs[0] / (short) zargs[1])); - store ((zword) ((short) zargs[0] / (short) zargs[1])); - -}/* z_div */ +} /* z_div */ /* @@ -91,14 +88,13 @@ void z_div (void) * zargs[3] = fourth value (optional) * */ -void z_je (void) +void z_je(void) { - branch ( - zargc > 1 && (zargs[0] == zargs[1] || ( - zargc > 2 && (zargs[0] == zargs[2] || ( - zargc > 3 && (zargs[0] == zargs[3])))))); - -}/* z_je */ + branch ( + zargc > 1 && (zargs[0] == zargs[1] || ( + zargc > 2 && (zargs[0] == zargs[2] || ( + zargc > 3 && (zargs[0] == zargs[3])))))); +} /* z_je */ /* @@ -108,10 +104,9 @@ void z_je (void) * zargs[1] = second value * */ -void z_jg (void) +void z_jg(void) { - branch ((short) zargs[0] > (short) zargs[1]); - + branch((short) zargs[0] > (short) zargs[1]); }/* z_jg */ @@ -122,11 +117,10 @@ void z_jg (void) * zargs[1] = second value * */ -void z_jl (void) +void z_jl(void) { - branch ((short) zargs[0] < (short) zargs[1]); - -}/* z_jl */ + branch((short) zargs[0] < (short) zargs[1]); +} /* z_jl */ /* @@ -135,11 +129,11 @@ void z_jl (void) * zargs[0] = value * */ -void z_jz (void) +void z_jz(void) { - branch ((short) zargs[0] == 0); + branch((short) zargs[0] == 0); -}/* z_jz */ +} /* z_jz */ /* @@ -149,14 +143,13 @@ void z_jz (void) * zargs[1] = #positions to shift left (positive) or right (negative) * */ -void z_log_shift (void) +void z_log_shift(void) { - if ((short) zargs[1] > 0) - store ((zword) (zargs[0] << (short) zargs[1])); - else - store ((zword) (zargs[0] >> - (short) zargs[1])); - -}/* z_log_shift */ + if ((short) zargs[1] > 0) + store((zword) (zargs[0] << (short) zargs[1])); + else + store((zword) (zargs[0] >> - (short) zargs[1])); +} /* z_log_shift */ /* @@ -168,12 +161,11 @@ void z_log_shift (void) */ void z_mod (void) { - if (zargs[1] == 0) - runtime_error (ERR_DIV_ZERO); + if (zargs[1] == 0) + runtime_error(ERR_DIV_ZERO); - store ((zword) ((short) zargs[0] % (short) zargs[1])); - -}/* z_mod */ + store((zword) ((short) zargs[0] % (short) zargs[1])); +} /* z_mod */ /* @@ -183,11 +175,10 @@ void z_mod (void) * zargs[1] = second value * */ -void z_mul (void) +void z_mul(void) { - store ((zword) ((short) zargs[0] * (short) zargs[1])); - -}/* z_mul */ + store((zword) ((short) zargs[0] * (short) zargs[1])); +} /* z_mul */ /* @@ -198,9 +189,8 @@ void z_mul (void) */ void z_not (void) { - store ((zword) ~zargs[0]); - -}/* z_not */ + store((zword) ~zargs[0]); +} /* z_not */ /* @@ -210,11 +200,10 @@ void z_not (void) * zargs[1] = second value * */ -void z_or (void) +void z_or(void) { - store ((zword) (zargs[0] | zargs[1])); - -}/* z_or */ + store((zword) (zargs[0] | zargs[1])); +} /* z_or */ /* @@ -224,11 +213,10 @@ void z_or (void) * zargs[1] = second value * */ -void z_sub (void) +void z_sub(void) { - store ((zword) ((short) zargs[0] - (short) zargs[1])); - -}/* z_sub */ + store((zword) ((short) zargs[0] - (short) zargs[1])); +} /* z_sub */ /* @@ -238,8 +226,7 @@ void z_sub (void) * zargs[1] = bit mask * */ -void z_test (void) +void z_test(void) { - branch ((zargs[0] & zargs[1]) == zargs[1]); - -}/* z_test */ + branch((zargs[0] & zargs[1]) == zargs[1]); +} /* z_test */ -- 2.34.1