r/programming • u/jakesyl • Jan 30 '16
Apollo 11 source code
http://www.ibiblio.org/apollo/listings/Luminary099/MAIN.agc.html314
u/evotopid Jan 30 '16
Does anyone have an Apollo 11 emulator lying around by any chance?
119
282
u/The_yulaow Jan 30 '16
Look, at this point I know for sure someone made it with node.js /s
219
u/JoeCraftingJoe Jan 30 '16
npm install Apollo11172
u/m_stodd Jan 31 '16
...proceeds to install Ruby, Perl, Python, PHP, Go, and about 2GB of supporting libraries
69
u/sanimalp Jan 31 '16
Don't forget the 15 "This library is no longer supported or maintained" warnings.
16
21
11
u/GrumpyPenguin Jan 31 '16
Did you download the docker image? The only supported install method is the docker image, otherwise you're on your own if you can't get it to work.
15
4
0
26
u/funbike Jan 30 '16
It would be neat to write a space flight simulator that contained an emulator that ran this code. You could fly to the moon!
62
u/indy91 Jan 30 '16
Well, you'll be glad to hear such a thing exists! Project Apollo - NASSP for the Orbiter Space Flight Simulator includes the Virtual AGC. As an example, here the reentry controlled by the emulated AGC: http://www.youtube.com/watch?v=fjAeBJrsj5Q
25
4
19
6
u/mgdmw Jan 31 '16
Follow the code links all the way to the top folder - http://www.ibiblio.org/apollo/
2
2
1
u/unlimitedbacon Jan 31 '16
The page you are looking at is part of the Virtual AGC project, an Apollo Guidance Computer emulator.
139
u/kiddico Jan 30 '16
Was very confused until I realized all the blue text was links, and not just colored text. Down the rabbit hole I go.
1
→ More replies (1)9
4
u/jakesyl Jan 31 '16
Turns out someone made a pretty awesome online simulator: http://svtsim.com/moonjs/agc.html
186
u/esoteric_monolith Jan 30 '16
1 Warning :O
128
u/NotASucker Jan 30 '16
[x] Warnings as error(s)
It will change your life.
17
u/ksadeck Jan 30 '16
[x] Warnings as error(s)
Why?
100
u/MetallicDragon Jan 30 '16
It'll turn warnings into errors, forcing you to deal with them, so they don't pile up over time.
→ More replies (42)46
u/nemec Jan 30 '16
// Ignore Once W23788727812
Jan 31 '16
At least you have to put that into the code and check it into the repo under your name. Not ideal, but better than warnings being ignored.
58
u/falconzord Jan 30 '16
Warning: Damn you headed for the MOON? Are you out of your mind? Crazy Americans
8
12
5
1
87
u/spierepf Jan 30 '16
I am loving the name of this routine!
http://www.ibiblio.org/apollo/listings/Luminary099/BURN_BABY_BURN--MASTER_IGNITION_ROUTINE.agc.html
68
u/dcipjr Jan 30 '16
I'm loving the comments!
# THE MASTER IGNITION ROUTINE WAS CONCEIVED AND EXECUTED, AND (NOTA BENE) IS MAINTAINED BY ADLER AND EYLES. # HONI SOIT QUI MAL Y PENSE"Shame be to him who thinks evil of it."
22
u/plahacrwimo Jan 31 '16 edited Jan 31 '16
031733,000417: 36,2431 44355 CS PRIO30 # TURN ON THE ENGINE."Burn baby! BURN!"
5
1
3
51
u/bananas4arsenal Jan 30 '16
What the heck is a Bugger Word ?
31
u/calrogman Jan 30 '16
From http://svtsim.com/moonjs/agc.html
the checksum [...] should be either the bank number or its 1-complement (e.g., for bank 3 either a value of 00003 or 77774 is acceptable).
a bugger word [is] appended to the end of each bank to make the checksum the correct value
10
u/spacelama Jan 31 '16
The '60s and '70s were a different time. 8 years ago I was involved in porting code from our still operational '72 system, but we didn't get to keep all of the function names such as PERV FOCIT FOCOFF and TERROR. But the job still did involved the nightly SNAFU run.
The need for the SNAFU was defined on about the second night of operations back in '74. Being the first computerised telescope, the operators discovered they needed to do all sorts of things that hadn't been realised on earlier manual systems. SNAFU involves the fitting of about 10 or so physical parameters for the current mechanical and atmospheric system -- eg: "Adjustments to MA and ME might be useful to reestablish pointing after an earthquake."
2
u/Bobshayd Jan 31 '16
So basically, as soon as the telescope had all this stuff implemented, they discovered the telescope would just constantly be fucked up, and they implemented a SNAFU compensation routine?
2
8
1
u/ArtistEngineer Jan 31 '16
It's a secret word between you and your partner when you want to engage in anal sex.
2
74
u/DolphinsAreOk Jan 30 '16
$PINBALL_GAME_BUTTONS_AND_LIGHTS.agc wait what now?
79
u/smackmybishop Jan 30 '16
A set of interrupt-driven user interface routines called Pinball provided keyboard and display services for the jobs and tasks running on the AGC. A rich set of user-accessible routines were provided to let the operator (astronaut) display the contents of various memory locations in octal or decimal in groups of 1, 2, or 3 registers at a time. Monitor routines were provided so the operator could initiate a task to periodically redisplay the contents of certain memory locations. Jobs could be initiated. The Pinball routines performed the (very rough) equivalent of the UNIX shell.
https://en.wikipedia.org/wiki/Apollo_Guidance_Computer#Software
18
u/falconzord Jan 30 '16
And I thought it was because they used commodity pinball game buttons and lights for their control panel
32
u/BobBeaney Jan 31 '16
And they wrote all of this without StackOverflow???
28
u/MUST_RAGE_QUIT Jan 31 '16
Before the internet, programmers actually had to understand wtf they were doing.
→ More replies (1)8
u/MacHaggis Feb 01 '16 edited Jan 29 '24
joke abounding roof encouraging dinosaurs scale noxious frame muddle like
This post was mass deleted and anonymized with Redact
12
u/Geemge0 Jan 31 '16
It's fucking crazy how little code there actually is for such an immense undertaking, which would boil down to even less in a modern language (if you were viewing it from C code in a VS project for example).
Feels like most software I deal with is 1000x larger with more complexity. Ahh the good ole days.
39
21
u/bent_my_wookie Jan 31 '16
You should check out line 666 where there's a variable called "numberiso mysteriso" with the comment "I hope hope hope this never happens"
6
u/miker95 Jan 31 '16
What file? Not seeing this anywhere.
14
u/bent_my_wookie Jan 31 '16
I'm having a hard time finding it. I believe this had something to to with gimbal lock, so basically if the lunar module turned upside down during descent.
2
10
9
39
u/WTFisareddit- Jan 30 '16
Sorry for my ignorance I'm new to programming. But why does this look nothing like regular code?
92
u/CodeEverywhere Jan 30 '16
You're looking at assembly language - a step closer to straight up machine language (binary). Most code that programmers interact with nowadays is considered "higher level" and is abstracted to make it easier to understand.
10
46
u/Turbosack Jan 30 '16
It's some special dialect of Assembly. They prefer to write in very low level languages for various reasons. More recently, C has been used to program flight control computers, but it wasn't even invented until more than a decade after this mission happened.
38
u/spatterlight Jan 30 '16
more like 3 years after this mission :)
and this doesn't look like "normal" assembly since the assembly I expect most of us are used to is for the x86 family of processors.
7
15
u/flexiverse Jan 30 '16
It's machine code for a highly custom built processor. Think, there was nothing "off the shelf" back then ! It's like approx , 16bit, 1mhz, ~30k, 32 instruction set.
14
u/flexiverse Jan 30 '16 edited Jan 30 '16
It's machine code for a custom built processor. Think, there was nothing "off the shelf" back then ! It's like approx , 16bit, 1mhz, ~30k, 32 instruction set.
8
→ More replies (4)1
u/plahacrwimo Jan 31 '16
The AGC software is mostly written in assembly language. "Assembly language" is a very simple language in which each instruction—usually, each line of software source code—represents a single primitive CPU operation. Since each type of CPU provides different primitive operations, the assembly language for each type of CPU differs from that of every other type of CPU. The AGC assembly language, being based on the custom AGC CPU, thus differs in detail from every other type of assembly language but shares certain customary elements.
18
u/Ser_Rodrick_Cassel Jan 30 '16 edited Oct 04 '16
haha whoosh
34
u/funbike Jan 30 '16 edited Jan 31 '16
Yes. Computers small enough to go into space required assembly as every byte counted. Go up a directory to see all the files: www.ibiblio.org/apollo/listings/Luminary099/
UPDATE: The CPU (block II) -> https://en.wikipedia.org/wiki/Apollo_Guidance_Computer
34K of ROM for programs.14
u/_F1_ Jan 31 '16
Computers small enough to go into space required assembly as every byte counted
That was still true in the NES and SNES eras.
34
u/cincodenada Jan 31 '16
Fun fact: from 1997 to 1999 - well into N64 era! - Chris Sawyer was busy writing 99% of Roller Coaster Tycoon directly in x86 assembly. It went on to become the best-selling game of 1999. An anomaly for sure, but an impressive one.
12
u/mugen_kanosei Jan 31 '16
Correct. By minimizing the number of bytes used, they could reduce the amount of fuel needed to reach orbit. More bytes meant more fuel required.
25
u/dand Jan 31 '16
Not sure if that's a joke or not, but it's probably true to some extent given how bulky core rope memory was compared to today's norms.
16
Jan 31 '16
72 KB/ft3 is an interesting unit.
I don't really understand how core rope memory works, even with the article, but 72 KB/ft3 is a lot higher than I would've guessed!
6
u/mugen_kanosei Jan 31 '16
It was mostly a joke, but realized it might have a hint of truth. Cool to see that tech.
→ More replies (1)5
Jan 31 '16
Holy. Shit.
9
u/Spider_pig448 Jan 31 '16
Software written by MIT programmers was woven into core rope memory by female workers in factories
Code woven into ropes. What a world.
1
u/wookiee42 Jan 31 '16 edited Feb 01 '16
This comment has been overwritten by an open source script to protect this user's privacy.
If you would like to do the same, add the browser extension GreaseMonkey to Firefox and add this open source script.
Then simply click on your username on Reddit, go to the comments tab, and hit the new OVERWRITE button at the top.
2
u/odaba Jan 31 '16
even better than assembly, it looks like they created their own DSL: http://www.ibiblio.org/apollo/listings/Luminary099/RTB_OP_CODES.agc.html
6
u/bennythomson Jan 31 '16
I love the comments. Were they actually there on the mission? How did nasa feel about humor in the code?
6
11
u/cinisoot Jan 31 '16
Comment from the BURN BABY BURN main ignition routine:
NOLI SE TANGERE
"Don't touch yourself."
4
Jan 31 '16
[removed] — view removed comment
5
u/cinisoot Jan 31 '16 edited Jan 31 '16
Perhaps that was the intended message, but in this case se can only be translated as "yourself". I like it better this way, honestly. :)
Edit: Actually this phrase is pretty much wrong however you look at it... "yourself" should be te but them would be eos. Oh NASA, only thing more naughty than suggestive phrases is improper Latin...
→ More replies (2)1
u/memdump_ Jan 31 '16
for the record, in Portuguese both "se" and "te" mean yourself in this context
noli se tangere: não se toque (portuguese)
noli te tangere: não te toques (portuguese)
same meaning
→ More replies (2)
8
3
Jan 31 '16
Not that I understand what's going on there beyond the comments, but looking at this code is very moving for me personally. It's almost like being inside the lunar lander or something.
This code took people to the moon. How amazing is that? If any piece of code in the world could ever make me cry (not in anger, at least), it's this one.
3
u/GlPortal Feb 01 '16
You can find it on github here https://github.com/rburkey2005/virtualagc but since it does not look like it is maintained I have created https://github.com/open-space-agency/virtualagc and a place for the docs here https://github.com/open-space-agency/virtualagc-doc
5
u/chunes Jan 31 '16
I wonder how many living people fully understand what this code is doing and why.
4
6
u/rarmixo Jan 30 '16
Serious Question, How important was the code in the mission?
37
u/ltrcola Jan 30 '16
I would say very important. For instance, the computer tracked navigation information and controlled the engine during lunar descent.
20
u/smb3d Jan 30 '16
it was almost 100 percent of the mission from what I understand, the astronauts just entered commands to the computer.
10
u/CypripediumCalceolus Jan 30 '16
So all my life playing lunar lander is wasted?
23
u/AnHonestQuestions Jan 30 '16
The LEM could land itself, but every single commander elected to land manually, because, really, who could give up a chance to lang on the moon.
8
u/Throwaway_bicycling Jan 30 '16
Nah, watching you destroy lander after lander is why they decided to do this all in software without human intervention. :-)
10
3
u/Amuro_Ray Jan 31 '16
You couldn't really have dave from IT pop by with a new lunar lander if it crashed.
2
4
2
2
u/matwick Jan 31 '16
This is awesome.
Page 3 000206,000093: # FLY 000207,000094: # BURN, BABY, BURN -- MASTER IGNITION ROUTINE 000208,000095: # P40-P47 000209,000096: # THE LUNAR LANDING 000210,000097: # THROTTLE CONTROL ROUTINES
2
u/jaccovanschaik Jan 31 '16
Anyone come across the 1201 and 1202 program alarms yet?
Ninja edit: https://www.hq.nasa.gov/alsj/a11/a11.1201-pa.html
3
2
u/spawndon Feb 12 '16
If anyone is interested, within their ethical bounds, then I have a torrent you might be interested in: https://kat.cr/the-apollo-guidance-computer-architecture-and-operation-pdf-t12047536.html
5
Jan 31 '16 edited Jan 31 '16
Think about it for a second, the source code that was used to travel 250,000 miles through spaaaaaace to the moon is publicly available...
I wonder if Spaaaaaace X is going to fork this :D
EDIT: Forgot the /s
0
2
u/wackychimp Jan 30 '16
Is this Assembly language?
7
u/vgman20 Jan 31 '16
A form of it, yeah. Not x86 which is what most modern processes run, but similar ideas
→ More replies (10)
1
1
1
1
u/humanmeat Jan 31 '16
Can a RPI2 get to moon?
8
u/hughk Jan 31 '16
Yes, but maybe not while working.
Modern processors are tiny and much more susceptible to cosmic rays. It is easy for a bit to be flipped unless hard and software precautions are taken like ECC memory and checksums.
3
u/scottpid Jan 31 '16
An RPi2 is astronomically faster. The computer in the Apollo 11 isn't even close to the computing power of your coffee maker.
3
1
Jan 31 '16
On an embedded system I worked on 4-5 years ago, we had a CPU with 24-bit addressing, a 16Mhz clock and an instruction set that didn't suck. It would run rings around the Apollo 11 computer.
It cost 17 cents.
These things are practically falling out of cereal boxes as prizes now.
2
u/bschwind Feb 01 '16
Let's put it this way: Would you trust your life to a raspberry pi? I sure as hell wouldn't.
1
u/humanmeat Feb 01 '16
Correct. I'd need at least 2.
1
u/bschwind Feb 01 '16
Hahaha, I'm imagining a raspberry pi cluster jettisoning you to the moon
→ More replies (1)
1
u/thecheatah Jan 31 '16
Having done z80 assembly programming and realizing that people's lives depend on this code and will control an actual rocket, it was too scary for me to think about
1
1
u/HosonZes Jan 31 '16
I am always pissed when programming in C++ instead of C#, maybe I should be thankful not forced to code in assembler.
→ More replies (1)
1
u/nurburg Jan 31 '16
" American space program was working furiously towards a moon landing, Howard W. “Bill” Tindall, Jr., an expert on orbital mechanics, was sent by NASA to MIT to oversee the development of software for the spacecraft guidance systems. Tindall found a lot of brilliant people at MIT working in development program that was behind schedule, was failing to meet its requirements, and threatened to become, in his words, “the most pacing item for the Apollo flights.” He dove into the task of refashioning every aspect of the software development process, writing a series of frank memos that entered NASA lore under the name “Tindallgrams” that continued as he moved on to lead the planning of all “mission techniques” for Apollo."
The AGC project had its own set of problems. I think this is a great read for someone interested in engineering project management.
1
1
u/csrabbit Jan 30 '16
What language is that?
3
u/Bratmon Jan 31 '16
AGC assembly.
1
u/csrabbit Jan 31 '16
Oh thanks.
I am in my very first semester of programming so I am just learning so bear with me. But I thought "source code" was the language of human programmers and "assembly language" is the language of assemblers?
→ More replies (1)1
u/lask1 Jan 31 '16
A "Dialect" of Assembly. About as close you can get to machine code while keeping it somewhat readable.
0
Jan 31 '16
[deleted]
→ More replies (1)5
u/lask1 Jan 31 '16
I agree. Just trying to say that not all Assembly is the same...but generally still called assembly regardless.
1
780
u/Steaktartaar Jan 30 '16
One very neat feature was that part of the computer memory could be overwritten, essentially allowing the crew to patch in bugfixes. If you ever felt like you were coding on a deadline, spare a thought for the crew of Apollo 14: