beautypg.com

5 using the arithmetic and logic unit, 1 selecting the active accumulator, 2 enabling auto-increment and auto-decrement – Maxim Integrated MAX31782 User Manual

Page 171: 19 .5 using the arithmetic and logic unit -6, 5usingthearithmeticandlogicunit

background image

19-6

MAX31782 User’s Guide

Revision 0; 8/11

19.5UsingtheArithmeticandLogicUnit

The MAX31782 provides a 16-bit ALU, which allows operations to be performed between the active accumulator and
any other register . The MAX31782 provides 16 accumulator registers, of which any one may be selected as the active
accumulator .

19.5.1SelectingtheActiveAccumulator

Any of the 16 accumulator registers A[0] through A[15] may be selected as the active accumulator by setting the low
four bits of the
Accumulator Pointer Register (AP) to the index of the accumulator register you want to select .

move

AP, #01h

; select A[1] as the active accumulator

move

AP, #0Fh

; select A[15] as the active accumulator

The current active accumulator can be accessed as the Acc register, which is also the register used as the implicit
destination for all arithmetic and logical operations .

move

A[0], #55h ; set A[0]

;

= 0055 hex

move

AP, #00h

; select A[0] as active accumulator

move

Acc, #55h

; set A[0]

;

= 0055 hex

19.5.2EnablingAuto-IncrementandAuto-Decrement

The accumulator pointer AP can be set to automatically increment or decrement after each arithmetic or logical opera-
tion . This is useful for operations involving a number of accumulator registers, such as adding or subtracting two mul-
tibyte integers .
If auto-increment/decrement is enabled, the AP register increments or decrements after any of the following operations:
• ADD src (Add source to active accumulator)
• ADDC src (Add source to active accumulator with carry)
• SUB src (Subtract source from active accumulator)
• SUBB src (Subtract source from active accumulator with borrow)
• AND src (Logical AND active accumulator with source)
• OR src (Logical OR active accumulator with source)
• XOR src (Logical XOR active accumulator with source)
• CPL (Bit-wise complement active accumulator)
• NEG (Negate active accumulator)
• SLA (Arithmetic shift left on active accumulator)
• SLA2 (Arithmetic shift left active accumulator two bit positions)
• SLA4 (Arithmetic shift left active accumulator four bit positions)
• SRA (Arithmetic shift right on active accumulator)
• SRA2 (Arithmetic shift right active accumulator two bit positions)
• SRA4 (Arithmetic shift right active accumulator four bit positions)
• RL (Rotate active accumulator left)
• RLC (Rotate active accumulator left through Carry flag)
• RR (Rotate active accumulator right)
• RRC (Rotate active accumulator right through Carry flag)
• SR (Logical shift active accumulator right)