beautypg.com

4 alu operations using o, 5 alu bit operations usi, 6 maxq10 example: adding – Maxim Integrated MAXQ Family User Manual

Page 34: Maxq family user’s guide

background image

3-9

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 four times

sr

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

; set Acc.7 to zero (MAXQ10)

; set Acc.15 to zero (MAXQ20)

sra

; Shift accumulator right arithmetically once

sra2

; Shift accumulator right arithmetically twice

sra4

; Shift accumulator right arithmetically four times

xchn

; Swap low and high nibbles of each Acc byte

xch (MAXQ20 only)

; Swap low byte and high byte of Acc

3.5.5 ALU Bit Operations Using Only the Active Accumulator

The following operations operate on single bits of the current active accumulator in conjunction with the Carry flag. Any of these oper-

ations may use an Acc bit from 0 to 7 (for MAXQ10) or from 0 to 15 (for MAXQ20).

move C, Acc.0

; copy bit 0 of accumulator to Carry

move Acc.5, C

; copy Carry to bit 5 of accumulator

and Acc.3

; Acc.3 = Acc.3 AND Carry

or Acc.0

; Acc.0 = Acc.0 OR Carry

xor Acc.1

; Acc.1 = Acc.1 OR Carry

None of the above bit operations cause the auto-increment, auto-decrement, or modulo operations defined by the accumulator point-

er control (APC) register.

3.5.6 MAXQ10 Example: Adding Two 4-Byte Numbers Using Auto-Increment

move A[0], #78h

; First number – 12345678h

move A[1], #56h

move A[2], #34h

move A[3], #12h

move A[4], #0AAh

; Second number – 0AAAAAAAh

move A[5], #0AAh

move A[6], #0AAh

move A[7], #0Ah

move AP, #00h

; A[0] is active accumulator

move APC, #02h

; Increment low two bits mod 4

add A[4]

; A[0] = 78h + AAh = 22h + Carry

addc A[5]

; A[1] = 56h + AAh + 1 = 01h + Carry

addc A[6]

; A[2] = 34h + AAh + 1 = DFh

addc A[7]

; A[3] = 12h + 0Ah = 1Ch

; 12345678h + 0AAAAAAAh = 1CDF0122h

MAXQ Family User’s Guide

Maxim Integrated