Last active
August 29, 2015 14:00
-
-
Save jpf/6c0e042420487eae0093 to your computer and use it in GitHub Desktop.
This is a program written in AUTOCODER for the IBM 1401. It prints the first 10 numbers in the Fibonacci sequence.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A DCW @001@ * VARIABLE "A" | |
B DCW @001@ * VARIABLE "B" | |
C DCW @000@ * VARIABLE "C" | |
COUNT DCW @000@ * VARIABLE "COUNT" | |
START MCS A,201+3 * MOVE A VARIABLE TO PRINT BUFFER | |
W * PRINT | |
LOOP BCE DONE,COUNT-1,1 * WHILE COUNT < 10 | |
MCS B,201+3 * MOVE B VARIABLE TO PRINT BUFFER | |
W * PRINT | |
A @1@,COUNT * COUNT++ | |
MCW A,C * C=A | |
A B,C * C+=B | |
MCW B,A * A=B | |
MCW C,B * B=C | |
B LOOP * GOTO LOOP | |
DONE H *-3 * HALT, SET PROGRAM COUNTER AT HALT INSTRUCTION | |
END START |
All data on the IBM 1401 is stored as "characters" and BCE can only compare one character with another, so what we're doing here is comparing COUNT-1, which is whatever address COUNT starts at, minus 1. This selects the "middle digit" in that variable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Am I misunderstanding something or is there a typo on line 7? I read it as
Shouldn't it be?