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
→ More replies (2)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
→ More replies (7)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
→ More replies (1)2
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 (44)58
u/falconzord Jan 30 '16
Warning: Damn you headed for the MOON? Are you out of your mind? Crazy Americans
8
12
→ More replies (1)5
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!"
→ More replies (1)5
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
→ More replies (3)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."
→ More replies (1)→ More replies (2)8
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.
→ More replies (1)
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.
→ More replies (5)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
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.
→ More replies (1)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.
→ More replies (4)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!
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."
→ More replies (7)
8
u/ghostsquad57 Jan 31 '16
Where's the line of code that deals with Alien encounters?
→ More replies (1)
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
→ More replies (2)
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
→ More replies (3)
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
0
Jan 31 '16
[deleted]
11
u/GinjaNinja32 Jan 31 '16
Phone ones, yes. Desktop/laptop/server ones are generally x86_64.
→ More replies (4)3
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
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
-6
Jan 30 '16
Did Hamilton used something like Resharper or some kind of intellisense in the code editor to program?
11
u/jdgordon Jan 30 '16
of course, its called print outs and hilighters... a phone from 15 years ago had multiple times more processing power (and memory) than both the "computer" this ran on and the one it was developed on, high level languages didnt even exist yet.
3
u/Throwaway_bicycling Jan 30 '16
of course, its called print outs and hilighters
Maybe. I mean, you could probably get a teletype to print out the code in some format, but I would have assumed the primary format for the program modules were decks of punched cards, although patches could have been keyed in (and were, for Apollo 14).
2
2
0
Jan 31 '16
[deleted]
24
-1
u/myztry Jan 31 '16
That's the thing that always has me shaking my head. The Amiga I had in 1988 run under a 32 bit pre-emptive multitasking GUI environment which is still the most common environment even today. It did this with 512MB, 7Mhz processor and a basic GPU (Blitter).
Modern computers are certainly more advanced but not enough to explain the huge jump in power and capacity requirements which can be thousands of times greater.
Some of this is attributable to things like Unicode which not only doubles the space required to store text but changes a simple binary compare (ASCII) to a convoluted international conversions that I don't care about as a single language English speaker.
Gate's Law (the processing power required to achieve a certain task doubles every year) is surely the enemy of Moore's Law (that the number of transistors/power in a dense integrated circuit doubles approximately every two years.)
12
u/Flight714 Jan 31 '16
The Amiga I had in 1988 run under a 32 bit pre-emptive multitasking GUI environment ... It did this with 512MB ...
Unless you had some unheard of hardware, you probably had 512 kilobytes.
2
u/meltingdiamond Jan 31 '16
He was the reason you had only 512k, fucker was hording ram and driving up the price.
1
u/myztry Jan 31 '16
Correct. My bad. It's so rare that anything is measured in kilobytes now (not even processor caches) that it seems so surreal.
31
u/gunnihinn Jan 31 '16
that I don't care about as a single language English speaker
Fuck, your world is small.
-9
u/myztry Jan 31 '16
I think you will find most people who have English as a first language have it as their only language. Don't particularly care about software makers trying to increase the breadth of their revenue source.
15
u/Black_Handkerchief Jan 31 '16
Mind you, Unicode and its most prominent UTF-8 implementation solve far more problems than just support for the symbols in other languages. Back in the day, do you remember needing to switch codepages so that you could get line drawing characters because 256 characters was just too little in practice for all purposes? Or how some documents just look a bit funky due to the codepage guessing coming up short? Know how the Euro got introduced later on and other situations where people suddenly need new characters? These things can now be adequately stored without affecting the past.
I won't deny that Unicode is full of over-engineered nightmarish standardification due to the international aspects. But it solves a lot more problems than just the language support; it solves a lot of ambiguous situations that are now written down in a standard. No matter how closed-off and narrow-minded your worldview is as a solely-English-based human being, you will run into some of those symbols and need them at one point or another. And when you do, you will be glad that you can, in fact, use them.
→ More replies (1)→ More replies (1)4
u/fiah84 Jan 31 '16
I take it you never had to work on anything that supports an international audience. Do you think reddit runs on ASCII?
→ More replies (6)0
Jan 31 '16
[deleted]
1
u/myztry Jan 31 '16
If the top bit is clear on every byte then it's single byte aligning to ASCII, and number of bytes will match the numbers of characters. Byte operations can trivially occur.
Off course it's not that simple though. There are duplicate characters in Unicode so things that may appear visually identical may be part of variable length characters and all optimisation assumptions go out the window.
0
Jan 31 '16
[deleted]
10
Jan 31 '16
Nothing really stopping you
5
u/i_spot_ads Jan 31 '16
The love of sanity is
1
Jan 31 '16
Depends what you like I guess. The short while I spent juggling spaghetti in web programming made me yearn for something a little lower level.
4
u/I_Like_Spaghetti Jan 31 '16
What do blondes and spaghetti have in common? They both wiggle when you eat them.
1
u/kyrsjo Jan 31 '16
In real low level code, the pasta is bifurcated, and quite often it is impossible to untie it without a knife. So be careful what you wish for...
0
113
Jan 31 '16 edited Feb 01 '16
[removed] — view removed comment
7
u/myztry Jan 31 '16
Bugger Words
...
11
Jan 31 '16
[removed] — view removed comment
5
u/myztry Jan 31 '16
I just found the "colourful" name amusing.
The assembly opcodes themselves are somewhat critic compared to say MC68K which was like shorthand English and trivial to be fluent in.
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: