Thursday, May 26, 2016

8051 Program - signed 8bit division

; subroutine DIV8
; 8-Bit / 8-Bit to 8-Bit Quotient & Remainder signed Divide
; 2's Complement Format
;
; input: r0 = Dividend X
; r1 = Divisor Y
;
; output: r0 = quotient Q of division Q = X / Y
; r1 = remainder
;
; calls: Cr0, Cr1, Mr0
;
; alters: acc, C, Bits 21H & 22H

DIV8:anl PSW, #0E7H ;Register Bank 0
acall Cr0 ;2's comp -> Mag/Sign
acall Cr1 ;2's comp -> Mag/Sign
acall UDIV8
acall Mr0 ;Mag/Sign -> 2's Comp
ret


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



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

List of topics: 8051

No comments:

Post a Comment