Commodore 128 Programmer's Reference Manual page 168

Hide thumbs Also See for 128:
Table of Contents

Advertisement

158
COMMODORE 128
SET AND CLEAR INSTRUCTIONS
The set and clear instructions are designed to manipulate the bits (flags) within the status
register and control certain conditions within the microprocessor. These are the set and
clear instructions available in 8502 machine language:
SEC
Set the Carry Flag
SED
Set Decimal Mode
SEI
Set the Interrupt Disable Bit
CLC
Clear the Carry Flag
CLD
Clear Decimal Mode
CLI
Clear the Interrupt Disable Bit
CLV
Clear the Overflow Rag
Each of these instructions applies to a flag in the status register that controls a
particular microprocessor condition. Notice that each clear instruction has a counterpart
which sets the condition, except for CLV (Clear Overflow Flag). The overflow flag can
be set by the BIT instruction or from the result of a signed mathematical operation
overflowing into the sign bit.
Figure 5-11 shows the 8502 status register:
y
u
I—I
u
lB|ph|Z|C|
PROCESSOR STATUS REG "P"
-►CARRY
1 .TRUE
-►ZERO
1 * RESULT ZERO
-►IRQ DISABLE
1 * DISABLE
-► DECIMAL MODE
1 = TRUE
-► BRK COMMAND
-►OVERFLOW
-► NEGATIVE
TRUE
NEG
u
Figure 5-I I. 8502 Status Register
The flags of the status register are set for various reasons. For example, set
decimal mode when you want to perform calculations in binary coded decimal (BCD)
notation rather than hexadecimal. Set the carry flag when you are performing subtrac
tion. Set the interrupt disable bit when you want to prevent interrupts from occurring.
An example of a split screen, smooth scrolling raster interrupt routine is given at the end
of Chapter 8.
The clear instructions operate in the reverse of the set instructions. To make sure
that a carry does not occur during an addition operation, clear the carry flag before
U

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents