emulator/cpu/processor.c
static bool action_word_generator(elliott803_t *proc, const char *params) {

  if ('\0' != params[0]) {
    uint64_t w = proc->word_generator;
    if (0 == strcmp(params, "b")) {
      // set the B-Modifier
      w |= b_mod_bit;
    } else if ('f' == params[0] && ('1' == params[1] || '2' == params[1])) {
      uint64_t shift = '1' == params[1] ? first_op_shift : second_op_shift;
      uint64_t value = 0;
      params += 2;
      for (;;) {
        char c = *params++;
        if (c >= '0' && c <= '7') {
          value = value * 8 + c - '0';
        } else if (' ' == c) {
          continue;
        } else if ('\0' == c) {
          break;
        } else {
          const_reply(proc, "error invalid octal value");
          return true;
        }
      }
      if (value > op_bits) {
        const_reply(proc, "error octal value too large");
        return true;
      }
      if (0 == value) {
        w &= ~(op_bits << shift);
      } else {
        w |= value << shift;
      }
    } else if ('n' == params[0] && ('1' == params[1] || '2' == params[1])) {
      uint64_t shift =
        '1' == params[1] ? first_address_shift : second_address_shift;
      uint64_t value = 0;
      bool bmod = false;
      params += 2;
      for (;;) {
        char c = *params++;
        if (c >= '0' && c <= '9') {
          value = value * 10 + c - '0';
        } else if ('b' == c || '/' == c) {
          if (first_address_shift == shift) {
            bmod = true;
          } else {
            const_reply(proc, "error invalid b-modifier");
            return true;
          }
        } else if (' ' == c) {
          continue;
        } else if ('\0' == c) {
          break;
        } else {
          const_reply(proc, "error invalid decimal value");
          return true;
        }
      }
      if (value >= memory_size) {
        const_reply(proc, "error decimal value too large");
        return true;
      }
      if (0 == value && !bmod) {
        w &= ~(address_bits << shift);
        if (first_address_shift == shift) {
          w &= ~b_mod_bit;
        }
      } else {
        w |= value << shift;
        if (bmod) {
          w |= b_mod_bit;
        }
      }
    } else {
      // otherwise treat as code or ±N
      w = from_machine_code(params, strlen(params));
      if (-1 == (int64_t)(w)) {
        const_reply(proc, "error invalid machine code");
        return true;
      }
    }
    proc->word_generator = w;
  }

  char *s = to_machine_code("wg ", proc->word_generator);

  ssize_t n = reply(proc, s, strlen(s) + 1); // include '\0'
  assert(0 != n);
  free(s);

  return true;
}
// msb/lsb simulate action of Elliott 803 word generator in that
// a single bit can be set, but clear zeros a whole row
// msb    = 40  0 : 00  0   sign bit
// f2l    = 00  0 : 01  0   low bit of op2
// lsb    = 00  0 : 00  1   low bit of address 2
msb/lsb simulate action of Elliott 803 word generator in that
a single bit can be set, but clear zeros a whole row
msb    = 40  0 : 00  0   sign bit
f2l    = 00  0 : 01  0   low bit of op2
lsb    = 00  0 : 00  1   low bit of address 2
msb / lsb simulate action of Elliott 803 word generator in that a single bit can be set but clear zeros a whole row msb = 40 0 : 00 0 sign bit f2l = 00 0 : 01 0 low bit of op2 lsb = 00 0 : 00 1 low bit of address 2
static bool action_word_generator(elliott803_t *proc, const char *params) {
  if ('\0' != params[0]) {
    uint64_t w = proc->word_generator;
    if (0 == strcmp(params, "b")) {
      w |= b_mod_bit;
    } else if ('f' == params[0] && ('1' == params[1] || '2' == params[1])) {
      uint64_t shift = '1' == params[1] ? first_op_shift : second_op_shift;
      uint64_t value = 0;
      params += 2;
      for (;;) {
        char c = *params++;
        if (c >= '0' && c <= '7') {
          value = value * 8 + c - '0';
        } else if (' ' == c) {
          continue;
        } else if ('\0' == c) {
          break;
        } else {
          const_reply(proc, "error invalid octal value");
          return true;
        }
      }
      if (value > op_bits) {
        const_reply(proc, "error octal value too large");
        return true;
      }
      if (0 == value) {
        w &= ~(op_bits << shift);
      } else {
        w |= value << shift;
      }
    } else if ('n' == params[0] && ('1' == params[1] || '2' == params[1])) {
      uint64_t shift =
        '1' == params[1] ? first_address_shift : second_address_shift;
      uint64_t value = 0;
      bool bmod = false;
      params += 2;
      for (;;) {
        char c = *params++;
        if (c >= '0' && c <= '9') {
          value = value * 10 + c - '0';
        } else if ('b' == c || '/' == c) {
          if (first_address_shift == shift) {
            bmod = true;
          } else {
            const_reply(proc, "error invalid b-modifier");
            return true;
          }
        } else if (' ' == c) {
          continue;
        } else if ('\0' == c) {
          break;
        } else {
          const_reply(proc, "error invalid decimal value");
          return true;
        }
      }
      if (value >= memory_size) {
        const_reply(proc, "error decimal value too large");
        return true;
      }
      if (0 == value && !bmod) {
        w &= ~(address_bits << shift);
        if (first_address_shift == shift) {
          w &= ~b_mod_bit;
        }
      } else {
        w |= value << shift;
        if (bmod) {
          w |= b_mod_bit;
        }
      }
    } else {
      w = from_machine_code(params, strlen(params));
      if (-1 == (int64_t)(w)) {
        const_reply(proc, "error invalid machine code");
        return true;
      }
    }
    proc->word_generator = w;
  }
  char *s = to_machine_code("wg ", proc->word_generator);
  ssize_t n = reply(proc, s, strlen(s) + 1); 
  assert(0 != n);
  free(s);
  return true;
}
static bool action_word_generator ( elliott803_t * proc , const char * params ) { if ( ' \0 ' != params [ 0 ] ) { uint64_t w = proc -> word_generator ; if ( 0 == strcmp ( params , " " ) ) { w |= b_mod_bit ; } else if ( ' ' == params [ 0 ] && ( ' ' == params [ 1 ] || ' ' == params [ 1 ] ) ) { uint64_t shift = ' ' == params [ 1 ] ? first_op_shift : second_op_shift ; uint64_t value = 0 ; params += 2 ; for ( ; ; ) { char c = * params ++ ; if ( c >= ' ' && c <= ' ' ) { value = value * 8 + c - ' ' ; } else if ( ' ' == c ) { continue ; } else if ( ' \0 ' == c ) { break ; } else { const_reply ( proc , " " ) ; return true ; } } if ( value > op_bits ) { const_reply ( proc , " " ) ; return true ; } if ( 0 == value ) { w &= ~ ( op_bits << shift ) ; } else { w |= value << shift ; } } else if ( ' ' == params [ 0 ] && ( ' ' == params [ 1 ] || ' ' == params [ 1 ] ) ) { uint64_t shift = ' ' == params [ 1 ] ? first_address_shift : second_address_shift ; uint64_t value = 0 ; bool bmod = false ; params += 2 ; for ( ; ; ) { char c = * params ++ ; if ( c >= ' ' && c <= ' ' ) { value = value * 10 + c - ' ' ; } else if ( ' ' == c || ' ' == c ) { if ( first_address_shift == shift ) { bmod = true ; } else { const_reply ( proc , " " ) ; return true ; } } else if ( ' ' == c ) { continue ; } else if ( ' \0 ' == c ) { break ; } else { const_reply ( proc , " " ) ; return true ; } } if ( value >= memory_size ) { const_reply ( proc , " " ) ; return true ; } if ( 0 == value && ! bmod ) { w &= ~ ( address_bits << shift ) ; if ( first_address_shift == shift ) { w &= ~ b_mod_bit ; } } else { w |= value << shift ; if ( bmod ) { w |= b_mod_bit ; } } } else { w = from_machine_code ( params , strlen ( params ) ) ; if ( -1 == ( int64_t ) ( w ) ) { const_reply ( proc , " " ) ; return true ; } } proc -> word_generator = w ; } char * s = to_machine_code ( " " , proc -> word_generator ) ; ssize_t n = reply ( proc , s , strlen ( s ) + 1 ) ; assert ( 0 != n ) ; free ( s ) ; return true ; }
msb/lsb simulate action of Elliott 803 word generator in that
a single bit can be set, but clear zeros a whole row
msb    = 40  0 : 00  0   sign bit
f2l    = 00  0 : 01  0   low bit of op2
lsb    = 00  0 : 00  1   low bit of address 2
msb / lsb simulate action of Elliott 803 word generator in that a single bit can be set but clear zeros a whole row msb = 40 0 : 00 0 sign bit f2l = 00 0 : 01 0 low bit of op2 lsb = 00 0 : 00 1 low bit of address 2
// set the B-Modifier // otherwise treat as code or ±N // include '\0'