; Description:
; Signed Divide Of R2/3 By R4/5
;
; Entry Requirements:
; Divisor In R4/5
; Dividend In R2/3
;
; On Exit:
; Quotient In R2/3
; Remainder In R4/5
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc, B, R2, R3, R4, R5
;
; Stack:
; 5 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; Swiped From A Now Defunct 'C' Compiler
;
UTIL_DIV:
push 0 ;
push 1 ;
mov a,r4 ;
xrl a,r2 ;
push acc ;
call NEGEM ;
call DIVIDE ;
pop acc ;
jnb acc.7,loop1 ;
clr a ;
clr c ;
subb a,r3 ;
mov r3,a ;
clr a ;
subb a,r2 ;
mov r2,a ;
loop1: pop 1 ;
pop 0 ;
ret ; done!
Source: Assorted Utilities, John C. Wren 11/23/96
Related topics:
8051 Program - count ascii decimal in string | 8051 Program - unsigned divide | 8051 Program - unsigned mod | 8051 Program - signed mod | 8051 Program - sign fixup for divide | 8051 Program - divide | 8051 Program - memory subroutines | 8051 Program - math subroutines | 8051 Program - conversion subroutines
List of topics: 8051
No comments:
Post a Comment