Convert math.c to K&R style.
authorDavid Griffith <dave@661.org>
Sat, 21 Sep 2019 23:59:53 +0000 (16:59 -0700)
committerDavid Griffith <dave@661.org>
Mon, 23 Sep 2019 00:48:04 +0000 (17:48 -0700)
src/common/math.c

index 2d087a82c7dfca5b9b2f078fe934dffe7932b636..afb51b72dfeb8e048edf777b81dcb1172542b5c2 100644 (file)
  *     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 */