Euclid's algorithm executed on the relay computer

preview_player
Показать описание
Register block is the second from the right.
There are A, B on top and PC on bottom.

The following program is executed with op1=15, op2=12:
; A, B - operands, A - result
ORG 0
MOVI A, op1 ; 00: 10000000 iiiiiiii
MOVI B, op2 ; 01: 10000001 iiiiiiii
LOOP:
OR F, A, A ; 02: 01101000 00000000
JMP Z, END ; 03: 10010111 00001100
OR F, B, B ; 04: 01101000 00010001
JMP Z, END ; 05: 10010111 00001100
SUB F, A, B ; 06: 01011000 00000001
JMP C, L1 ; 07: 10110111 00001010
SUB A, A, B ; 08: 01011000 00001001
JMP LOOP ; 09: 10000111 00000010
L1:
SUB B, B, A ; 0A: 01011001 00011000
JMP LOOP ; 0B: 10000111 00000010
END:
ADD A, A, B ; 0C: 01001000 00001001
HALT ; 0D: 00010000 00000000

Рекомендации по теме
Комментарии
Автор

Если вместо новогодней елки - то сгодиться !
:)
Круто, конечно же Круто !

sergatmel
Автор

The closed captions make it even better.

greentree
Автор

Hollywood still thinks that computer look like this…

geowar
Автор

You should probably describe euclids algorithm; somewhere.

michaelpcoffee