Thursday, May 26, 2016

8051 Program - signed 16bit multiplication

; subroutine MUL16
; 16-Bit x 16-Bit to 32-Bit Product Signed Multiply
; 2's Complement format
;
; input: r1, r0 = multiplicand X
; r3, r2 = multiplier Y
;
; output: r3, r2, r1, r0 = product P = X x Y
;
; calls: UMUL16, Cr0r1, Cr2r3, Mr0r3
;
; alters: acc, C, Bits 21H & 22H

MUL16:anl PSW, #0E7H ;Register Bank 0
acall Cr0r1 ;2's comp -> Mag/Sign
acall Cr2r3 ;2's comp -> Mag/Sign
acall UMUL16
acall Mr0r3 ;Mag/Sign -> 2's Comp
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 - unsigned 16bit multiplication   |   8051 Program - signed 16bit multiply Accumulate   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment