0
|
1 ;=============================================================================
|
|
2 ;
|
634
|
3 ; File math.inc * combined next generation V3.09.4k
|
0
|
4 ;
|
|
5 ;
|
|
6 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
|
|
7 ;=============================================================================
|
|
8 ; HISTORY
|
|
9 ; 2011-08-03 : [mH] moving from OSTC code
|
|
10
|
604
|
11
|
634
|
12 ;-----------------------------------------------------------------------------
|
|
13 ; SHIFT-RIGHT with UNSIGNED values
|
|
14 ;
|
|
15 extern div16 ; divA:2 = divA:2 / 2^WREG
|
604
|
16 ; trashes WREG
|
|
17
|
634
|
18
|
|
19 ;-----------------------------------------------------------------------------
|
|
20 ; SHIFT-LEFT with UNSIGNED values
|
|
21 ;
|
|
22 extern mult16 ; divA:2 = divA:2 * 2^WREG
|
604
|
23 ; trashes WREG
|
|
24
|
634
|
25
|
|
26 ;-----------------------------------------------------------------------------
|
|
27 ; ADDITION with UNSIGNED values
|
|
28 ;
|
|
29 extern addU16 ; sub_c:2 = sub_a:2 + sub_b:2
|
628
|
30 ; trashes WREG
|
|
31
|
634
|
32
|
|
33 ;-----------------------------------------------------------------------------
|
|
34 ; SUBTRACTION with SIGNED values
|
|
35 ;
|
|
36 extern sub16 ; sub_c:2 = sub_a:2 - sub_b:2
|
604
|
37 ; sets neg_flag if result is < 0
|
|
38 ; trashes WREG
|
|
39
|
634
|
40
|
|
41 ;-----------------------------------------------------------------------------
|
|
42 ; SUBTRACTION with UNSIGNED values
|
|
43 ;
|
|
44 extern subU16 ; sub_c:2 = sub_a:2 - sub_b:2
|
604
|
45 ; sets neg_flag if result is < 0
|
|
46 ; trashes WREG
|
|
47
|
634
|
48
|
|
49 ;-----------------------------------------------------------------------------
|
|
50 ; COMPARE with UNSIGNED values
|
|
51 ;
|
|
52 extern cmpU16 ; trashed = sub_a:2 - sub_b:2
|
623
|
53 ; sets neg_flag if result is < 0, but does not store result itself
|
|
54 ; trashes WREG
|
|
55
|
634
|
56
|
|
57 ;-----------------------------------------------------------------------------
|
|
58 ; MULTIPLICATION with UNSIGNED values
|
|
59 ;
|
|
60 extern mult16x16 ; xC:4 = xA:2 * xB:2
|
604
|
61 ; trashes PRODL, PRODH, WREG
|
|
62
|
634
|
63
|
|
64 ;-----------------------------------------------------------------------------
|
|
65 ; DIVISION with UNSIGNED values
|
|
66 ;
|
|
67 extern div16x16 ; xC:2 = xA:2 / xB:2 with xA as remainder
|
604
|
68 ; trashes xB, WREG
|
|
69
|
634
|
70
|
|
71 ;-----------------------------------------------------------------------------
|
|
72 ; DIVISION with UNSIGNED values
|
|
73 ;
|
|
74 extern div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
|
604
|
75 ; trashes WREG
|
|
76
|
634
|
77
|
|
78 ;-----------------------------------------------------------------------------
|
|
79 ; Math Functions specific for Use by ISR
|
|
80 ;-----------------------------------------------------------------------------
|
|
81
|
|
82 ;-----------------------------------------------------------------------------
|
|
83 ; 24 bit shift, repeated WREG times, dedicated to a specific usage
|
|
84 ;
|
|
85 extern isr_shift_C31
|
604
|
86
|
631
|
87
|
634
|
88 ;-----------------------------------------------------------------------------
|
|
89 ; MULTIPLICATION with UNSIGNED values
|
|
90 ;
|
|
91 extern isr_unsigned_mult16x16 ; isr_xC = isr_xA * isr_xB
|
604
|
92 ; trashes PRODL, PRODH, WREG
|
643
|
93 ;-----------------------------------------------------------------------------
|
|
94 ; MULTIPLICATION with UNSIGNED values
|
|
95 ;
|
|
96 extern isr_unsigned_mult24x24 ; isr_xC = isr_xA * isr_xB
|
|
97 ; trashes PRODL, PRODH, WREG
|
|
98 extern isr_unsigned_mult32x24 ; isr_xC = isr_xA * isr_xB
|
|
99 ; trashes PRODL, PRODH, WREG
|
|
100
|
634
|
101 ;-----------------------------------------------------------------------------
|
|
102 ; MULTIPLICATION with SIGNED values
|
|
103 ;
|
|
104 extern isr_signed_mult16x16 ; isr_xC = isr_xA * isr_xB
|
604
|
105 ; trashes PRODL, PRODH, WREG
|
643
|
106
|
|
107 extern isr_signed_mult24x24
|
634
|
108
|
643
|
109 ;-----------------------------------------------------------------------------
|
|
110
|
|
111 ; DIVISION with UNSIGNED values
|
|
112 ;
|
|
113 extern isr_div16x16 ; isr_xC:2 = isr_xA:2 / isr_xB:2 with isr_xA as remainder
|
|
114 ; trashes xB, WREG
|
|
115
|
|
116 ;-----------------------------------------------------------------------------
|
|
117 ; DIVISION with UNSIGNED values
|
|
118 ;
|
|
119
|
|
120 extern isr_div32x16 ; isr_xC:4 = isr_xC:4 / isr_xB:2 with isr_xA as remainder
|