Add several arithmetic functions
diff --git a/src/lisp/lib/std.c b/src/lisp/lib/std.c
index 7bed8de..8175940 100644
--- a/src/lisp/lib/std.c
+++ b/src/lisp/lib/std.c
@@ -9,6 +9,30 @@
return (((a >> 2) + (b >> 2)) << 2) | INT_TAG;
}
+value_t l_minus (value_t a, value_t b)
+{
+ if ( !integerp (a) || !integerp (b) )
+ return nil;
+
+ return (((a >> 2) - (b >> 2)) << 2) | INT_TAG;
+}
+
+value_t l_times (value_t a, value_t b)
+{
+ if ( !integerp (a) || !integerp (b) )
+ return nil;
+
+ return (((a >> 2) * (b >> 2)) << 2) | INT_TAG;
+}
+
+value_t l_divide (value_t a, value_t b)
+{
+ if ( !integerp (a) || !integerp (b) )
+ return nil;
+
+ return (((a >> 2) / (b >> 2)) << 2) | INT_TAG;
+}
+
void add_function (struct environment *env, char *name, void *func, int nargs)
{
struct function *last,
@@ -26,4 +50,7 @@
void load_std (struct environment *env)
{
add_function (env, "+", l_plus, 2);
+ add_function (env, "-", l_minus, 2);
+ add_function (env, "*", l_times, 2);
+ add_function (env, "/", l_divide, 2);
}
diff --git a/src/lisp/lisp b/src/lisp/lisp
index 2421bd3..492c456 100755
--- a/src/lisp/lisp
+++ b/src/lisp/lisp
Binary files differ