Settings

Theme

Writing a lunar lander game for an actual lunar lander

cowlark.com

151 points by david-given 6 years ago · 17 comments

Reader

azalemeth 6 years ago

Wow. Seriously impressive -- both to see the limitations that smart people worked within while taking mankind off this rock, but also hats off to some excellent nerdery.

>"Division. Arrgh. The AGC does have hardware division (and multiplication), but it’s strictly limited to only being able to compute x/y when |x|>|y|. Anything else, you get garbage, including in the y=x case. This hit me several times and trying to deal with all the sign issues, combined with the 1s-complement sign issues above, was really painful."

Not being expert in slightly outdated processor architectures (1s compliment!), might someone more expert than I be able to tell me _why_ this is the case and was a good design decision? It seems like a potential way for unexpected sensor data to bite you in the arse...

  • Thorrez 6 years ago

    Complete guess, but I would say they weren't just optimizing for ease of creating software, they were also optimizing for ease of creating the hardware.

    If you're creating hardware that's only going to be used a few times, it's probably not worth it to spend a lot of effort into giving it every feature that programmers want.

    • djmips 6 years ago

      I think you're on the right track but the motivation would be more for a smaller, lighter mass computer and not so much the one off nature as they made many hardware changes as requirements changed.

    • djmips 6 years ago

      Still I feel the 1s compliment was perhaps more of a choice based around the familiarity of the designer, Eldon Hall. It was a style of the times and 2s compliment had not yet become the dominant standard.

    • david-givenOP 6 years ago

      They did add instructions when the programmers asked for them --- such as the famous EDRUPT instruction (whose use is still a bit of a mystery).

  • bArray 6 years ago

    > it’s strictly limited to only being able to compute x/y when |x|>|y|. Anything else, you get garbage, including in the y=x

    I think it's literally just to keep the math circuit logic very simple, it'll be identical to MOD (just need to look at the remainder register) and |x| <= |y| will either require some hackery to convert it (with an appropriate test) or the machine having some idea of non-integer numbers.

    For implementation of division, you could have the circuit equivalence of:

        uint div(x, y){
          uint t = x; //temporary (don't want to touch x)
          uint c = 0; //counter
          while(t >= y){
            t = t - y;
            c = c + 1;
          }
          return c; //remainder is in t
        }
    
    Not sure about the x == y case though.

    Of course there would be no checking, hence the garbage out when you misuse it. Your checking would be done manually.

    [1] https://en.wikipedia.org/wiki/Ones%27_complement

  • eftychis 6 years ago

    I have the same question. My first guess would be it was due to the reality of using the limited space and design process. Note the mention in the article about asynchronous logic and hand-wired gates. It probably seemed a better trade-off to keep the circuit as simple as possible if it would work fine and out of the box for a majority of the cases.

david-givenOP 6 years ago

Hello, author here.

It's a surprisingly modern-ish system, in many ways, and surprisingly weird in lots of other ways. One thing which really surprised me was a complete lack of pointer support: I managed to bodge the look-up-table instruction (which evaluates its argument and adds the result to the next instruction to be executed) to do pointer dereferences instead (INDEX ptr; TC 0). And, luckily, I found a way to make the assembler emit an address as a literal value, which it really didn't want to do.

It's a shame the address space is so small (only 12 bits!) or you could totally port real software to this...

  • david-givenOP 6 years ago

    I've updated the post on cowlark.com which a decent writeup on the machine's more interesting quirks.

yummybear 6 years ago

Hm - I keep getting a 1202 program alert when hovering near the surface.

hanniabu 6 years ago

I think that's the longest non-loop Youtube video I've ever seen.

djmips 6 years ago

I thought about this myself and it's really cool to see someone follow through on such a whimsical project. One consideration is that the is already a great lunar lander game for this system!

piadodjanho 6 years ago

Does anyone know of any FPGA implementation?

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection