Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That looks very short. Is that really the full implementation? Is there any annotated version of it?


AGC assembler uses unusual mnemonics, so it can be difficult to understand for someone who doesn't know the architecture.

The CPU has onle accumulator which instructions act on. The argument is normally an address. The relevant instructions for this code snippet is:

AD - Add the value pointed to by the argument to the accumulator

TS - Transfer to storage. Write the accumulator to the argument

TCF - Transfer control to fixed memory. Jumps to an instruction in fixed storage

DOUBLE - Assembler macro compiling to AD A. I.e. double the accumulator.

XCH - This exchanges the value in the accumulator with the argument

INDEX - Adjust the address used in the next instruction by the argument

COM - Complements the accumulator. Note that the AGC uses one's complement arithmetic, so this negates the value.

EXTEND - Indicate that the next instruction is an extended instruction

MP - Multiply the accumulator with the argument

The final instruction is TS Q which jumps to the location stored in the Q register. This is the return address which is updated by the TS instruction. In other words, TS can be used both as a regular jump as well as being used as a function call, depending on what the destination does with the Q register.

I hope this helps you analyse the code further. I haven't spent much time looking at the code itself, so I am not going to attempt an analysis right now.


Also note that the constants (HALF, LIMITS, C3/2, C5/2, C1/2, etc) are defined in another source file: https://raw.githubusercontent.com/chrislgarry/Apollo-11/a135...


Thanks fur the details! What kind of format does SINGLE PRECISION refer to here?


Single precision is a 15-bit fixed point number in the range between -1 and 1. Apparently in most cases this was enough for moon flights. There was also double and triple precision that were used sometimes.

Of course, in many places in the code you need values outside of this range and the actual number represented is scaled by some factor. However, the CPU has no internal representation of the scale factor (i.e. the exponent bits in a floating point number) so the programmer had to manually manage this.

I can strongly recommend this book, if you're interested in the AGC: http://www.apolloguidancecomputer.com/


Thanks, I was already searching for what the opcodes meant.


Fermat's Library is an annotation platform, so there are annotations on the linked version - click on the circles (or rectangles, depending on whether the side panel is open) on either side of the document to see the annotations.


Ah nice. Although a line by line walkthrough would be nicer.


This is how big the full printout looked compared to the author:

https://news.mit.edu/2016/scene-at-mit-margaret-hamilton-apo...


Each one of those bound 'books' is a complete full printout. That photo shows a bunch of different revisions / programs stacked up. Here's one complete listing in a book printout being discussed by one of the original authors Don Eyles. https://www.youtube.com/watch?v=H0ITFbDuJz0

Scan of Luminary - Lunar Module source code https://archive.org/details/Luminary99001J2k60/page/n979/mod...


If you follow the link to github, there is much more.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: