©harryvansomeren

Beeb

Homo Ludens

Homo Ludens is a book originally published in Dutch in 1938 by Dutch historian and cultural theorist Johan Huizinga. Huizinga suggests that play is a necessary condition of the generation of culture. Homo is the Latin word for 'human'. Ludens refers to sport, play, school, and practice.

Every opportunity now to sport, play, school, practice, and spend time on hobbies! See below for some projects I am working on.

I have never tried that before, so I think I should definitely be able to do that.
Astrid Lindgren, Pippi Longstocking

Work in progress

Knowing about software and knowing nothing about hardware: it will always be Work in Progress!

The Beeb: an 8-bit computer.

Building the Beeb2: step by step!

The Beeb

Alan Turing

The movie The Imitation Game is about cryptanalyst Alan Turing who invented a machine (the Bombe) which decrypted German intelligence messages for the British government during the Second World War. After watching it for the second time I started to dig into the work of Alan Turing again. During my study he was one of the heroes within IT history I got to know. (Fun fact: did you know that the T in Captcha stands for Turing?) And being a hard software guy from origin I delved again into issues like Turing Machines, Backus-Naur Form languages, Boolean algebra and CPU microcode. Microcode is the closest thing approaching hardware I studied. While walking down memory lane and trying to understand the evolution from the abacus, mechanical calculators, computers with vacuum tubes, transistors, integrated circuits and modern CPUs, I encountered the video's from Ben Eater.

Ben Eater's 8-bit homemade breadboard computer

Ben Eater has made a fantastic series of video's about making an 8-bit homemade breadboard computer. A breadboard is a construction base for prototyping of electronics. 8 Bits means it is basic, slow and primitive! It can only calculate with 8 zeroes/ones at a time. Knowing nothing about hardware but with the help of Ben Eater and having the quote from Pippi Longstocking in mind ("I have never tried that before, so I think I should definitely be able to do that."), I decided to make this computer too!

The Beeb2

The first computer I ever bought was the BBC B micro computer. The computer was designed by Cambridge based Acorn Computers Ltd. and used by the BBC in England in their Computer Literacy Project. Acorn was later called Arm Ltd. (known for their licensable chip architectures) which now stands for Advanced RISC Machines, but in the past stood for Acorn RISC Machine. BBC B owners loved their computer and nicknamed it "the Beeb". I have very fond memories of my Beeb, so decided to call this Ben Eater inspired 8-bit homemade breadboard computer I am going to make the Beeb2.

Beeb 2 Components and roadmap

Beeb 2 Components

The properties of the Beeb2 (and probably the easiest order to build the components) are:
Tick the box to see the used 74LS series IC's (Integrated Circuits): <---

Roadmap to the Beeb2+

  • 8 bit Program Counter
  • 8 bit Instruction Register
  • Reset Step Counter control line
  • 512KB Flash RAM/ROM (16 Banks of 32KB)
  • 4 bit Bank register
  • Boot from ROM
  • Assembler
  • Compiler
  • Game: Tower of Hanoi
  • OLED display
  • Pushbutton joystick
  • Game: Pong
  • Sound
  • C Cross-compiler

Roadmap the Beeb3

  • Joystick
  • Game: Snake
  • Real time clock
  • Wifi
  • Playstation joystick connection
  • SD card
  • Boot from SD card
  • Remote control of volume
  • Touchscreen
  • RFID unlock of the computer
  • Interrupts
  • Memory Mapped I/O
  • Pre-emptive kernel
  • Native C compiler

 


I am already working on an Assembler and a Compiler. The Beeb4 could be a PCB version... We'll see, it is al going to be very agile! 😇

Tower of Hanoi

Building the Beeb2

Clock

The first module!
  • Switch for manual or auto setting
  • Push button for use in manual mode to generate 1 clock tick
  • Rotary knob to adjust clock speed
  • Orange HALT line

Program Counter (PC)

  • 4 bit (16 addresses)
  • 3 control lines: PC-OUT, PC-IN (jump), PC++ (stop/resume PC)

Bus

  • 8 bit

A and B registers

Two registers are enough.
  • 8 bit
  • 2 control lines per register: A-IN, A-OUT, B-IN, B-OUT
  • Orange HALT lines

Sum Register

Tedious work, but in progress. Finished Sum Register.
  • 8 bit
  • 2 control lines: SUM-OUT, ADD (add or subtract).

Arduino Programmer

Time to build a digital display. To be able to program an EEPROM as a decoder for the LED display, I had to build an Arduino EEPROM programmer. An Arduino Nano is part of that programmer.


The first window below contains the Arduino code to write and read the EEPROM.
The second window below shows the Arduino IDE output during that proces.

eeprom_programmer.ino
/* This sketch is specifically for programming the EEPROM used in the 8-bit decimal display decoder described in https://youtu.be/dLh1n2dErzE */
#define SHIFT_DATA 2
#define SHIFT_CLK 3
#define SHIFT_LATCH 4
#define EEPROM_D0 5
#define EEPROM_D7 12
#define WRITE_EN 13

/* Output the address bits and outputEnable signal using shift registers. */
void setAddress(int address, bool outputEnable) {
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, (address >> 8) | (outputEnable ? 0x00 : 0x80));
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, address);
  digitalWrite(SHIFT_LATCH, LOW);
  digitalWrite(SHIFT_LATCH, HIGH);
  digitalWrite(SHIFT_LATCH, LOW);
}

/* Read a byte from the EEPROM at the specified address. */
byte readEEPROM(int address) {
  for (int pin = EEPROM_D0; pin <= EEPROM_D7; pin += 1) {
    pinMode(pin, INPUT);
  }
  setAddress(address, /*outputEnable*/ true);
  delayMicroseconds(5); // Geef de voltages op het breadboard tijd om te stabiliseren
  byte data = 0;
  for (int pin = EEPROM_D7; pin >= EEPROM_D0; pin -= 1) {
    data = (data << 1) + digitalRead(pin);
  }
  return data;
}

/* Write a byte to the EEPROM at the specified address.*/
void writeEEPROM(int address, byte data) {
  setAddress(address, /*outputEnable*/ false);
  for (int pin = EEPROM_D0; pin <= EEPROM_D7; pin += 1) {
    pinMode(pin, OUTPUT);
  }
  for (int pin = EEPROM_D0; pin <= EEPROM_D7; pin += 1) {
    digitalWrite(pin, data & 1);
    data = data >> 1;
  }
  delayMicroseconds(10); // toegevoegd
  digitalWrite(WRITE_EN, LOW);
  delayMicroseconds(5);  // verhoogd van 1 naar 5
  digitalWrite(WRITE_EN, HIGH);
  delay(20); // verhoogd van 10 naar 20
}

/* Leest elk bit en print het */
void printBinary(byte inByte) {
  for (int i = 7; i >= 0; i--) {
    Serial.print(bitRead(inByte, i));  // bitRead is een standaard Arduino functie
  }
}

/* Program EEPROM */
void programEEPROM() {
  byte digits[] = { 0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b };
  Serial.println("Programming EEPROM");
  Serial.print("Programming ones place. ");
  for (int value = 0; value <= 255; value += 1) {
    writeEEPROM(value, digits[value % 10]);
  }
  Serial.print("Programming tens place. ");
  for (int value = 0; value <= 255; value += 1) {
    writeEEPROM(value + 256, digits[(value / 10) % 10]);
  }
  Serial.print("Programming hundreds place. ");
  for (int value = 0; value <= 255; value += 1) {
    writeEEPROM(value + 512, digits[(value / 100) % 10]);
  }
  Serial.println("Programming sign.");
  for (int value = 0; value <= 255; value += 1) {
    writeEEPROM(value + 768, 0);
  }

  Serial.print("Programming ones place (twos complement). ");
  for (int value = -128; value <= 127; value += 1) {
    writeEEPROM((byte)value + 1024, digits[abs(value) % 10]);
  }
  Serial.print("Programming tens place (twos complement). ");
  for (int value = -128; value <= 127; value += 1) {
    writeEEPROM((byte)value + 1280, digits[abs(value / 10) % 10]);
  }
  Serial.print("Programming hundreds place (twos complement). ");
  for (int value = -128; value <= 127; value += 1) {
    writeEEPROM((byte)value + 1536, digits[abs(value / 100) % 10]);
  }
  Serial.println("Programming sign (twos complement). ");
  for (int value = -128; value <= 127; value += 1) {
    if (value < 0) {
      writeEEPROM((byte)value + 1792, 0x01);
    } else {
      writeEEPROM((byte)value + 1792, 0);
    }
  }
}

/* led-segment code to decimal */
byte convert_to_led_char(byte regel_entry) {
  switch (regel_entry) {
    case 0x7e: return (0);
    case 0x30: return (1);
    case 0x6d: return (2);
    case 0x79: return (3);
    case 0x33: return (4);
    case 0x5b: return (5);
    case 0x5f: return (6);
    case 0x70: return (7);
    case 0x7f: return (8);
    case 0x7b: return (9);
    case 0x0:  return (0); // space
    case 0x1:  return (1); // minus (-) teken
    default:
      {
        char buf[80];
        sprintf(buf, "**** Onbekende regel_entry: %02x", regel_entry);
        Serial.println(buf);
        return(regel_entry);
      }
  }
}

/* print a chunk of addresses */
void print_base(int start_base, int end_base) {
  byte regel[20];
  char buf[80];

  sprintf(buf, "%04d-%04d", start_base, end_base);
  Serial.println(buf);
  Serial.println("             0  1  2  3  4  5  6  7  8  9");
  for (int address = start_base; address <= end_base; address += 10) {
    for (int regel_offset = 0; regel_offset <= 9; regel_offset += 1) {
      if (address + regel_offset <= end_base) {
        regel[regel_offset] = readEEPROM(address + regel_offset);
        regel[regel_offset + 10] = convert_to_led_char(regel[regel_offset]);
      } else {
        regel[regel_offset] = 0;
        regel[regel_offset + 10] = 0;
      }
    }
    sprintf(buf, "%04d-%04d:  %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x - %1x %1x %1x %1x %1x %1x %1x %1x %1x %1x",
            address, address + 9, regel[0], regel[1], regel[2], regel[3], regel[4], regel[5], regel[6], regel[7], regel[8], regel[9], regel[10], regel[11], regel[12], regel[13], regel[14], regel[15], regel[16], regel[17], regel[18], regel[19]);
    Serial.println(buf);
  }
  Serial.println("");
}

/* Read the contents of the EEPROM and print them to the serial monitor. */
void showContents_v2() {
  int start_base;
  int base_step = 256;
  int end_base;

  Serial.println("");
  Serial.println("Reading contents EEPROM");

  Serial.println("1's places.");
  start_base = 0;
  end_base = base_step - 1;
  print_base(start_base, end_base);

  Serial.println("10's places.");
  start_base = start_base + base_step;
  end_base = end_base + base_step;
  print_base(start_base, end_base);

  Serial.println("100's places.");
  start_base = start_base + base_step;
  end_base = end_base + base_step;
  print_base(start_base, end_base);

  Serial.println("sign places.");
  start_base = start_base + base_step;
  end_base = end_base + base_step;
  print_base(start_base, end_base);

  // 2-Complement
  Serial.println("1's places. (2-complement)");
  start_base = start_base + base_step;
  end_base = end_base + base_step;
  print_base(start_base, end_base);

  Serial.println("10's places. (2-complement)");
  start_base = start_base + base_step;
  end_base = end_base + base_step;
  print_base(start_base, end_base);

  Serial.println("100's places. (2-complement)");
  start_base = start_base + base_step;
  end_base = end_base + base_step;
  print_base(start_base, end_base);

  Serial.println("sign places. (2-complement)");
  start_base = start_base + base_step;
  end_base = end_base + base_step;
  print_base(start_base, end_base);
}

void setup() {
  pinMode(SHIFT_DATA, OUTPUT);
  pinMode(SHIFT_CLK, OUTPUT);
  pinMode(SHIFT_LATCH, OUTPUT);
  digitalWrite(WRITE_EN, HIGH);
  pinMode(WRITE_EN, OUTPUT);
  Serial.begin(9600);

  Serial.println();
  Serial.println("-------------------------------------------------------------");
  Serial.println("Bit patterns for the digits 0..9");
  Serial.print("Char    : ");
  Serial.println("        0         1         2         3         4         5         6         7         8         9");
  
  byte digits[] = { 0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b };
  char buf[80];
  Serial.print("Led-code: ");
  for (int offset = 0; offset <= 9; offset += 1) {
    sprintf(buf, "       %02x ", digits[offset]);
    Serial.print(buf);
  }
  Serial.println();
  Serial.print("Binary  :  ");
  for (int offset = 0; offset <= 9; offset += 1) {
    printBinary(digits[offset]);
    Serial.print("  ");
  }
  Serial.println();
  Serial.print("Decimal : ");
  for (int offset = 0; offset <= 9; offset += 1) {
    sprintf(buf, "      %03d ", digits[offset]);
    Serial.print(buf);
  }
  Serial.println();

  programEEPROM();
  showContents_v2();
}

void loop() {}
Serial Monitor Output
-------------------------------------------------------------
Bit patterns for the digits 0..9
Char    :         0         1         2         3         4         5         6         7         8         9
Led-code:        7e        30        6d        79        33        5b        5f        70        7f        7b 
Binary  :  01111110  00110000  01101101  01111001  00110011  01011011  01011111  01110000  01111111  01111011  
Decimal :       126       048       109       121       051       091       095       112       127       123 
Programming EEPROM
Programming ones place. Programming tens place. Programming hundreds place. Programming sign.
Programming ones place (twos complement). Programming tens place (twos complement). Programming hundreds place (twos complement). Programming sign (twos complement). 

Reading contents EEPROM
1's places.
0000-0255
             0  1  2  3  4  5  6  7  8  9
0000-0009:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0010-0019:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0020-0029:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0030-0039:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0040-0049:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0050-0059:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0060-0069:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0070-0079:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0080-0089:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0090-0099:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0100-0109:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0110-0119:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0120-0129:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0130-0139:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0140-0149:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0150-0159:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0160-0169:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0170-0179:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0180-0189:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0190-0199:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0200-0209:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0210-0219:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0220-0229:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0230-0239:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0240-0249:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
0250-0259:  7e 30 6d 79 33 5b 00 00 00 00 - 0 1 2 3 4 5 0 0 0 0

10's places.
0256-0511
             0  1  2  3  4  5  6  7  8  9
0256-0265:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0266-0275:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0276-0285:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0286-0295:  79 79 79 79 79 79 79 79 79 79 - 3 3 3 3 3 3 3 3 3 3
0296-0305:  33 33 33 33 33 33 33 33 33 33 - 4 4 4 4 4 4 4 3 3 3
0306-0315:  5b 5b 5b 5b 5b 5b 5b 5b 5b 5b - 5 5 5 5 5 5 5 5 5 5
0316-0325:  5f 5f 5f 5f 5f 5f 5f 5f 5f 5f - 6 6 6 6 6 6 6 6 6 6
0326-0335:  70 70 70 70 70 70 70 70 70 70 - 7 7 7 7 7 7 7 7 7 7
0336-0345:  7f 7f 7f 7f 7f 7f 7f 7f 7f 7f - 8 8 8 8 8 8 8 8 8 8
0346-0355:  7b 7b 7b 7b 7b 7b 7b 7b 7b 7b - 9 9 9 9 9 9 9 9 9 9
0356-0365:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0366-0375:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0376-0385:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0386-0395:  79 79 79 79 79 79 79 79 79 79 - 3 3 3 3 3 3 3 3 3 3
0396-0405:  33 33 33 33 33 33 33 33 33 33 - 4 4 4 4 4 4 4 4 4 4
0406-0415:  5b 5b 5b 5b 5b 5b 5b 5b 5b 5b - 5 5 5 5 5 5 5 5 5 5
0416-0425:  5f 5f 5f 5f 5f 5f 5f 5f 5f 5f - 6 6 6 6 6 6 6 6 6 6
0426-0435:  70 70 70 70 70 70 70 70 70 70 - 7 7 7 7 7 7 7 7 7 7
0436-0445:  7f 7f 7f 7f 7f 7f 7f 7f 7f 7f - 8 8 8 8 8 8 8 8 8 8
0446-0455:  7b 7b 7b 7b 7b 7b 7b 7b 7b 7b - 9 9 9 9 9 9 9 9 9 9
0456-0465:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0466-0475:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0476-0485:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0486-0495:  79 79 79 79 79 79 79 79 79 79 - 3 3 3 3 3 3 3 3 3 3
0496-0505:  33 33 33 33 33 33 33 33 33 33 - 4 4 4 4 4 4 4 4 4 4
0506-0515:  5b 5b 5b 5b 5b 5b 00 00 00 00 - 5 5 5 5 5 5 0 0 0 0

100's places.
0512-0767
             0  1  2  3  4  5  6  7  8  9
0512-0521:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0522-0531:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0532-0541:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0542-0551:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0552-0561:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0562-0571:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0572-0581:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0582-0591:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0592-0601:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0602-0611:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
0612-0621:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0622-0631:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0632-0641:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0642-0651:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0652-0661:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0662-0671:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0672-0681:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0682-0691:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0692-0701:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0702-0711:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
0712-0721:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0722-0731:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0732-0741:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0742-0751:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0752-0761:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
0762-0771:  6d 6d 6d 6d 6d 6d 00 00 00 00 - 2 2 2 2 2 2 0 0 0 0

sign places.
0768-1023
             0  1  2  3  4  5  6  7  8  9
0768-0777:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0778-0787:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0788-0797:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0798-0807:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0808-0817:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0818-0827:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0828-0837:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0838-0847:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0848-0857:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0858-0867:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0868-0877:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0878-0887:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0888-0897:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0898-0907:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0908-0917:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0918-0927:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0928-0937:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0938-0947:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0948-0957:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0958-0967:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0968-0977:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0978-0987:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0988-0997:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
0998-1007:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1008-1017:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1018-1027:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0

1's places. (2-complement)
1024-1279
             0  1  2  3  4  5  6  7  8  9
1024-1033:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1034-1043:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1044-1053:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1054-1063:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1064-1073:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1074-1083:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1084-1093:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1094-1103:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1104-1113:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1114-1123:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1124-1133:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1134-1143:  7e 30 6d 79 33 5b 5f 70 7f 7b - 0 1 2 3 4 5 6 7 8 9
1144-1153:  7e 30 6d 79 33 5b 5f 70 7f 70 - 0 1 2 3 4 5 6 7 8 7
1154-1163:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1164-1173:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1174-1183:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1184-1193:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1194-1203:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1204-1213:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1214-1223:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1224-1233:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1234-1243:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1244-1253:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1254-1263:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1264-1273:  5f 5b 33 79 6d 30 7e 7b 7f 70 - 6 5 4 3 2 1 0 9 8 7
1274-1283:  5f 5b 33 79 6d 30 00 00 00 00 - 6 5 4 3 2 1 0 0 0 0

10's places. (2-complement)
1280-1535
             0  1  2  3  4  5  6  7  8  9
1280-1289:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1290-1299:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
1300-1309:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
1310-1319:  79 79 79 79 79 79 79 79 79 79 - 3 3 3 3 3 3 3 3 3 3
1320-1329:  33 33 33 33 33 33 33 33 33 33 - 4 4 4 4 4 4 4 4 4 4
1330-1339:  5b 5b 5b 5b 5b 5b 5b 5b 5b 5b - 5 5 5 5 5 5 5 5 5 5
1340-1349:  5f 5f 5f 5f 5f 5f 5f 5f 5f 5f - 6 6 6 6 6 6 6 6 6 6
1350-1359:  70 70 70 70 70 70 70 70 70 70 - 7 7 7 7 7 7 7 7 7 7
1360-1369:  7f 7f 7f 7f 7f 7f 7f 7f 7f 7f - 8 8 8 8 8 8 8 8 8 8
1370-1379:  7b 7b 7b 7b 7b 7b 7b 7b 7b 7b - 9 9 9 9 9 9 9 9 9 9
1380-1389:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1390-1399:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
1400-1409:  6d 6d 6d 6d 6d 6d 6d 6d 6d 6d - 2 2 2 2 2 2 2 2 2 2
1410-1419:  6d 6d 6d 6d 6d 6d 6d 30 30 30 - 2 2 2 2 2 2 2 1 1 1
1420-1429:  30 30 30 30 30 30 30 7e 7e 7e - 1 1 1 1 1 1 1 0 0 0
1430-1439:  7e 7e 7e 7e 7e 7e 7e 7b 7b 7b - 0 0 0 0 0 0 0 9 9 9
1440-1449:  7b 7b 7b 7b 7b 7b 7b 7f 7f 7f - 9 9 9 9 9 9 9 8 8 8
1450-1459:  7f 7f 7f 7f 7f 7f 7f 70 70 70 - 8 8 8 8 8 8 8 7 7 7
1460-1469:  70 70 70 70 70 70 70 5f 5f 5f - 7 7 7 7 7 7 7 6 6 6
1470-1479:  5f 5f 5f 5f 5f 5f 5f 5b 5b 5b - 6 6 6 6 6 6 6 5 5 5
1480-1489:  5b 5b 5b 5b 5b 5b 5b 33 33 33 - 5 5 5 5 5 5 5 4 4 4
1490-1499:  33 33 33 33 33 33 33 79 79 79 - 4 4 4 4 4 4 4 3 3 3
1500-1509:  79 79 79 79 79 79 79 6d 6d 6d - 3 3 3 3 3 3 3 2 2 2
1510-1519:  6d 6d 6d 6d 6d 6d 6d 30 30 30 - 2 2 2 2 2 2 2 1 1 1
1520-1529:  30 30 30 30 30 30 30 7e 7e 7e - 1 1 1 1 1 1 1 0 0 0
1530-1539:  7e 7e 7e 7e 7e 7e 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0

100's places. (2-complement)
1536-1791
             0  1  2  3  4  5  6  7  8  9
1536-1545:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1546-1555:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1556-1565:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1566-1575:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1576-1585:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1586-1595:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1596-1605:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1606-1615:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1616-1625:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1626-1635:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1636-1645:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
1646-1655:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
1656-1665:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
1666-1675:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
1676-1685:  30 30 30 30 30 30 30 30 30 30 - 1 1 1 1 1 1 1 1 1 1
1686-1695:  30 30 30 30 30 30 30 7e 7e 7e - 1 1 1 1 1 1 1 0 0 0
1696-1705:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1706-1715:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1716-1725:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1726-1735:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1736-1745:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1746-1755:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1756-1765:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1766-1775:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1776-1785:  7e 7e 7e 7e 7e 7e 7e 7e 7e 7e - 0 0 0 0 0 0 0 0 0 0
1786-1795:  7e 7e 7e 7e 7e 7e 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0

sign places. (2-complement)
1792-2047
             0  1  2  3  4  5  6  7  8  9
1792-1801:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1802-1811:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1812-1821:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1822-1831:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1832-1841:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1842-1851:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1852-1861:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1862-1871:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1872-1881:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1882-1891:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1892-1901:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1902-1911:  00 00 00 00 00 00 00 00 00 00 - 0 0 0 0 0 0 0 0 0 0
1912-1921:  00 00 00 00 00 00 00 00 01 01 - 0 0 0 0 0 0 0 0 1 1
1922-1931:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
1932-1941:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
1942-1951:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
1952-1961:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
1962-1971:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
1972-1981:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
1982-1991:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
1992-2001:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
2002-2011:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
2012-2021:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
2022-2031:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
2032-2041:  01 01 01 01 01 01 01 01 01 01 - 1 1 1 1 1 1 1 1 1 1
2042-2051:  01 01 01 01 01 01 00 00 00 00 - 1 1 1 1 1 1 0 0 0 0

LED Display

This table compares two foundational methods for representing negative numbers in binary logic:
1's Complement and 2's Complement.
In both systems, the leftmost bit (the Sign Bit) dictates the sign of the number: 0 means positive, and 1 means negative.

1's Complement (The Legacy Method): To make a number negative, you simply invert all the bits (turn 0s into 1s, and 1s into 0s). The Flaw: Look at the highlighted row. If you invert 0000 (+0), you get 1111 (-0). This means the computer has to process two completely different binary codes for the exact same value (zero), which requires extra logic gates and slows down calculations.

2's Complement (The Modern Standard): To make a number negative, you invert all the bits and then add 1.
The Fix: If you invert 0000 to 1111 and add 1, the binary counter rolls over back to 0000 (the 5th bit falls off in a 4-bit system). As shown in the right column, 2's complement elegantly eliminates the "-0" anomaly, leaving the computer with one unified, mathematically sound representation for zero.

Decimal 1's Complement 2's Complement
+5 0101 0101
+4 0100 0100
+3 0011 0011
+2 0010 0010
+1 0001 0001
0 0000 0000
-0 1111
-1 1110 1111
-2 1101 1110
-3 1100 1101
-4 1011 1100
-5 1010 1011
X Red bit indicates the Sign Bit (0 = Positive, 1 = Negative).
v1.05 - gs6.06

THE GHOST OF NEGATIVE ZERO

Discover how the Apollo 11 spacecraft handled the 1's complement anomaly, and how John von Neumann solved it forever.
THE ANCIENT ROOTS
The underlying mathematical principle of complements wasn't actually invented for digital computers. The "method of complements" (specifically 10's and 9's complement) had been used for a long time in mechanical calculators and decimal adding machines (like the Pascaline, invented by Blaise Pascal in the 1600s). It allowed these mechanical gears to perform subtraction simply by running the addition mechanism forward with a complement (a 'mirror' number that turns subtraction into addition), rather than having to build complex reversing gears.
THE APOLLO 11 QUIRK
The Apollo Guidance Computer (AGC) that landed Neil Armstrong on the moon in 1969 did not use the modern 2's Complement system. To save hardware complexity, NASA engineers built the AGC utilizing 1's Complement arithmetic.
Two Kinds of Nothing This meant the AGC's software had to constantly deal with the "-0" anomaly. The computer possessed two entirely distinct binary states for the number zero: 000000000000000 (+0) and 111111111111111 (-0). Software Acrobatics If the guidance software compared +0 and -0 directly, the computer would rigidly conclude they were not equal. NASA's programmers had to code special mathematical safeguards into the lunar descent logic to ensure a rogue "-0" wouldn't cause the spacecraft to crash or miscalculate its trajectory.
THE VON NEUMANN MASTERSTROKE
The specific 2's Complement system for binary electronic computers was introduced by the brilliant mathematician John von Neumann in 1945. He formally proposed it in his legendary foundational paper, "First Draft of a Report on the EDVAC".
Simplifying the Hardware Von Neumann explicitly argued that utilizing the 2's complement method would massively simplify the hardware needed for the computer's Arithmetic Logic Unit (ALU). The machine would no longer need separate, complex circuitry to handle subtraction. The Global Standard Because it elegantly eliminated the "-0" anomaly and streamlined calculations, von Neumann's 1945 proposal became the undisputed standard for integer mathematics in almost all modern microprocessors.
THE MODERN SURVIVOR
While integers strictly use 2's complement, modern computers handle decimal numbers using the IEEE 754 standard. This standard utilizes a dedicated sign bit separate from the number itself—almost exactly like the old 1's Complement logic!
Your CPU Still Has -0 Because of this architectural choice, your brand new 64-bit smartphone or gaming PC still has a hardwired representation for -0.0. In advanced programming and scientific calculations, dividing by +0.0 yields positive infinity, while dividing by -0.0 yields negative infinity.

To be continued...