2 – zero flag, 3 – equals flag, 4 – carry flag – Maxim Integrated DS4830A Optical Microcontroller User Manual

Page 196: Ds4830a user’s guide

Advertising
background image

DS4830A User’s Guide

196

Since the Sign flag is a dynamic reflection of the high bit of the active accumulator, any instruction that changes the
value in the active accumulator can potentially change the value of the Sign flag. Also, any instruction that changes
which accumulator is the active one (including AP auto-increment/decrement) can also change the Sign flag.

The following operation uses the Sign flag:

JUMP S, src

; Jump if Sign flag is set

23.6.2 – Zero Flag
The Zero flag (PSF.7) is a dynamic flag that reflects the current state of the active accumulator, Acc. If all bits in the
active accumulator are zero, the Zero flag will equal 1. Otherwise, it will equal 0.

Since the Zero flag is a dynamic reflection of (Acc == 0), any instruction that changes the value in the active
accumulator can potentially change the value of the Zero flag. Also, any instruction that changes which accumulator
is the active one (including AP auto-increment/decrement) can also change the Zero flag.

The following operations use the Zero flag:

JUMP Z, src

; Jump if Zero flag is set

JUMP NZ, src

; Jump if Zero flag is cleared


23.6.3 – Equals Flag
The Equals flag (PSF.0) is a static flag set by the CMP instruction. When the source given to the CMP instruction is
equal to the active accumulator, the Equals flag is set to 1. When the source is different from the active accumulator,
the Equals flag is cleared to 0.

The following instructions use the value of the Equals flag. Note that the ‘src’ for the JUMP E/NE instructions must be
immediate.

JUMP E, src

; Jump if Equals flag is set

JUMP NE, src

; Jump if Equals flag is cleared

In addition to the CMP instruction, any instruction using PSF as the destination can alter the Equals flag.

23.6.4 – Carry Flag
The Carry flag (PSF.1) is a static flag indicating that a carry or borrow bit resulted from the last ADD/ADDC or
SUB/SUBB operation. Unlike the other status flags, it can be set or cleared explicitly and is also used as a generic bit
operand by many other instructions.

The following instructions can alter the Carry flag:

• ADD src

(Add source to active accumulator)

• ADDC src

(Add source and Carry to active accumulator)

• SUB src

(Subtract source from active accumulator)

• SUBB src

(Subtract source and Carry from active accumulator)

• SLA, SLA2, SLA4

(Arithmetic shift left active accumulator)

• SRA, SRA2, SRA4

(Arithmetic shift right active accumulator)

• SR

(Shift active accumulator right)

• RLC / RRC

(Rotate active accumulator left / right through Carry)

• MOVE C, Acc.<b>

(Set Carry to selected active accumulator bit)

• MOVE C, #i

(Explicitly set, i=1, or clear, i=0, the Carry flag)

• CPL C

(Complement Carry)

• MOVE C, src.<b>

(Copy bit addressable register bit to Carry)

any instruction using PSF as the destination


The following instructions use the value of the Carry flag:

• ADDC src

(Add source and Carry to active accumulator)

• SUBB src

(Subtract source and Carry from active accumulator)

• RLC / RRC

(Rotate active accumulator left / right through Carry)

• CPL C

(Complement Carry)

• MOVE Acc.<b>, C

(Set selected active accumulator bit to Carry)

• AND Acc.<b>

(Carry = Carry AND selected active accumulator bit)

• OR Acc.<b>

(Carry = Carry OR selected active accumulator bit)

Advertising