Kits
›
Cómo cuenta un procesador
RU
EN
ES
Contenido
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 4 in pictures
← Back to the lesson: Lesson 4. 8 bits and comparison: CMP is subtraction
4
8 bits and comparison
two ADDSUB4 in a chain, lamps = < >
kh
HB-02
A
0
A7
0
A6
0
A5
0
A4
0
A3
1
A2
0
A1
1
A0
B
0
B7
0
B6
0
B5
0
B4
1
B3
0
B2
0
B1
1
B0
1
SUB
A=B
A<B
A>B
5 − 9: A < B
IN
17×
OUT
10×
ADDSUB4
2×
3
0
17×
OR
6×
1
NOR
1×
1
NOT
2×
1
AND
4×
1
7×
4b
0
A
3×
∞
Ctrl
+
G
ADDSUB8
© 2026 Daniil Khanin · khanin.info · HB-02
24
CANVAS
1
Delete
0
A0
0
A1
0
A2
0
A3
0
B0
0
B1
0
B2
0
B3
0
SUB
2
Delete
OR
I0
S0
I1
S1
O0
z01
OR
I0
S2
I1
S3
O0
z23
NOR
I0
z01
I1
z23
O0
Z
C
Z
S3
V
4b
DEC
A
4b
DEC
B
3
Delete
4b
BIN
S
© 2026 Daniil Khanin · khanin.info · HB-02
25
CANVAS …
4
Delete
ADDSUB4
A0
A0
A1
A1
A2
A2
A3
A3
B0
B0
B1
B1
B2
B2
B3
B3
SUB
SUB
CI
SUB
S0
S0
S1
S1
S2
S2
S3
S3
CO
C
V
V
© 2026 Daniil Khanin · khanin.info · HB-02
26
ADDSUB8
5
IN
17×
OUT
10×
A0
A1
A2
A3
A4
A5
A6
A7
B0
B1
B2
B3
B4
B5
B6
B7
SUB
S0
S1
S2
S3
S4
S5
S6
S7
CO
V
6
ADDSUB4
1×
3
15×
ADDSUB4
A0
A0
A1
A1
A2
A2
A3
A3
B0
B0
B1
B1
B2
B2
B3
B3
SUB
SUB
CI
SUB
S0
S0
S1
S1
S2
S2
S3
S3
CO
c4
V
7
ADDSUB4
1×
3
16×
ADDSUB4
A0
A4
A1
A5
A2
A6
A3
A7
B0
B4
B1
B5
B2
B6
B3
B7
SUB
SUB
CI
c4
S0
S4
S1
S5
S2
S6
S3
S7
CO
CO
V
V
© 2026 Daniil Khanin · khanin.info · HB-02
27
ADDSUB8 …
CANVAS
8
Ctrl
+
G
Library
…
Chip N
2×
Library
…
ADDSUB8
Enter
ADDSUB8
A0
A1
A2
A3
A4
A5
A6
A7
B0
B1
B2
B3
B4
B5
B6
B7
SUB
S0
S1
S2
S3
S4
S5
S6
S7
CO
V
9
0
5×
5×
0
A0
0
A1
0
A2
0
A3
0
A4
10
0
5×
5×
0
A5
0
A6
0
A7
0
B0
0
B1
11
0
5×
5×
0
B2
0
B3
0
B4
0
B5
0
B6
12
0
2×
2×
0
B7
0
SUB
© 2026 Daniil Khanin · khanin.info · HB-02
28
CANVAS …
13
ADDSUB8
1×
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
14
OR
3×
1
9×
OR
I0
S0
I1
S1
O0
z01
OR
I0
S2
I1
S3
O0
z23
OR
I0
S4
I1
S5
O0
z45
15
OR
3×
1
9×
OR
I0
S6
I1
S7
O0
z67
OR
I0
z01
I1
z23
O0
z03
OR
I0
z45
I1
z67
O0
z47
© 2026 Daniil Khanin · khanin.info · HB-02
29
CANVAS …
16
NOR
1×
1
3×
NOR
I0
z03
I1
z47
O0
Z
17
NOT
2×
1
AND
1×
1
7×
NOT
I0
C
O0
nC
NOT
I0
Z
O0
nZ
AND
I0
SUB
I1
Z
O0
EQ
18
AND
3×
1
9×
AND
I0
SUB
I1
nC
O0
LT
AND
I0
C
I1
nZ
O0
cnz
AND
I0
SUB
I1
cnz
O0
GT
© 2026 Daniil Khanin · khanin.info · HB-02
30
CANVAS …
19
5×
5×
C
Z
S7
V
EQ
20
2×
2×
LT
GT
21
4b
0
A
3×
8b
DEC
A
8b
DEC
B
8b
DEC
S
A
0
A7
0
A6
0
A5
0
A4
0
A3
1
A2
1
A1
1
A0
B
0
B7
0
B6
0
B5
0
B4
0
B3
1
B2
1
B1
1
B0
1
SUB
0
S
=
<
>
A
0
A7
0
A6
0
A5
0
A4
0
A3
1
A2
0
A1
1
A0
B
0
B7
0
B6
0
B5
0
B4
1
B3
0
B2
0
B1
1
B0
1
SUB
252
S
=
<
>
A
1
A7
1
A6
0
A5
0
A4
1
A3
0
A2
0
A1
0
A0
B
1
B7
0
B6
0
B5
1
B4
0
B3
1
B2
1
B1
0
B0
1
SUB
50
S
=
<
>
© 2026 Daniil Khanin · khanin.info · HB-02
31
← Back to the lesson
Lesson 4. 8 bits and comparison: CMP is subtraction