3 alu operations using t, Maxq family user’s guide – Maxim Integrated MAXQ Family User Manual
Page 33
3-8
MAXQ Family User’s Guide
For the modulo increment or decrement operation, the selected range of bits in AP are incremented or decremented. However, if these
bits roll over or under, they simply wrap around without affecting the remaining bits in the accumulator pointer. So, the operations can
be defined as follows:
• Increment modulo 2: AP = AP[3:1] + ((AP[0] + 1) mod 2)
• Decrement modulo 2: AP = AP[3:1] + ((AP[0] - 1) mod 2)
• Increment modulo 4: AP = AP[3:2] + ((AP[1:0] + 1) mod 4)
• Decrement modulo 4: AP = AP[3:2] + ((AP[1:0] - 1) mod 4)
• 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
move 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
;
; *the upper #00h byte of each accumulator
; is only present on the MAXQ20 device
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 accumulator Acc is
always used as the second operand and the implicit destination. Also, Acc may not be used as the source for any of these operations.
add A[4]
; Acc = Acc + A[4]
addc #32h
; Acc = Acc + 32h + Carry (MAXQ10)
; Acc = Acc + 0032h + Carry (MAXQ20)
sub A[15]
; Acc = Acc – A[15]
subb A[1]
; Acc = Acc – A[1] - Carry
cmp #00h
; If (Acc == 00h), set Equals flag (MAXQ10)
; If (Acc == 0000h), set Equals flag (MAXQ20)
and A[0]
; Acc = Acc AND A[0]
or #55h
; Acc = Acc OR #55h (MAXQ10)
; Acc = Acc OR #0055h (MAXQ20)
xor A[1]
; Acc = Acc XOR A[1]
Maxim Integrated