Mining bitcoins on 55-year-old veteran IBM 1401
- Transfer
Is it possible to mine bitcoins using the IBM mainframe from the 60s of the last century? I decided to check out this seemingly crazy idea. I injected the Bitcoin hash algorithm into the assembler code for IBM 1401 and tested it in practice by running it on a workable model of this ancient mainframe.

The punched card used to calculate the SHA-256 hashes on the IBM 1401 mainframe. A printout is visible behind the punched card showing the input of the algorithm and the resulting hash
As it turned out, using this computer you can mine, but this process will take so much time that even the entire lifetime of the Universe may not be enough to successfully mine one block.
While modern hardware allows you to calculate billions of hashes per second, the computer 1401 spends 80 seconds each to calculate a single hash. The progress in computer performance over the past decades is evident, which is clearly described by the law of Gordon Moore.
The punch cards that participated in the experiment, as well as the SHA-256 printout with a line printer are shown in the photograph above (the first punch card serves only for beauty - it was not easy to break through this pattern). Note that the second line ends with a group of zeros; this means a successful hash.
Bitcoin mining principle
Recently, the electronic currency Bitcoin (Bitcoin), which Internet users can transfer to each other, has been very popular. To understand the essence of the work of this cryptocurrency, the Bitcoin system can be presented in the form of a kind of accounting journal, which stores records about the owner of digital coins (bitcoins) and the number of coins that he / she has. Bitcoin members can transfer digital coins to each other.
It should be noted that the Bitcoin system is decentralized: it does not have a single regulatory server that would monitor the progress of transactions. Instead, records are sent out over a distributed network from thousands of computers on the Internet.
The difficulty is that such a distributed system must somehow ensure that all users agree on the records. That is, conscientious users must confirm the validity of the transaction, approve it, despite the possible presence of fraudsters and slow-running networks. The solution to this problem was the so-called "mining." Approximately every 10 minutes during the mining process, a block of outgoing transactions is confirmed, as a result, it is considered officially confirmed.
The mining process, based on reliable cryptography, is extremely complicated, so no one can control which transactions are mining. In particular, the key idea of the Bitcoin system is that it is difficult and difficult to get the result of work, but it is easy to verify. This is the so-called “proof-of-work” technology.
The process of block mining requires a huge amount of computational cost. However, after the block has been confirmed, peer-to-peer network users can easily verify its validity. The complexity of mining prevents fraudulent use of Bitcoin, and the ease of checking the validity of the block allows users to be confident in the validity of transactions.
A side effect of mining is the addition of new bitcoins to the system. Currently, everyone who confirms the block receives 25 generated bitcoins for this (now the value of this number of virtual coins in traditional monetary terms is about 6 thousand US dollars). This encouragement encourages the miners to work hard and spend their resources on mining. Given the opportunity to receive 6 thousand US dollars every 10 minutes, mining seems to be a real "gold mine", encouraging users to spend significant amounts on hardware for mining.

The inline printer and the IBM 1401 Mainframe featured at the Computer History Museum. This computer was running my program. The console is located on the top left. The dark rectangular panels on the computer are the “doors” of the racks that swing back, providing access for maintenance.
The mining process is extremely complicated, but the result is very easy to verify. Bitcoin mining uses cryptography with a hash function called double SHA-256. The hash takes a chunk of data at the input and reduces it to a lower hash value (in this case, 256 bits).
The cryptographic hashing algorithm will not allow you to get the desired hash value without having to sort through the mass of data at the input. However, after finding an input that gives the desired value, everyone can easily check the hash. Therefore, cryptographic hashing is a good way to implement “proof-of-work” bitcoins.
In more detail, in order to smine a block, first you need to collect new transactions into a block. Then you need to hash the block to obtain (essentially randomly) the hash value of the block. If the hash value begins with 16 zeros, the block is considered successfully confirmed and sent to the Bitcoin network. Most of the time, the hash is not successful, so you slightly change the block and try again and again, after more than one billion computational operations. About every 10 minutes, someone succeeds in successfully confirming the block and the process starts again. This is reminiscent of a lottery in which miners participate, making an attempt after an attempt, until someone becomes a “winner”. The complexity of the hashing process is difficult to visualize: it is easier to find a grain of sand in the entire sand of the Earth than to find a valid hash value.
I deliberately simplify many of the explanations in this article. If you want to learn more about the Bitcoin system and mining, I advise you to study my articles The difficult experience of mining bitcoins and the harsh lessons of bitcoin mining .
Bitcoin SHA-256 Hash Algorithm
Now I will look at the hash function used by Bitcoin, which is based on a standard cryptographic hash function called SHA-256. The Bitcoin system uses a “double SHA-256”. This means that the SHA-256 function is executed twice. The SHA-256 algorithm is so simple that you can literally execute it using only a pencil and paper , and the algorithm allows you to mix data in an unpredictable way. The algorithm accepts 64 byte blocks at the input, processes the data cryptographically and produces 256 bits (32 bytes) of encrypted data. The algorithm uses one round, which is repeated 64 times. The illustration below shows one round of the algorithm, which takes eight 4-byte blocks, A through H, performs several operations and produces new values for A through N.

Round SHA-256, as an example from Wikipedia , by kockmeyer, CC BY-SA 3.0
Dark blue blocks mix bits in a non-linear way, which is difficult for cryptographic analysis. (If you manage to find a mathematically faster way to get successful hashes, you can control the mining of bitcoins). Cell “select” Ch selects bits from F or G, based on the value of input E. Cells Σ “sum” rotate bits A (or E) generating three cyclic shifted versions, and then sums them together modulo 2.
Cell Ma “majority” checks the bits at each position A, B, and C, and selects 0 or 1, depending on what value is in the majority. Red cells perform 32-bit additions, generating new values for A and E. The Wt input is based on slightly processed input. (This is where the input block is introduced into the algorithm.) Input Kt is a constant defined for each round.
According to the above illustration, only A and E are changed per round. The remaining values are skipped unchanged. The old value of A becomes the new value of B, the old value of B becomes the new value of C, and so on. Although each round of SHA-256 changes the data slightly, after 64 rounds the input data is completely mixed, giving an unpredictable hash value.
Ibm 1401
I decided to execute this algorithm on the IBM 1401 mainframe. This computer appeared in 1959 and by the mid-60s became the best-selling computer - at that time more than 10 thousand machines were actively operated. The computer 1401 was not a very powerful computer even for 1960. However, it was affordable for medium-sized companies that previously could not afford to have a computer, due to the fact that it could be rented for little money - $ 2,500 per month.
The IBM 1401 did not use silicon chips. Moreover, in this computer there were no chips at all. Its transistors were built on semiconductors, germanium crystals, which were used before silicon. Transistors, along with other components, were installed on boards the size of playing cards called SMS cards. The computer involved thousands of such cards, which were installed in the form of racks called “doors”. The IBM 1401 has twenty such “doors” that have been put forward for computer maintenance. In the illustration above, one open door is visible, providing access to microchips and cables.

The illustration shows an open rack (the so-called “door”) of the IBM 1401 Mainframe. The photograph shows SMS cards connected to the circuit. This rack drives tape drives
The working principle of such a computer was significantly different from modern PCs. This computer used not 8-bit bytes, but 6-bit characters based on binary-coded decimal number (BCD). Since this computer was a calculating machine for solving economic problems, it used decimal rather than binary arithmetic, and each character in the memory had a digital value from 0 to 9. Computer memory on magnetic cores contained 4000 characters. A memory expansion module the size of a dishwasher increased memory capacity by 12,000 characters. Data entry into the computer was carried out using perforated cards. Card reader read data and programs from cards. The output data was printed out by a high-speed drain printer or punched on maps.
Museum of Computer History Computer History Museumin Mountain View, it has two workable IBM 1401 mainframes. On one of them I ran the SHA-256 hash code. I talk more about IBM 1401 in my article Fractals on IBM 1401
.
Running SHA-256 on an IBM 1401
Surely the IBM 1401 computer is the worst of all the machines that could be chosen to execute the SHA-256 hash algorithm. To work effectively, this algorithm requires machines that can perform bit operations in 32-bit words. Unfortunately, IBM 1401 does not support either 32-bit words or bytes. This computer works with 6-bit characters and does not allow bit operations. Moreover, instead of binary, decimal arithmetic was used in it. Therefore, the algorithm on the computer 1401 will be slow and inconvenient for the user.
I ended up using one character per bit. The 32-bit value was stored as 32 characters, either “0” or “1”. My code had to perform bitwise operations, multiplications and additions character by character, checking each character and deciding what to do with it. As you might expect, code execution took a long time.
Next, I quote the assembler code I wrote. In general, the principle of the code is described in the comments. At the end of the code there is a table of constants required by the SHA-256 algorithm in hexadecimal form. Since the computer 1401 does not support the hexadecimal format, I had to write my own routines for converting the hexadecimal and binary formats. In this article I will not provide explanations of the assembler code for IBM 1401, I emphasize only that it is very different from what modern computers use. This code does not call subroutines and does not return results. Due to the lack of general purpose registers, operations are carried out in memory.
Look for the code under the spoiler:
job bitcoin
* SHA-256 hash
* Ken Shirriff http://righto.com
ctl 6641
org 087
X1 dcw @000@
org 092
X2 dcw @000@
org 097
X3 dcw @000@
org 333
start cs 299
r
sw 001
lca 064, input0
mcw 064, 264
w
* Initialize word marks on storage
mcw +s0, x3
wmloop sw 0&x3
ma @032@, x3
c +h7+32, x3
bu wmloop
mcw +input-127, x3 * Put input into warr[0] to warr[15]
mcw +warr, x1
mcw @128@, tobinc
b tobin
* Compute message schedule array w[0..63]
mcw @16@, i
* i is word index 16-63
* x1 is start of warr[i-16], i.e. bit 0 (bit 0 on left, bit 31 on right)
mcw +warr, x1
wloop c @64@, i
be wloopd
* Compute s0
mcw +s0, x2
za +0, 31&x2 * Zero s0
* Add w[i-15] rightrotate 7
sw 7&x2 * Wordmark at bit 7 (from left) of s0
a 56&x1, 31&x2 * Right shifted: 32+31-7 = bit 24 of w[i-15], 31 = end of s0
a 63&x1, 6&x2 * Wrapped: 32+31 = end of w[i-15], 7-1 = bit 6 of s0
cw 7&x2 * Clear wordmark
* Add w[i-15] rightrotate 18
sw 18&x2 * Wordmark at bit 18 (from left) of s0
a 45&x1, 31&x2 * Right shifted: 32+31-18 = bit 13 of w[i-15], 31 = end of s0
a 63&x1, 17&x2 * Wrapped: 32+31 = end of w[i-15], 18-1 = bit 17 of s0
cw 18&x2 * Clear wordmark
* Add w[i-15] rightshift 3
sw 3&x2 * Wordmark at bit 3 (from left) of s0
a 60&x1, 31&x2 * Right shifted: 32+31-3 = bit 28 of w[i-15], 31 = end of s0
cw 3&x2 * Clear wordmark
* Convert sum to xor
mcw x1, x1tmp
mcw +s0+31, x1 * x1 = right end of s0
mcw @032@, x2 * Process 32 bits
b xor
sw s0 * Restore wordmark cleared by xor
mcw x1tmp, x1
* Compute s1
mcw +s1, x2
za +0, 31&x2 * Zero s1
* Add w[i-2] rightrotate 17
sw 17&x2 * Wordmark at bit 17 (from left) of s1
a 462&x1, 31&x2 * Right shifted: 14*32+31-17 = bit 14 of w[i-2], 31 = end of s1
a 479&x1, 16&x2 * Wrapped: 14*32+31 = end of w[i-2], 17-1 = bit 16 of s1
cw 17&x2 * Clear wordmark
* Add w[i-2] rightrotate 19
sw 19&x2 * Wordmark at bit 19 (from left) of s1
a 460&x1, 31&x2 * Right shifted: 14*32+31-19 = bit 12 of w[i-2], 31 = end of s1
a 479&x1, 18&x2 * Wrapped: 14*32+31 = end of w[i-2], 19-1 = bit 18 of s1
cw 19&x2 * Clear wordmark
* Add w[i-2] rightshift 10
sw 10&x2 * Wordmark at bit 10 (from left) of s1
a 469&x1, 31&x2 * Right shifted: 14*32+31-10 = bit 21 of w[i-2], 31 = end of s1
cw 10&x2 * Clear wordmark
* Convert sum to xor
mcw +s1+31, x1 * x1 = right end of s1
mcw @032@, x2 * Process 32 bits
b xor
sw s1 * Restore wordmark cleared by xor
* Compute w[i] := w[i-16] + s0 + w[i-7] + s1
mcw x1tmp, x1
a s1+31, s0+31 * Add s1 to s0
a 31&x1, s0+31 * Add w[i-16] to s0
a 319&x1, s0+31 * Add 9*32+31 = w[i-7] to s0
* Convert bit sum to 32-bit sum
mcw +s0+31, x1 * x1 = right end of s0
mcw @032@, x2 * Process 32 bits
b sum
sw s0 * Restore wordmark cleared by sum
mcw x1tmp, x1
mcw s0+31, 543&x1 * Move s0 to w[i]
ma @032@, x1
a +1, i
mz @0@, i
b wloop
x1tmp dcw #5
* Initialize: Copy hex h0init-h7init into binary h0-h7
wloopd mcw +h0init-7, x3
mcw +h0, x1
mcw @064@, tobinc * 8*8 hex digits
b tobin
* Initialize a-h from h0-h7
mcw @000@, x1
ilp mcw h0+31&x1, a+31&x1
ma @032@, x1
c x1, @256@
bu ilp
mcw @000@, bitidx * bitidx = i*32 = bit index
mcw @000@, kidx * kidx = i*8 = key index
* Compute s1 from e
mainlp mcw +e, x1
mcw +s1, x2
za +0, 31&x2 * Zero s1
* Add e rightrotate 6
sw 6&x2 * Wordmark at bit 6 (from left) of s1
a 25&x1, 31&x2 * Right shifted: 31-6 = bit 25 of e, 31 = end of s1
a 31&x1, 5&x2 * Wrapped: 31 = end of e, 6-1 = bit 5 of s1
cw 6&x2 * Clear wordmark
* Add e rightrotate 11
sw 11&x2 * Wordmark at bit 11 (from left) of s1
a 20&x1, 31&x2 * Right shifted: 31-11 = bit 20 of e, 31 = end of s1
a 31&x1, 10&x2 * Wrapped: 31 = end of e, 11-1 = bit 10 of s1
cw 11&x2 * Clear wordmark
* Add e rightrotate 25
sw 25&x2 * Wordmark at bit 25 (from left) of s1
a 6&x1, 31&x2 * Right shifted: 31-25 = bit 6 of e, 31 = end of s1
a 31&x1, 24&x2 * Wrapped: 31 = end of e, 25-1 = bit 24 of s1
cw 25&x2 * Clear wordmark
* Convert sum to xor
mcw +s1+31, x1 * x1 = right end of s1
mcw @032@, x2 * Process 32 bits
b xor
sw s1 * Restore wordmark cleared by xor
* Compute ch: choose function
mcw @000@, x1 * x1 is index from 0 to 31
chl c e&x1, @0@
be chzero
mn f&x1, ch&x1 * for 1, select f bit
b chincr
chzero mn g&x1, ch&x1 * for 0, select g bit
chincr a +1, x1
mz @0@, x1
c @032@, x1
bu chl
* Compute temp1: k[i] + h + S1 + ch + w[i]
cs 299
mcw +k-7, x3 * Convert k[i] to binary in temp1
ma kidx, x3
mcw +temp1, x1
mcw @008@, tobinc * 8 hex digits
b tobin
mcw @237@, x3
mcw +temp1, x1
mcw @008@, tobinc
b tohex
a h+31, temp1+31 * +h
a s1+31, temp1+31 * +s1
a ch+31, temp1+31 * +ch
mcw bitidx, x1
a warr+31&x1, temp1+31 * + w[i]
* Convert bit sum to 32-bit sum
mcw +temp1+31, x1 * x1 = right end of temp1
b sum
* Compute s0 from a
mcw +a, x1
mcw +s0, x2
za +0, 31&x2 * Zero s0
* Add a rightrotate 2
sw 2&x2 * Wordmark at bit 2 (from left) of s0
a 29&x1, 31&x2 * Right shifted: 31-2 = bit 29 of a, 31 = end of s0
a 31&x1, 1&x2 * Wrapped: 31 = end of a, 2-1 = bit 1 of s0
cw 2&x2 * Clear wordmark
* Add a rightrotate 13
sw 13&x2 * Wordmark at bit 13 (from left) of s0
a 18&x1, 31&x2 * Right shifted: 31-13 = bit 18 of a, 31 = end of s0
a 31&x1, 12&x2 * Wrapped: 31 = end of a, 13-1 = bit 12 of s0
cw 13&x2 * Clear wordmark
* Add a rightrotate 22
sw 22&x2 * Wordmark at bit 22 (from left) of s0
a 9&x1, 31&x2 * Right shifted: 31-22 = bit 9 of a, 31 = end of s0
a 31&x1, 21&x2 * Wrapped: 31 = end of a, 22-1 = bit 21 of s0
cw 22&x2 * Clear wordmark
* Convert sum to xor
mcw +s0+31, x1 * x1 = right end of s0
mcw @032@, x2 * Process 32 bits
b xor
sw s0 * Restore wordmark cleared by xor
* Compute maj(a, b, c): majority function
za +0, maj+31
a a+31, maj+31
a b+31, maj+31
a c+31, maj+31
mz @0@, maj+31
mcw @000@, x1 * x1 is index from 0 to 31
mjl c maj&x1, @2@
bh mjzero
mn @1@, maj&x1 * majority of the 3 bits is 1
b mjincr
mjzero mn @0@, maj&x1 * majority of the 3 bits is 0
mjincr a +1, x1
mz @0@, x1
c @032@, x1
bu mjl
* Compute temp2: S0 + maj
za +0, temp2+31
a s0+31, temp2+31
a maj+31, temp2+31
* Convert bit sum to 32-bit sum
mcw +temp2+31, x1 * x1 = right end of temp1
b sum
mcw g+31, h+31 * h := g
mcw f+31, g+31 * g := f
mcw e+31, f+31 * f := e
za +0, e+31 * e := d + temp1
a d+31, e+31
a temp1+31, e+31
mcw +e+31, x1 * Convert sum to 32-bit sum
b sum
mcw c+31, d+31 * d := c
mcw b+31, c+31 * c := b
mcw a+31, b+31 * b := a
za +0, a+31 * a := temp1 + temp2
a temp1+31, a+31
a temp2+31, a+31
mcw +a+31, x1 * Convert sum to 32-bit sum
b sum
a @8@, kidx * Increment kidx by 8 chars
mz @0@, kidx
ma @032@, bitidx * Increment bitidx by 32 bits
c @!48@, bitidx * Compare to 2048
bu mainlp
* Add a-h to h0-h7
cs 299
mcw @00000@, x1tmp
add1 mcw x1tmp, x1
a a+31&x1, h0+31&x1
ma +h0+31, x1 * Convert sum to 32-bit sum
b sum
ma @032@, x1tmp
c @00256@, x1tmp
bu add1
mcw @201@, x3
mcw +h0, x1
mcw @064@, tobinc
b tohex
w
mcw 280, 180
p
p
finis h
b finis
* Converts sum of bits to xor
* X1 is right end of word
* X2 is bit count
* Note: clears word marks
xor sbr xorx&3
xorl c @000@, x2
be xorx
xorfix mz @0@, 0&x1 * Clear zone
c 0&x1, @2@
bh xorok
sw 0&x1 * Subtract 2 and loop
s +2, 0&x1
cw 0&x1
b xorfix
xorok ma @I9I@, x1 * x1 -= 1
s +1, x2 * x2 -= 1
mz @0@, x2
b xorl * loop
xorx b @000@
* Converts sum of bits to sum (i.e. propagate carries if digit > 1)
* X1 is right end of word
* Ends at word mark
sum sbr sumx&3
suml mz @0@, 0&x1 * Clear zone
c 0&x1, @2@ * If digit is <2, then ok
bh sumok
s +2, 0&x1 * Subtract 2 from digit
bwz suml, 0&x1, 1 * Skip carry if at wordmark
a @1@, 15999&x1 * Add 1 to previous position
b suml * Loop
sumok bwz sumx,0&x1,1 * Quit if at wordmark
ma @I9I@, x1 * x1 -= 1
b suml * loop
sumx b @000@ * return
* Converts binary to string of hex digits
* X1 points to start (left) of binary
* X3 points to start (left) of hex buffer
* X1, X2, X3 destroyed
* tobinc holds count (# of hex digits)
tohex sbr tohexx&3
tohexl c @000@, tobinc * check counter
be tohexx
s @1@, tobinc * decrement counter
mz @0@, tobinc
b tohex4
mcw hexchr, 0&x3
ma @004@, X1
ma @001@, X3
b tohexl * loop
tohexx b @000@
* X1 points to 4 bits
* Convert to hex char and write into hexchr
* X2 destroyed
tohex4 sbr tohx4x&3
mcw @000@, x2
c 3&X1, @1@
bu tohx1
a +1, x2
tohx1 c 2&X1, @1@
bu tohx2
a +2, x2
tohx2 c 1&x1, @1@
bu tohx4
a +4, x2
tohx4 c 0&x1, @1@
bu tohx8
a +8, x2
tohx8 mz @0@, x2
mcw hextab-15&x2, hexchr
tohx4x b @000@
* Converts string of hex digits to binary
* X3 points to start (left) of hex digits
* X1 points to start (left) of binary digits
* tobinc holds count (# of hex digits)
* X1, X3 destroyed
tobin sbr tobinx&3
tobinl c @000@, tobinc * check counter
be tobinx
s @1@, tobinc * decrement counter
mz @0@, tobinc
mcw 0&X3, hexchr
b tobin4 * convert 1 char
ma @004@, X1
ma @001@, X3
b tobinl * loop
tobinx b @000@
tobinc dcw @000@
* Convert hex digit to binary
* Digit in hexchr (destroyed)
* Bits written to x1, ..., x1+3
tobin4 sbr tobn4x&3
mcw @0000@, 3+x1 * Start with zero bits
bwz norm,hexchr,2 * Branch if no zone
mcw @1@, 0&X1
a @1@, hexchr * Convert letter to value: A (1) -> 2, F (6) -> 7
mz @0@, hexchr
b tob4
norm c @8@, hexchr
bl tob4
mcw @1@, 0&X1
s @8@, hexchr
mz @0@, hexchr
tob4 c @4@, hexchr
bl tob2
mcw @1@, 1&X1
s @4@, hexchr
mz @0@, hexchr
tob2 c @2@, hexchr
bl tob1
mcw @1@, 2&X1
s @2@, hexchr
mz @0@, hexchr
tob1 c @1@, hexchr
bl tobn4x
mcw @1@, 3&X1
tobn4x b @000@
* Message schedule array is 64 entries of 32 bits = 2048 bits.
org 3000
warr equ 3000
s0 equ warr+2047 *32 bits
s1 equ s0+32
ch equ s1+32 *32 bits
temp1 equ ch+32 *32 bits
temp2 equ temp1+32 *32 bits
maj equ temp2+32 *32 bits
a equ maj+32
b equ a+32
c equ b+32
d equ c+32
e equ d+32
f equ e+32
g equ f+32
h equ g+32
h0 equ h+32
h1 equ h0+32
h2 equ h1+32
h3 equ h2+32
h4 equ h3+32
h5 equ h4+32
h6 equ h5+32
h7 equ h6+32
org h7+32
hexchr dcw @0@
hextab dcw @0123456789abcdef@
i dcw @00@ * Loop counter for w computation
bitidx dcw #3
kidx dcw #3
* 64 round constants for SHA-256
k dcw @428a2f98@
dcw @71374491@
dcw @b5c0fbcf@
dcw @e9b5dba5@
dcw @3956c25b@
dcw @59f111f1@
dcw @923f82a4@
dcw @ab1c5ed5@
dcw @d807aa98@
dcw @12835b01@
dcw @243185be@
dcw @550c7dc3@
dcw @72be5d74@
dcw @80deb1fe@
dcw @9bdc06a7@
dcw @c19bf174@
dcw @e49b69c1@
dcw @efbe4786@
dcw @0fc19dc6@
dcw @240ca1cc@
dcw @2de92c6f@
dcw @4a7484aa@
dcw @5cb0a9dc@
dcw @76f988da@
dcw @983e5152@
dcw @a831c66d@
dcw @b00327c8@
dcw @bf597fc7@
dcw @c6e00bf3@
dcw @d5a79147@
dcw @06ca6351@
dcw @14292967@
dcw @27b70a85@
dcw @2e1b2138@
dcw @4d2c6dfc@
dcw @53380d13@
dcw @650a7354@
dcw @766a0abb@
dcw @81c2c92e@
dcw @92722c85@
dcw @a2bfe8a1@
dcw @a81a664b@
dcw @c24b8b70@
dcw @c76c51a3@
dcw @d192e819@
dcw @d6990624@
dcw @f40e3585@
dcw @106aa070@
dcw @19a4c116@
dcw @1e376c08@
dcw @2748774c@
dcw @34b0bcb5@
dcw @391c0cb3@
dcw @4ed8aa4a@
dcw @5b9cca4f@
dcw @682e6ff3@
dcw @748f82ee@
dcw @78a5636f@
dcw @84c87814@
dcw @8cc70208@
dcw @90befffa@
dcw @a4506ceb@
dcw @bef9a3f7@
dcw @c67178f2@
* 8 initial hash values for SHA-256
h0init dcw @6a09e667@
h1init dcw @bb67ae85@
h2init dcw @3c6ef372@
h3init dcw @a54ff53a@
h4init dcw @510e527f@
h5init dcw @9b05688c@
h6init dcw @1f83d9ab@
h7init dcw @5be0cd19@
input0 equ h7init+64
org h7init+65
dc @80000000000000000000000000000000@
input dc @00000000000000000000000000000100@ * 512 bits with the mostly-zero padding
end start
The executable program was applied to 85 punched cards (you already saw them at the beginning of the article). I also made a punch card with a hash algorithm. In order to run the program, I had to load the punch card into the card reader and click the “Load” button. The card reader processed 800 cards per minute. Thus, it took only a few seconds to download the program. During program execution, the computer console (see illustration below) blinked feverishly for 40 seconds. Finally, the printer printed the final hash for me (you also saw the printout at the beginning of the article), and the results were printed on a new punch card. Since Bitcoin mining uses SHA-256 double hashing, the mining hashing process took twice as long (80 seconds).

Hard work of the IBM 1401 console while calculating the SHA-256 hash
Performance comparison
The IBM 1401 computer can calculate the SHA-256 double hash in 80 seconds. To complete this task, the computer consumes about 3,000 watts of power, about the same as an electric stove or clothes dryer. At one time, the IBM 1401 base system cost $ 125,600. In the realities of 2015, this amounts to about a million US dollars. At the same time, now you can buy a USB flash drive for mining for $ 50, which has a specialized integrated circuit (ASIC USB miner). This USB miner performs 3.6 billion hashes per second, while consuming about 4 watts.
Such significant performance indicators are due to several factors: a sharp increase in computer performance over the past 50 years according to Moore’s law, loss of performance associated with the use of decimal arithmetic in computers to solve commercial problems, which was busy computing a binary hash code, as well as gain in speed with sides of traditional bitcoin mining hardware.
To summarize. To mine the block, taking into account the current requirements for this process, the IBM 1401 computer will need about 5x10 ^ 14 years (which is 40,000 times the current age of the Universe). The cost of consumed electricity will be about 10 ^ 18 US dollars. As a result, you will receive 25 bitcoins, whose value in monetary terms will be about 6,000 US dollars. So, mining bitcoins on the IBM 1401 mainframe cannot be called a profitable business. The photographs below compare the computer chips of the 60s of the last century and modern options, clearly demonstrating technological progress.


Left: SMS cards used in IBM 1401. Each card consists of many components with a microcircuit. The number of such cards in the computer exceeded a thousand. Right: the Bitfury ASIC chip allows you to mine bitcoins at a speed of 2-3 gigahashes per second. Photo Source: zeptobars (CC BY 3.0)
Network data
You may decide that bitcoins are incompatible with the technology of the 60s of the last century due to the lack of the ability to transmit data over the network. Will someone need to send punched cards with a block chain to other computers? Communication between computers through the network appeared a long time ago. Back in 1941, IBM supported the so-called telemetric (remote) data processing process. In the 60s, IBM 1401 could be connected to an IBM 1009 data transmission device ( IBM 1009 Data Transmission Unit) - a modem the size of a dishwasher, which allowed computers to exchange data with each other over a telephone line at up to 300 characters per second. That is, theoretically, building a Bitcoin network based on technologies of the 60s of the last century is quite possible. Unfortunately, I was not able to get equipment for teleprocessing data and test this theory.

An IBM 1009 data transfer device. A modem the size of a dishwasher appeared in 1960. With its help it was possible to transmit up to 300 characters per second over a telephone line. Photo Source: Introduction to IBM Data Processing Systems) .
conclusions
Using SHA-256 in the assembly language of an ancient mainframe has become a difficult but interesting experience. I expected better performance (even compared to my Mandelbrot set in 12 minutes ). Decimal arithmetic of a commercial computer is not the best option for a binary algorithm like SHA-256. However, the algorithm for mining bitcoins can be performed even on a computer without integrated circuits. Therefore, if suddenly a certain temporary collapse takes me to 1960, I can build a Bitcoin network.
The Mountain View Museum of Computer History shows the running IBM 1401 on Wednesdays and Saturdays. If you happen to be nearby, you should definitely take a look at this by checking the timetablework. And if you tell museum staff who demonstrate running IBM 1401 about me, they may even launch my Pi program .
I want to thank the Computer History Museum and the members of the 1401 computer recovery team: Robert Garner, Ed Thelen, Van Snyder, and especially Stan Paddock. The ibm-1401.info team website has a lot of interesting information about the 1401 computer and how to restore it.
Explanation
It is worth noting that I did not smash the real block on IBM 1401 - the Museum of Computer History would not like it. As I said, having a working IBM 1401, you won’t be able to earn money on mining. However, I managed to implement and execute the SHA-256 algorithm on an IBM 1401 machine, thus proving that mining is theoretically possible. And I’ll tell you the secret of finding a valid hash - I just used the already mined block .
We hope you enjoyed our translation
