beautypg.com

4 alu operations using only the active accumulator – Maxim Integrated MAXQ622 User Manual

Page 45

background image

MAXQ612/MAXQ622 User’s Guide

Maxim Integrated

3-9

• Increment modulo 8: AP = AP[3] + ((AP[2:0] + 1) mod 8)
• Decrement modulo 8: AP = AP[3] + ((AP[2:0] - 1) mod 8)
• Increment modulo 16: AP = (AP + 1) mod 16
• Decrement modulo 16: AP = (AP - 1) mod 16
For this example, assume that all 16 accumulator registers are initially set to zero .

move

AP, #02h

; select A[2] as active accumulator

mov

APC, #02h

; auto-increment AP[1:0] modulo 4

; AP A[0] A[1] A[2] A[3]

; 02 0000 0000 0000 0000

add

#01h

; 03 0000 0000 0001 0000

add

#02h

; 00 0000 0000 0001 0002

add

#03h

; 01 0003 0000 0001 0002

add

#04h

; 02 0003 0004 0001 0002

add

#05h

; 03 0003 0004 0006 0002

3.5.3 ALU Operations Using the Active Accumulator and a Source

The following arithmetic and logical operations can use any register or immediate value as a source . The active accu-
mulator, Acc, is always used as the second operand and the implicit destination . Also, Acc cannot be used as the
source for any of these operations .

add

A[4]

; Acc = Acc + A[4]

addc

#32h

; Acc = Acc + 0032h + Carry

sub

A[15]

; Acc = Acc – A[15]

subb

A[1]

; Acc = Acc – A[1] - Carry

cmp

#00h

; If (Acc == 0000h), set Equals flag

and

A[0]

; Acc = Acc AND A[0]

or

#55h

; Acc = Acc OR #0055h

xor

A[1]

; Acc = Acc XOR A[1]

3.5.4 ALU Operations Using Only the Active Accumulator

The following arithmetic and logical operations operate only on the active accumulator .

cpl

; Acc = NOT Acc

neg

; Acc = (NOT Acc) + 1

rl

; Rotate accumulator left (not using Carry)

rlc

; Rotate accumulator left through Carry

rr

; Rotate accumulator right (not using Carry)

rrc

; Rotate accumulator right through Carry

sla

; Shift accumulator left arithmetically once

sla2

; Shift accumulator left arithmetically twice

sla4

; Shift accumulator left arithmetically 4 times

sr

; Shift accumulator right, set Carry to Acc.0,

; set Acc.15 to zero

This manual is related to the following products: