Commodore 128 Programmer's Reference Manual page 163

Hide thumbs Also See for 128:
Table of Contents

Advertisement

MACHINE LANGUAGE ON THE COMMODORE 128
153
/ I
If either of the operands equals 1, the resulting Boolean value is 1, except if both
operands are 1, then the result equals 0.
p
j j
Here's an example using this rule:
Contents of Memory Address = 10101001
R
Contents of Accumulator
= 10000011
i
J |
Result of the exclusive OR
= 00101010
) \
In this example, the operands are the same as in the previous OR example. Notice
bits 0 and 7 are now equal to 0 since both operands are equal to 1. All other bit values
p->
remain the same.
/ l
BIT
The BIT instruction performs a logical AND operation on the contents of the specified
(J
memory address and the contents of the accumulator, but the resulting value is not
' I
stored in the accumulator. Instead, the zero flag in the status register is set by the result
of the operation. The BIT instruction compares the contents of the accumulator and the
H
contents of the memory address, bit-for-bit. If the result of the operation of the
j |
accumulator being ANDed by a memory location is 0, then the zero flag (in the status
register) is set to a 1. Otherwise the zero flag is 0.
PYour machine language program can then act conditionally depending on the
result of the zero flag in the status register. In addition, bits 7 and 6 from the specified
'
memory address are moved into the negative-flag and overflow-flag bit positions in the
status register, respectively. These flags can also be used to perform conditional
Pi
instructions depending on the value of the flag. For example, the BIT instruction
i 1
performs the following:
n
7
0
1
NV BDIZC
Contents of Memory Address = 10101001
Contents of Accumulator
= 11001101
->
1 0
Result of BIT instruction
= 10001001
Status Register
(Not stored in accumulator)
Since the resulting bit pattern is not 0, the zero flag in the status register is 0.
In addition, bits 7 and 6 are placed in the bit positions of the negative and overflow
flags, respectively, in the status register. Notice the result of the BIT instruction's AND
operation is not stored in the accumulator. The original contents of the accumulator
remain intact. See the following example of 2-bit pattern operands that result in 0 when
ANDed:

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents