I am interested in looking at the source code of any program that was written in Assembly just about when the Assembly language was invented.

If anyone have a source code for such a program, please post it and say what year it was written in and on what computer it run on.

  • 5
    Except for "when Assembly language was invented" (because that happened gradually, in many variations, and not at a single point in time), it's perfectly clear what he is asking, so I don't understand the votes to close this questions. – dirkt May 9 '17 at 6:23
  • 1
    Welcome to Retrocomputing Stack Exchange. This question has quite a lot of possible answers; we prefer questions that can be answered fully here. Don't worry; you can always edit your question. Please read the tour to familiarise yourself with the site. – wizzwizz4 May 9 '17 at 6:24
  • 6
    This is very vague. Which assembly language for a start? Are you after 1940s/50s mainframes or 70s micros or anything in between. Besides, most code that people will have will be subject to copyright and probably shouldn't be posted. – Chenmunka May 9 '17 at 7:34

In case you want to look into interesting Assembly sources, I'd recommend to check the source code for the Appollo Guidance Computer. The sources (assembly code written in the early sixties for the first IC-based computer and discontinued 1975) have just recently be released into the open and can be analyzed on Google code.

In case you're missing real retro hardware to run the code on (like a lunar lander, Apollo spaceship or the US Navy's DSRV), there's also an AGC emulator available along the same pages :).

  • AGC is far from the first computer that used assembly language though :) – rackandboneman May 19 '17 at 17:30
  • Google Code has been dead for a while now. I found the AGC source code on github. – isanae Nov 17 '17 at 22:10

If you want to go all the way back, the first stored-program electronic computer was the Manchester Small-Scale Experimental Machine (aka Baby). Featuring 32 words of storage and seven instructions, its first program was run on 21st June 1948. The program successfully found the highest factor of 262144 to be 131072, and took almost an hour to do so.

The Baby could only subtract, and its one conditional instruction could only skip the next instruction if the accumulator was negative. Nonetheless, several programs were written for it.

Here's that first program, transcribed into more readable opcodes than were used at the time, from Joseph Adams' Baby Emulator distribution:

; This is the original factor finding program that was run on the SSEM in Manchester aka "the Baby"
; Run with: gobaby -t -l 27 -p=f examples/factor.asm [run-time ~ 15ms]
; Keep in mind, exection on the original machine took nearly an hour, same goes for the replica.

00  JMP  0
; Initialization
01  LDN 24          ; Loads to Acc -(no. to be factored - 1) = initial -b test value
02  STO 26          ; Stores the initial –b test value in line 26
03  LDN 26          ; Loads initial +b value into Acc
04  STO 27          ; Stores the initial +b test value in line 27

; Do subtractions using the current b test value, check sign of difference, jump back if 0 is not passed yet
05  LDN 23          ; Loads in no. to be factored to Acc.
06  SUB 27          ; Subtracts the latest +b test value from the current Acc value
07  CMP             ; Jumps to execute line 9 if Acc is now negative.
08  JRP 20          ; Loops back to execute from line 6 again if Acc value not yet negative

; Form a remainder, Test it and Stop if it is Zero (because we have a result then)
09  SUB 26          ; Subtract current -b test value from Acc (so adds +b back on).
                    ; By adding +b back on, we identify if subtractions have overshot 0
                    ; by less than the amount +b, in which case b isn’t a factor.
                    ; If instead we get back to 0 exactly, then it must be a factor.
10  STO 25          ; Stores the calculated overshoot difference value in line 25.
                    ; If this is 0, we’ve found the factor. If it’s +ve, we haven’t.
11  LDN 25          ; Loads negative of line 25 overshoot difference value.
                    ; If a negative no is loaded now, then we haven’t got a factor.
                    ; If a non negative no is loaded it must be 0 and we have the factor.
12  CMP             ; If Acc is negative: Jumps to execute from 14 with a new test divisor.
                    ; If Acc is not negative: Execute next line 13 to Stop.
13  STP             ; STOP. Acc was NOT negative so Divisor was found. Answer is in Line 27.

; Form a new divisor b to be tested, then jump back and test it as a possible factor using subtractions
14  LDN 26          ; Load the last tested b value as a positive Acc value.
15  SUB 21          ; Decrement the last tested b value by 1.
16  STO 27          ; Store new +b test value in line 27.
17  LDN 27          ; Load new –b test value into Acc.
18  STO 26          ; Store new -b test value in line 26.
19  JMP 22          ; Execute subtractions from line 5 again using new test b value.

; Fixed data
20  NUM -3          ; Value for use in the JRP jump instruction in line 8.
21  NUM  1          ; Value for decrementing value of the test b value in line 15.
22  NUM  4          ; Value for use in the JMP jump instruction in line 19.
23  NUM -262144     ; Negative form of the number to be factored.
24  NUM 262143      ; First b value to check as being a factor of number in line 23.

; Variable data written to during execution (initially all zero)
25  NUM  0          ; Latest overshoot difference (written by line 10).
26  NUM  0          ; Latest -b value under test (written by line 2 or 18).
27  NUM  0          ; Latest +b value under test (written by line 4 or 16).*
28  NUM  0          ; Not used.
29  NUM  0          ; Not used.
30  NUM  0          ; Not used.
31  NUM  0          ; Not used.

Here's a subroutine from Whirlwind (built 1947-1951) to print a 5 digit octal number. It is taken from this collection of subroutines. All computers of this era were programmed directly with the translated opcodes (there were not text editors, and no assembler to translate assembly into code), so the real program is just a sequence of numbers which was punched on papertape. The assembly mnemonics are just an aid for the programmer.

It looks very similar to how Assembly code still looks today.

00  ta 19r  set return address
01  ts 1t   store value
02  cp 20r  is word negative? Yes: 20r
03  ca 26r  No: Print "0"
04  qp 144  Printing
05  cs 25r  Set digit counter
06  ts 2t
07  ca 1t   Value in AC
08  sr *12
09  ad 34r  Add start of number table
10  td 13r
11  sl 15   Store remainder
12  ts lt
13  (ca 0)  Put flexo code for digit in AC
14  qp 128  print digit
15  ao 2t   Have all digits been printed?
16  cp 7e   No.
17  ca 4r   Yes. Cause a CR
18  qp 128
19  (sp 0)  Go back to main program
20  ad 24r  Change sign
21  ts 1t   Store value
22  ca 27r  Print "1"
23  sp 4r
24  0.77777
25  p4      Initial value of counter
26  p45     Number Table
27  p36
28  p39
29  p3
30  p21
31  p33
33  p15
34  p26r

And here is an assembly program for the IAS Machine (built from 1945-1951, inspired by Eniac).

It is taken from this article, which explains it in detail. Two instructions could be put into a single number, and again the sequence of numbers made up the program. There are no mnemonics this time, instead a more mathematical notation is used to describe the operation.

0.  S(x)->R     10  ;   load working number into AR
    S(x)*R->A   10  ;   multiply working number by AR
1.  R->A            ;   move AR into AC
    At->S(x)    12  ;   save AC in location 12
2.  S(x)->Ac+   10  ;   load working number into AC
    S(x)->Ah+   11  ;   add one to working number
3.  At->S(x)    10  ;   store incremented working number
    S(x)->R     10  ;   and start again!
4.  S(x)*R->A   10
5.  At->S(x)    13  ;   but save in location 13 this time
    S(x)->Ac+   10
6.  S(x)->Ah+   11
    At->S(x)    10
7.  .empty
8.  .empty
9.  .empty
10. .data   4
11. .data   1

Not the answer you're looking for? Browse other questions tagged or ask your own question.