これはlong integerに対するmodulo p(pは素数)の四則演算を行うためのinterpretive subroutineである.
但しpは235に近い整数でないと時間がかかる.
(このroutineでは p>235 - 218でなければならない.)
除算を除けばpは素数である必要はない.
1. 使用できる命令
p M C(M)→A
n M -C(M)→A
a M C(A) + C(M) → A
s M C(A) - C(M) → A
v M C(A) × C(M) → A
t M C(A) → M
j M M番地へのjump
k M C(A) = 0 ならばM番地へjump
w M M番地(interpretive routineの外)へjump, これは
closed subroutineへのjumpにも用いられる. この時
終りはjl 19cで戻ればよい.
2. B-modification
"命令"のsign digitが1であるとB-modifyされる. 但しB-registerとしては16c番地が使
われる.
c M B-registerの内容を2ずつ増しその結果が0でなければM番地へjumpする.
b M B-registerに -M をセットする
3. 除算
除算は逆数を乗じて行う. そのために逆数を求めるauziliary subroutine(d-routine)が
あり
w M
によってこれを呼び出すと, Aの内容の逆数がAに入れられて戻って来る.
4. その他
1) すべての数は 0 ≦ x < pとなるようにstandardizeされている.
2) A(interpretiveの中のaccumulator)は56c
M(interpretiveの中のmemory register)は44cである.
3) 使用に際してsetするparameter
0h=235 - p
235に近い素数について0hの値は次のようなものがある.
31, 49, 61, 69
A1 Interpretive Subroutine
0c:
a 40 29 jl 26r (p)
1 x 2r <-43, 21 30 jl 49r (c)
2 p ( ) by 1 31 vl a (v)
3 kl 5r 32 zl 24r
4 a 16r 33 wl 60
5 x 12r 34 jl 32r
6 x 18r 35 jl 58r (b)
7 x 41r 36 nl 44r (s)
8 l 1 37 al a
9 l 2035 38 k 26r
10 a 4r 39 jl 27r
11 x 15r 40 jl 37r (a)
12 pl( ) by 5 41 jl( ) (w)
13 tl 44r 42 p1 2r (j)
14 al m 43 jl 1r
15 jl( ) by 11 44 ( ) ┐"M-register"
16 0 45 ( ) ┘
17 pl a (t) 46 pl a (k)
18 tl( ) by 6 47 zl 42r
19 p 2r <-28, 48 48 jl 19r
20 a 49 49 p 16r ┐
21 jl 1r 50 a 40 │increase C(16r)
22 nl 44r (n) 51 x 16r │
23 jl 38r 52 z 19r │jump if 0
24 q <-32 53 jl 42r ┘
25 jl 27r 54 131072
26 sl m <-38 55 0h -p
27 tl a <-39 56 ( ) ┐"Accumulator"
28 jl 19r 57 ( ) ┘
58 n 12r ┐
59 x 16r │
60 jl 19r ┘
Notes 1. 0m and 0a are set by the subroutine tape:
0m = 54c location of the negative of the modulus -p
0a = 56c space used as "accumulator"
2. 0h must be set by user:
0h = 235- p where p is the modulus.
A2 Reciprocal routine (auxiliary)
0d:
0 pl a read Acc 14 q
1 zl 24r 0 test 15 vl 44c
2 tl 44c ACC MR 16 zl 19r multiply
3 nl 24r set strobe 17 wl 60
4 l 1 shift strobe 18 jl 16r
5 tl 26r 19 q
6 zl 37c exit 20 al m
7 pl a 21 tl a normalize
8 vl a 22 pl 26r read strobe
9 zl 12r square 23 jl 4r
10 wl 60 24 0
11 jl 9r 25 4hh 2(235 - p + 2)
12 pl 26r 26 ( ) strobe
13 kl 19r test strobe 27 ( )
Author: H. Takahasi
Date: 59-11-16