   else return nil;
 }
 
+// Bitwise operators
+
+object *fn_logand (object *args, object *env) {
+  (void) env;
+  unsigned int result = 0xFFFF;
+  while (args != NULL) {
+    result = result & integer(first(args));
+    args = cdr(args);
+  }
+  return number(result);
+}
+
+object *fn_logior (object *args, object *env) {
+  (void) env;
+  unsigned int result = 0;
+  while (args != NULL) {
+    result = result | integer(first(args));
+    args = cdr(args);
+  }
+  return number(result);
+}
+
+object *fn_logxor (object *args, object *env) {
+  (void) env;
+  unsigned int result = 0;
+  while (args != NULL) {
+    result = result ^ integer(first(args));
+    args = cdr(args);
+  }
+  return number(result);
+}
+
+object *fn_lognot (object *args, object *env) {
+  (void) env;
+  int result = integer(car(args));
+  return number(~result);
+}
+
+object *fn_ash (object *args, object *env) {
+  (void) env;
+  int value = integer(first(args));
+  int count = integer(second(args));
+  if (count >= 0)
+    return number(value << count);
+  else
+    return number(value >> abs(count));
+}
+
+object *fn_logbitp (object *args, object *env) {
+  (void) env;
+  int index = integer(first(args));
+  int value = integer(second(args));
+  return (bitRead(value, index) == 1) ? tee : nil;
+}
+
 // System functions
 
 object *fn_read (object *args, object *env) {

  for (int i=0; i<workspacesize; i++) {
    object *obj = &workspace[i];
    int type = (obj->type) & 0x7FFF;
    if (marked(obj) && type != SYMBOL && type != NUMBER) {
      if (car(obj) == (object *)((unsigned int)from | 0x8000)) 
        car(obj) = (object *)((unsigned int)to | 0x8000);
      if (cdr(obj) == from) cdr(obj) = to;

      TCCR2A = 1<<COM2A0 | 0<<COM2B0 | 2<<WGM20; // Toggle OC2A on match
    } else error(F("'note' pin not supported"));
    int prescaler = 0;
    if (cddr(args) != NULL) prescaler = integer(third(args));
    prescaler = 9 - prescaler - note/12;
    if (prescaler<3 || prescaler>6) error(F("'note' octave out of range"));
    OCR2A = pgm_read_byte(&scale[note%12]);
