-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDIV16_8.ASM
84 lines (74 loc) · 2.6 KB
/
DIV16_8.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
LIST
; DIV16_8.ASM 16 by 8 Bit Division Routine v4.1 Inform Software Corporation
NOLIST
;*-----------------------------------------------------------------------------*
;*------------------------- fuzzyTECH MCU-MP V4.1 -----------------------------*
;* (c) 1995 Inform Software Corporation, 2001 Midwest Road, Oak Brook, IL60521 *
;*------------ (c) 1995 Inform GmbH, Pascalstr. 23, 52076 Aachen --------------*
;*-----------------------------------------------------------------------------*
;*------------------------ division routine 16 / 8 bit ------------------------*
;*-----------------------------------------------------------------------------*
;**************************************************************************
;* *
;* Input: 16 bit unsigned fixed point dividend in FAARG+0, FAARG+1 *
;* 8 bit unsigned fixed point divisor in FBARG+0 *
;* *
;* Output: 16 bit unsigned fixed point quotient in FAARG+0, FAARG+1 *
;* 8 bit unsigned fixed point remainder in FREM +0 *
;* *
;* Result: FAARG, FREM <-- FAARG / FBARG *
;* *
;**************************************************************************
div16_8
if FAMILY < 2
clrf FREM
clrf FTcount
bsf FTcount,4
divLoop
rlf FAARG+1,F
rlf FAARG+0,F
rlf FREM,F
movf FBARG+1,W
btfss _C
goto no_carry
subwf FREM,F
bsf _C
goto no_sub
no_carry
subwf FREM,W
btfsc _C
movwf FREM
no_sub
decfsz FTcount,F
goto divLoop
rlf FAARG+1,F
rlf FAARG+0,F
else
clrf FREM,F
clrf FTcount,F
bsf FTcount,4
divLoop
rlcf FAARG+1,F
rlcf FAARG+0,F
rlcf FREM,F
movfp FBARG+1,WREG
btfss _C
goto no_carry
subwf FREM,F
bsf _C
goto no_sub
no_carry
subwf FREM,W
btfsc _C
movwf FREM
no_sub
decfsz FTcount,F
goto divLoop
rlcf FAARG+1,F
rlcf FAARG+0,F
endif
if FAMILY > 0
return
endif
; The end of module div16_8
LIST