Thursday, May 26, 2016

8051 Program - signed 16bit multiply Accumulate

; subroutine MAC16
; 16-Bit x 16-Bit to 32-Bit Product signed Multiply-Accumulate
; 2's Complement format
;
; input: r1, r0 = multiplicand X
; r3, r2 = multiplier Y
; r7, r6, r5, r4 = 32-bit accumulator Ar
;
; output: r7, r6, r5, r4 = accumulated result Ar = Ar + (X x Y)
; r3, r2, r1, r0 = multiply result M = X x Y
; Carry C set if overflow
;
; calls: MUL16
;
; alters: acc, C, Bits 21H & 22H

MAC16:anl PSW, #0E7H ;Register Bank 0
acall MUL16+3
mov A, r4
add A, r0
mov r4, A
mov A, r5
addc A, r1
mov r5, A
mov A, r6
addc A, r2
mov r6, A
mov A, r7
addc A, r3
mov r7, A
mov C, OV
ret


Source: Maths Subroutines for the 8051 microcontroller, W.G.Marshall 2002



Related topics:
8051 Program - signed 8bit multiplication   |   8051 Program - unsigned 8bit multiplication   |   8051 Program - signed 8bit x 16bit multiplication   |   8051 Program - signed 16bit multiplication   |   8051 Program - unsigned 16bit multiplication   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment