beautypg.com

5 overflow flag, 7 controlling program flow, 1 obtaining the next execution address – Maxim Integrated MAXQ610 User Manual

Page 47: 2 unconditional jumps, 3 .6 .5 overflow flag -12, 3 .7 controlling program flow -12, Maxq610 user’s guide

background image

3-12

MAXQ610 User’s Guide

• MOVE Acc., C

(Set selected active accumulator bit to carry)

• AND Acc.

(Carry = carry AND selected active accumulator bit)

• OR Acc.

(Carry = carry OR selected active accumulator bit)

• XOR Acc.

(Carry = carry XOR selected active accumulator bit)

• JUMP C, src

(Jump if carry flag is set)

• JUMP NC, src

(Jump if carry flag is cleared)

3.6.5 Overflow Flag

The overflow flag (PSF .2) is a static flag indicating that the carry or borrow bit (carry status flag) resulting from the last
ADD/ADDC or SUB/SUBB operation, but did not match the carry or borrow of the high order bit of the active accumula-
tor . The overflow flag is useful when performing signed arithmetic operations .
The following instructions can alter the overflow 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)

3.7 Controlling Program Flow

The MAXQ610 provides several options to control program flow and branching . Jumps can be unconditional, condi-
tional, relative, or absolute . Subroutine calls store the return address on the soft stack for later return . Built-in counters
and address registers are provided to control looping operations .

3.7.1 Obtaining the Next Execution Address

The address of the next instruction to be executed can be read at any time by reading the IP register . This can be
particularly useful for initializing loops, as shown in the following sections . Note that the value returned is actually the
address of the current instruction plus 1, so this is the address of the next instruction executed as long as the current
instruction does not cause a jump .

3.7.2 Unconditional jumps

An unconditional jump can be relative (IP +127/-128 words) or absolute (to anywhere in program space) . Relative
jumps must use an 8-bit immediate operand, such as:
Label1:

; must be within +127/-128 words of the JUMP

....

jump Label1

Absolute jumps can use either a 16-bit immediate operand, a 16-bit register, or an 8-bit register .

jump LongJump

; assembles to: move PFX[0], #high(LongJump)

; jump #low(LongJump)

jump DP[0]

; absolute jump to the address in DP[0]

If an 8-bit register is used as the jump destination, the prefix value is used as the high byte of the address and the
register is used as the low byte .