113
Calculating with Signed Binary Data Section 1-10
1-10 Calculating with Signed Binary Data
The CQM1/CPM1/CPM1A/SRM1 allow calculations on signed binary data.
The following instructions manipulate signed binary data. Signed data is han-
dled using 2’s complements.
CQM1 Instructions The following signed-binary instructions are available in CQM1 PCs:
Single-word Instructions
• 2’S COMPLEMENT – NEG(––)
• BINARY ADD – ADB(50)
• BINARY SUBTRACT – SBB(51)
• SIGNED BINARY MULTIPLY – MBS(––)
• SIGNED BINARY DIVIDE – DBS(––)
Double-word (Long) Instructions
• DOUBLE 2’S COMPLEMENT – NEGL(––)
• DOUBLE BINARY ADD – ADBL(––)
• DOUBLE BINARY SUBTRACT – SBBL(––)
• DOUBLE SIGNED BINARY MULTIPLY – MBSL(––)
• DOUBLE SIGNED BINARY DIVIDE – DBSL(––)
CPM1/CPM1A/SRM1
Instructions
The following signed-binary instructions are available in CPM1/CPM1A/SRM1
PCs:
• BINARY ADD – ADB(50)
• BINARY SUBTRACT – SBB(51)
Signed Data Calculations
1-10-1 Definition of Signed Binary Data
The CQM1 provides instructions that operate on either one or two words of
data; the CPM1/CPM1A/SRM1 provide just two instructions that operate on
one word of data. Signed binary data is manipulated using 2’s complements
and the MSB of the one- or two-word data is used as the sign bit. The range of
data that can be expressed using one or two words is thus as follows:
• One-word data:
–32,768 to 32,767 (8000 to 7FFF hexadecimal)
•
Two-word data:
–2,147,483,648 to 2,147,483,647 (8000 0000 to 7FFF FFFF hexadeci-
mal)
Addition
7 + 3 = 10
(–7) + 3 = –4
7 + (–3) = 4
(–7) + (–3) = –10
Multiplication
7 × 3 = 21
(–7) × 3 = –21
7 × (–3) = –21
(–7) × (–3) = 21
Subtraction
7 – 3 = 4
(–7) – 3 = –10
7 – (–3) = 10
(–7) – (–3) = –4
Division
7 ÷ 3 = 2 with a remainder of 1
(–7) ÷ 3 = –2 with a remainder of –1
7 ÷ (–3) = –2 with a remainder of 1
(–7) ÷ (–3) = 2 with a remainder of –1