From 9a5f69c8d777a50a44c6935b78a72e449f1b4dde Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Mon, 25 Jun 1990 18:18:34 +0000 Subject: [PATCH] Add bit-wise fixnum operations. --- v7/src/microcode/fixnum.c | 57 ++++++++++++++++++++++++++++++++++++-- v7/src/microcode/version.h | 4 +-- v8/src/microcode/version.h | 4 +-- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/v7/src/microcode/fixnum.c b/v7/src/microcode/fixnum.c index 15e5be261..57ece4cec 100644 --- a/v7/src/microcode/fixnum.c +++ b/v7/src/microcode/fixnum.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/fixnum.c,v 9.29 1989/09/28 21:18:59 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/fixnum.c,v 9.30 1990/06/25 18:18:20 jinx Exp $ -Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology +Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -247,3 +247,56 @@ DEFINE_PRIMITIVE ("GCD-FIXNUM", Prim_gcd_fixnum, 2, 2, 0) } PRIMITIVE_RETURN (LONG_TO_FIXNUM (x)); } + +/* Bitwise operations */ + +#define FIXNUM_BOOLEAN_BODY(operation) \ +do \ +{ \ + fast unsigned long x, y, z; \ + \ + PRIMITIVE_HEADER (2); \ + \ + x = (arg_fixnum (1)); \ + y = (arg_fixnum (2)); \ + \ + z = (x operation y); \ + return (LONG_TO_FIXNUM (z)); \ +} while (0) + + +DEFINE_PRIMITIVE ("FIXNUM-ANDC", Prim_fixnum_andc, 2, 2, 0) +{ + FIXNUM_BOOLEAN_BODY(& ~); +} + + +DEFINE_PRIMITIVE ("FIXNUM-AND", Prim_fixnum_and, 2, 2, 0) +{ + FIXNUM_BOOLEAN_BODY(&); +} + + +DEFINE_PRIMITIVE ("FIXNUM-OR", Prim_fixnum_or, 2, 2, 0) +{ + FIXNUM_BOOLEAN_BODY(|); +} + + +DEFINE_PRIMITIVE ("FIXNUM-XOR", Prim_fixnum_xor, 2, 2, 0) +{ + FIXNUM_BOOLEAN_BODY(^); +} + + +DEFINE_PRIMITIVE ("FIXNUM-NOT", Prim_fixnum_not, 1, 1, 0) +{ + fast unsigned long x, z; + + PRIMITIVE_HEADER (1); + + x = (arg_fixnum (1)); + + z = (~ (x)); + return (LONG_TO_FIXNUM (z)); +} diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index fdfffc05d..d6452e7e4 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.34 1990/06/21 20:02:06 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.35 1990/06/25 18:18:34 jinx Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -46,7 +46,7 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 34 +#define SUBVERSION 35 #endif #ifndef UCODE_TABLES_FILENAME diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index 1a35c5905..056cd6d55 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.34 1990/06/21 20:02:06 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.35 1990/06/25 18:18:34 jinx Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -46,7 +46,7 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 34 +#define SUBVERSION 35 #endif #ifndef UCODE_TABLES_FILENAME -- 2.25.1