; subroutine UDIV8
; 8-Bit / 8-Bit to 8-Bit Quotient & Remainder Unsigned Divide
;
; input: r0 = Dividend X
; r1 = Divisor Y
;
; output: r0 = quotient Q of division Q = X / Y
; r1 = remainder
;
; alters: acc, C
UDIV8: push b
mov a, r0 ;read X and ...
mov b, r1 ;... Y
div ab ;divide X and Y
mov r0, a ;save result quotient
mov r1, b ;save remainder
pop b
ret
Source: Maths Subroutines for the 8051 microcontroller, W.G.Marshall 2002
Related topics:
8051 Program - signed 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