Kits
›
How a CPU Counts
RU
EN
ES
Contents
Introduction
History: how machines learned to add
Lesson 1. Gates and the half adder: 1 + 1 = 10
1.1. The idea: adding one digit
1.2. Building
1.3. Check
Lesson 1 paste (Cmd+I)
Lesson 2. The full adder and 4 bits: the carry runs through the digits
2.1. The idea: column addition
2.2. Building
2.3. Check
Lesson 2 paste (Cmd+I)
Lesson 3. Negative numbers and subtraction: two's complement
3.1. The idea: numbers on a circle
3.2. Flags
3.3. Building
3.4. Check
Lesson 3 paste (Cmd+I)
Lesson 4. 8 bits and comparison: CMP is subtraction
4.1. The idea: two halves
4.2. The idea: comparison is subtraction
4.3. Building
4.4. Check
Lesson 4 paste (Cmd+I)
Lesson 5. The ± calculator: the minus on a lamp, the magnitude on the display
5.1. The idea: the magnitude is one more subtraction
5.2. Building
5.3. Check
Lesson 5 paste (Cmd+I)
Lesson 6 (bonus). Decimal math: add six
6.1. The idea: a digit in four bits
6.2. Why the display is in HEX mode
6.3. Building
How to set the digits
6.4. Check
Lesson 6 paste (Cmd+I)
Summary
All the parts
Instructions in pictures
Lesson 5 in pictures
← Back to the lesson: Lesson 5. The ± calculator: the minus on a lamp, the magnitude on the display
5
The ± calculator
the minus on a lamp, the magnitude on the display
kh
HB-02
A
0
A7
0
A6
0
A5
0
A4
0
A3
0
A2
1
A1
1
A0
B
0
B7
0
B6
0
B5
0
B4
0
B3
1
B2
0
B1
1
B0
1
SUB
−
2
M
3 − 5 = −2
0
17×
ADDSUB8
2×
4
2×
4b
0
A
3×
∞
© 2026 Daniil Khanin · khanin.info · HB-02
32
CANVAS
1
Delete
0
A0
0
A1
0
A2
0
A3
0
A4
0
A5
0
A6
0
A7
0
B0
2
Delete
0
B1
0
B2
0
B3
0
B4
0
B5
0
B6
0
B7
0
SUB
OR
I0
S0
I1
S1
O0
z01
© 2026 Daniil Khanin · khanin.info · HB-02
33
CANVAS …
3
Delete
OR
I0
S2
I1
S3
O0
z23
OR
I0
S4
I1
S5
O0
z45
OR
I0
S6
I1
S7
O0
z67
OR
I0
z01
I1
z23
O0
z03
OR
I0
z45
I1
z67
O0
z47
NOR
I0
z03
I1
z47
O0
Z
NOT
I0
C
O0
nC
NOT
I0
Z
O0
nZ
AND
I0
SUB
I1
Z
O0
EQ
4
Delete
AND
I0
SUB
I1
nC
O0
LT
AND
I0
C
I1
nZ
O0
cnz
AND
I0
SUB
I1
cnz
O0
GT
C
Z
S7
V
EQ
LT
© 2026 Daniil Khanin · khanin.info · HB-02
34
CANVAS …
5
Delete
GT
8b
DEC
A
8b
DEC
B
8b
DEC
S
6
Delete
ADDSUB8
A0
A0
A1
A1
A2
A2
A3
A3
A4
A4
A5
A5
A6
A6
A7
A7
B0
B0
B1
B1
B2
B2
B3
B3
B4
B4
B5
B5
B6
B6
B7
B7
SUB
SUB
S0
S0
S1
S1
S2
S2
S3
S3
S4
S4
S5
S5
S6
S6
S7
S7
CO
C
V
V
© 2026 Daniil Khanin · khanin.info · HB-02
35
CANVAS …
7
0
5×
5×
0
A0
0
A1
0
A2
0
A3
0
A4
8
0
5×
5×
0
A5
0
A6
0
A7
0
B0
0
B1
9
0
5×
5×
0
B2
0
B3
0
B4
0
B5
0
B6
© 2026 Daniil Khanin · khanin.info · HB-02
36
CANVAS …
10
0
2×
2×
0
B7
0
SUB
11
ADDSUB8
1×
4
27×
ADDSUB8
A0
A0
A1
A1
A2
A2
A3
A3
A4
A4
A5
A5
A6
A6
A7
A7
B0
B0
B1
B1
B2
B2
B3
B3
B4
B4
B5
B5
B6
B6
B7
B7
SUB
SUB
S0
S0
S1
S1
S2
S2
S3
S3
S4
S4
S5
S5
S6
S6
S7
S7
CO
C
V
V
12
ADDSUB8
1×
4
25×
ADDSUB8
A0
GND
A1
GND
A2
GND
A3
GND
A4
GND
A5
GND
A6
GND
A7
GND
B0
S0
B1
S1
B2
S2
B3
S3
B4
S4
B5
S5
B6
S6
B7
S7
SUB
S7
S0
M0
S1
M1
S2
M2
S3
M3
S4
M4
S5
M5
S6
M6
S7
M7
CO
V
© 2026 Daniil Khanin · khanin.info · HB-02
37
CANVAS …
13
2×
2×
S7
V
14
4b
0
A
3×
8b
DEC
A
8b
DEC
B
8b
DEC
M
A
0
A7
0
A6
0
A5
0
A4
0
A3
0
A2
1
A1
1
A0
B
0
B7
0
B6
0
B5
0
B4
0
B3
1
B2
0
B1
1
B0
1
SUB
2
M
−
V
A
0
A7
1
A6
1
A5
0
A4
0
A3
1
A2
0
A1
0
A0
B
0
B7
0
B6
0
B5
1
B4
1
B3
0
B2
1
B1
1
B0
0
SUB
127
M
−
V
A
0
A7
0
A6
0
A5
0
A4
1
A3
0
A2
1
A1
0
A0
B
0
B7
1
B6
1
B5
0
B4
0
B3
1
B2
0
B1
0
B0
1
SUB
90
M
−
V
© 2026 Daniil Khanin · khanin.info · HB-02
38
← Back to the lesson
Lesson 5. The ± calculator: the minus on a lamp, the magnitude on the display