Download Print this page

RCA COSMAC User Manual page 21

Hide thumbs Also See for COSMAC:

Advertisement

20 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ User Manual for the
The 0 byte.and M(R(X)) are the two operands. The result byte replaces the 0 operand. This instruction can
be used to compare two bytes for equality since identical values will result in all zeros in O.
A
00
33
N
3
cb
p
0
-
X
1
ADDRESS
M
I
F
00
30
01
R(O)
00
71
00
31
00
Rill
00
33
-
ALU
(@)/--
N
3
0
ADDRESS
M
00
30
01
R(O)
00
71
00
31
00
R(lI
00
33
00
32
92
R(2)
00
32
DF
=-
t
00
32
92
R(21
00
32
00
33
57
R(31
-
-
D
92
00
33
57
R(3)
' "
57
Fig. 18 - Example of instruction F3 - EXCLUSIVE-OR.
ADD
M(R(X))+O~O;C~OF
I
Aool
When I=F and N=4, the two 8-bit operands are added together. The 0 byte and M(R(X)) are the two
single-byte operands. The 8-bit result of the binary addition replaces the
0
operand. The final state of OF
indicates whether or not carry occurred:
3A + 4B = 85 (OF=O)
3A+ FO = 2A (OF=1)
OF can be subsequently tested with a branch instruction.
A
00
33
N
4
cb
p
0
-
X
1
ADDHI:SS
M
00
30
01
I
F
RIOI
00
71
00
31
00
Rill
00
33
-
ALU
(+1 / - -
ADDRESS
M
00
30
01
RIOI
00
31
00
R(lI
00
32
92
R(21
00
32
DF
=-
t
00
32
92
RI21
00
33
57
R(3)
-
-
D
92
00
33
57
RI31
57
Fig.
19 -
Example of instruction F4 - ADD.
SUBTRACT 0
M(R(X))-O~O;C~OF
N
4
P
0
00
71
00
33
00
32
-
SO
When I=F and N=5, the byte in 0 is subtracted from the memory byte addressed by R(X). The 8-bit
result replaces the subtrahend in the 0 register. Subtraction is 2's complement: each bit of the subtrahend
is complemented and the resultant byte added to the minuend plus 1. The final carry of this operation is
stored in OF:
42 -OE = 42+F1+ = 34 (OF = 1)
42 -42 = 42+BO+1 = 00 (OF = 1)
42 -77 = 42 +88+1 = CB (OF = 0)

Advertisement

loading