annotate src/math.inc @ 653:8bcd138ab744

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