# Josef “Jeff” Sipek

## Count, Compare, Skip

I just remembered a fun fact about the Apollo Guidance Computer (AGC).

A few years ago, I was tinkering with emulating one. It kind of worked, but that’s not important.

The AGC was an accumulator architecture, with 15-bit words (the accumulator (A) and few other “registers” were 16 bits), and 1’s complement arithmetic.

Now, the fun fact. There was an instruction called ’CCS’. It took an address, loaded the accumulator with the value at the address, and then performed a 4-way branch. The easiest way to explain it is with a some code that demonstrates what happened with some C-style pseudocode (A = accumulator, Z = program counter):

```Z = Z + 1;
A = mem[operand];

switch(A) {
case POSITIVE:
A = A - 1;
/* Z is already incremented */
break;
case POS_ZERO:
/* A is already a zero */
Z = Z + 1;
break;
case NEGATIVE:
A = (~A) - 1;
Z = Z + 2;
break;
case NEG_ZERO:
/* A is already a zero */
Z = Z + 3;
break;
}
```

So, in a program, you could see something like:

```CCS addr1