Relay computer calculates 7 digits of Pi

Calculation of Pi approximation by dividing 355 to 113. Program outputs digits (one by one) of the result into the register S, which can be observed by the user. Executed program listing: ; var a MOVI A, 1 ; 00: 10000000 00000001 MOVI B, 99 ; 01: 10000001 01100011 ; var b MOVI M, 113 ; 02: 10000100 01110001 Main: Div: MOVI L, 0 ; 03: 10000110 00000000 Loop: SUB D, B, M ; 04: 01011011 00011100 SBC C, A, 0 ; 05: 01010010 10001000 JMP C, Exit ; 06: 10110111 00001011 ADD L, L, 1 ; 07: 01001110 11101001 MOV B, D ; 08: 00011001 00110000 MOV A, C ; 09: 00011000 00100000 JMP Loop ; 0a: 10000111 00000100 Exit: ; Display next digit in S MOV S, L ; 0b: 00011101 01100000 ; rem * 2 still less than 256 ADD D, B, B ; 0c: 01001011 00011001 ; rem * 4 ADD B, D, D ; 0d: 01001001 00111011 ADC A, A, A ; 0e: 01000000 00001000 ; rem * 8 ADD B, B, B ; 0f: 010
Back to Top