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