1 MINSK-2 INSTRUCTION SET
2 ~~~~~~~~~~~~~~~~~~~~~~~
5 The memory of the machine consists of 4096 37-bit words (the topmost bit
6 is always used as a sign). The 0th memory cell is hard-wired to 0, writes
9 Fixed-point numbers: sign and 36 significant bits
11 Binary floating-point numbers (from top to bottom bit):
19 Decimal floating-point numbers (used only for printing):
22 28 bits of mantissa (7 decimal digits in BCD)
26 5 bits of exponent (2 decimal digits in BCD, the former one truncated to 1 bit)
31 Minsk-2 has 3 registers:
33 accumulator usually keeps the result of the previous arithmetic operation
34 R1 usually copies one of the operand of the instruction
35 R2 contains the value of acc
37 (most programs use only the accumulator)
40 Generic instruction format: (by octal digits; some instructions deviate)
46 | +------ indexing mode
47 +------- signed operation code
54 | +---- index register: when non-zero, lower 12 bits of the memory
55 | cell #iiii are added to yyyy, next 12 bits are added to xxxx
56 +----- address extension (supported only on Minsk-22, not in our Minsk-2)
59 For arithmetic instructions, the lower 2 bits of <sop> encode addressing mode:
61 0?: arg_a = mem[y], arg_b = mem[x]
62 1?: arg_a = previous value of accumulator, arg_b = mem[x]
63 ?0: store result to accumulator
64 ?1: store result to both accumulator and mem[y]
71 +10-13 Fixed-point a+b
72 +14-17 Floating-point a+b
73 +20-23 Fixed-point a-b
74 +24-27 Floating-point a-b
75 +30-33 Fixed-point a*b
76 +34-37 Floating-point a*b
77 +40-43 Fixed-point a/b
78 +44-47 Floating-point a/b
79 +50-53 Fixed-point abs(a)-abs(b)
80 +54-57 Floating-point abs(a)-abs(b)
81 +60-63 a << b (b may be negative)
82 +64-67 a << b (b may be negative)
85 -00 HALT, store x to R1 and y to accumulator
86 -03 Magnetic tape I/O -- NOTIMP
87 -04 Disable rounding -- NOTIMP
88 -05 Enable rounding -- NOTIMP
89 -06 Interrupt control -- NOTIMP
90 -07 Reverse tape -- NOTIMP
91 -10 Move: mem[y] = acc = mem[x]
92 -11 Move negative: mem[y] = acc = -mem[x]
93 -12 Move absolute: mem[y] = acc = abs(mem[x])
94 -13 Read from keyboard -- NOTIMP
95 -14 Copy sign of mem[x] to mem[y]
96 -15 Read code from R1 (obscure) -- NOTIMP
97 -16 Copy exponent of mem[x] to mem[y]
98 -17 Teletype I/O -- NOTIMP
99 -20 Loop: uses the index register mem[i] for loop control:
100 mem[i] is divided to 3 12-bit fields nnnn pppp qqqq,
101 mem[y] is likewise diveded to fields rrrr ssss tttt.
102 If n=0, the instruction does nothing
103 otherwise, mem[i] is written back with:
107 and jump to address x.
108 -30 Jump: mem[y]=acc and jump to address x
109 -31 Jump to subroutine at address x, store backward jump instruction to mem[y]
110 -32 Jump by sign: if acc>=0, jump to x, else jump to y
111 -33 Jump by overflow: if overflow, jump to y, else jump to x
112 (we always halt on overflow, so this is rather trivial)
113 -34 Jump by zero: if acc==0, jump to y, else jump to x
114 -35 Jump by keypress: if key pressed, jump to x, else jump to y
115 (no keys are emulated)
116 -36 Interrupt masking -- NOTIMP
117 -37 Tape I/O -- NOTIMP
118 -40-47 Various I/O -- NOTIMP
119 -60-61 Various I/O -- NOTIMP
120 -62 Printing instructions, depending on x:
121 0aaa put decimal float mem[y] at position aaa in the buffer
122 1aaa put octal integer mem[y]
123 2aaa put decimal integer mem[y]
124 3aaa put decimal integer mem[y], leading zeroes changed to spaces
125 4aaa put one Russian symbol stored in 6 topmost bits of mem[y]
126 5aaa put Russian text in mem[y] (6 6-bit characters)
127 6aaa put one Latin symbol stored in 6 topmost bits of mem[y]
128 7aaa put Latin text in mem[y] (6 6-bit characters)
129 z400 print contents of the buffer
130 bit 0 of z: perform line feed afterwards
131 bit 1 of z: clear buffer afterwards
132 bit 2 of z: if 0, nothing is printed
133 Hence, 2400 just clears the buffer, 5400 is a linefeed with
134 no effect on the contents of the buffer etc.
136 -70 Fixed-point a*b, take bottom part; result always to acc
137 (what is the sign? the book is silent...)
139 -72 Add exponent of mem[x] to mem[y], copy mem[y] to acc
140 -73 Sub exponent of mem[x] from mem[y], copy mem[y] to acc
141 -74 Addition in one's complement: mem[y] = mem[x] + mem[y]
142 -75 Normalization: convert fixed-point mem[x] to floating-point mem[y]
143 -76 Population count: set mem[y] to number of bits in mem[x]