summaryrefslogtreecommitdiff
path: root/mpu/mpu-integer.h
blob: 292398a5011dbbf00a431435475f84e6bf8198f7 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/***************************************************************
  __MPU_INTEGER.H

       This file contains declarations of functions for
       INTEGER arithmetic operations.

       PART OF : MPU - library .

       USAGE   : Internal only .

       NOTE    : Include "libmpu.h" before this FILE .

       Copyright (C) 2000 - 2024  by Andrew V.Kosteltsev.
       All Rights Reserved.
 ***************************************************************/

#ifndef   __MPU_INTEGER_H
#define   __MPU_INTEGER_H

#ifdef  __cplusplus
extern "C" {
#endif


extern void iadd_8( __mpu_uint8_t *c, __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void iadc_8( __mpu_uint8_t *c, __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void isub_8( __mpu_uint8_t *c, __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void isbb_8( __mpu_uint8_t *c, __mpu_uint8_t *a, __mpu_uint8_t *b );

extern void iadd_16( __mpu_uint16_t *c, __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void iadc_16( __mpu_uint16_t *c, __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void isub_16( __mpu_uint16_t *c, __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void isbb_16( __mpu_uint16_t *c, __mpu_uint16_t *a, __mpu_uint16_t *b );

extern void iadd_32( __mpu_uint32_t *c, __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void iadc_32( __mpu_uint32_t *c, __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void isub_32( __mpu_uint32_t *c, __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void isbb_32( __mpu_uint32_t *c, __mpu_uint32_t *a, __mpu_uint32_t *b );

extern void iadd_np( EMUSHORT *c, EMUSHORT *a, EMUSHORT *b, int np );
extern void iadc_np( EMUSHORT *c, EMUSHORT *a, EMUSHORT *b, int np );
extern void isub_np( EMUSHORT *c, EMUSHORT *a, EMUSHORT *b, int np );
extern void isbb_np( EMUSHORT *c, EMUSHORT *a, EMUSHORT *b, int np );


extern void ishl_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void ishr_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void isal_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void isar_8( __mpu_uint8_t *c, __mpu_uint8_t *a );

extern void ishl_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void ishr_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void isal_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void isar_16( __mpu_uint16_t *c, __mpu_uint16_t *a );

extern void ishl_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void ishr_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void isal_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void isar_32( __mpu_uint32_t *c, __mpu_uint32_t *a );

extern void ishl_np( EMUSHORT *c, EMUSHORT *a, int np );
extern void ishr_np( EMUSHORT *c, EMUSHORT *a, int np );
extern void isal_np( EMUSHORT *c, EMUSHORT *a, int np );
extern void isar_np( EMUSHORT *c, EMUSHORT *a, int np );


extern void irol_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void iror_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void ircl_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void ircr_8( __mpu_uint8_t *c, __mpu_uint8_t *a );

extern void irol_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void iror_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void ircl_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void ircr_16( __mpu_uint16_t *c, __mpu_uint16_t *a );

extern void irol_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void iror_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void ircl_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void ircr_32( __mpu_uint32_t *c, __mpu_uint32_t *a );

extern void irol_np( EMUSHORT *c, EMUSHORT *a, int np );
extern void iror_np( EMUSHORT *c, EMUSHORT *a, int np );
extern void ircl_np( EMUSHORT *c, EMUSHORT *a, int np );
extern void ircr_np( EMUSHORT *c, EMUSHORT *a, int np );


extern void ishln_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );
extern void ishrn_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );
extern void isaln_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );
extern void isarn_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );

extern void ishln_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );
extern void ishrn_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );
extern void isaln_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );
extern void isarn_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );

extern void ishln_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );
extern void ishrn_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );
extern void isaln_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );
extern void isarn_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );

extern void ishln_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );
extern void ishrn_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );
extern void isaln_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );
extern void isarn_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );


extern void iroln_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );
extern void irorn_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );
extern void ircln_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );
extern void ircrn_8( __mpu_uint8_t *c, __mpu_uint8_t *a, unsigned int b );

extern void iroln_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );
extern void irorn_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );
extern void ircln_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );
extern void ircrn_16( __mpu_uint16_t *c, __mpu_uint16_t *a, unsigned int b );

extern void iroln_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );
extern void irorn_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );
extern void ircln_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );
extern void ircrn_32( __mpu_uint32_t *c, __mpu_uint32_t *a, unsigned int b );

extern void iroln_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );
extern void irorn_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );
extern void ircln_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );
extern void ircrn_np( EMUSHORT *c, EMUSHORT *a, unsigned int b, int np );


extern void inot_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void inot_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void inot_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void inot_np( EMUSHORT *c, EMUSHORT *a, int np );

extern void ineg_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void ineg_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void ineg_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void ineg_np( EMUSHORT *c, EMUSHORT *a, int np );

extern void iand_8( __mpu_uint8_t *c, __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void iand_16( __mpu_uint16_t *c, __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void iand_32( __mpu_uint32_t *c, __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void iand_np( EMUSHORT *c, EMUSHORT *a, EMUSHORT *b, int np );

extern void itest_8( __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void itest_16( __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void itest_32( __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void itest_np( EMUSHORT *a, EMUSHORT *b, int np );

extern void icmp_8( __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void icmp_16( __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void icmp_32( __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void icmp_np( EMUSHORT *a, EMUSHORT *b, int np );

extern void ior_8( __mpu_uint8_t *c, __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void ior_16( __mpu_uint16_t *c, __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void ior_32( __mpu_uint32_t *c, __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void ior_np( EMUSHORT *c, EMUSHORT *a, EMUSHORT *b, int np );

extern void ixor_8( __mpu_uint8_t *c, __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void ixor_16( __mpu_uint16_t *c, __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void ixor_32( __mpu_uint32_t *c, __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void ixor_np( EMUSHORT *c, EMUSHORT *a, EMUSHORT *b, int np );

extern void iinc_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void iinc_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void iinc_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void iinc_np( EMUSHORT *c, EMUSHORT *a, int np );

extern void idec_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void idec_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void idec_32( __mpu_uint32_t *c, __mpu_uint32_t *a );
extern void idec_np( EMUSHORT *c, EMUSHORT *a, int np );


extern void icpy_8( __mpu_uint8_t *c, __mpu_uint8_t *a );
extern void icpy_16( __mpu_uint16_t *c, __mpu_uint16_t *a );
extern void icpy_32( __mpu_uint32_t *c, __mpu_uint32_t *a );

extern void icpy_s2l_8to16( __mpu_uint16_t *c, __mpu_uint8_t *a );
extern void icpy_s2l_8to32( __mpu_uint32_t *c, __mpu_uint8_t *a );
extern void icpy_s2l_8to_np( EMUSHORT *c, __mpu_uint8_t *a, int np );

extern void icpy_s2l_16to32( __mpu_uint32_t *c, __mpu_uint16_t *a );
extern void icpy_s2l_16to_np( EMUSHORT *c, __mpu_uint16_t *a, int np );

#if BITS_PER_EMUSHORT > 32
extern void icpy_s2l_32to_np( EMUSHORT *c, __mpu_uint32_t *a, int np );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void icpy_l2s_16to8( __mpu_uint8_t *c, __mpu_uint16_t *a );
extern void icpy_l2s_32to8( __mpu_uint8_t *c, __mpu_uint32_t *a );
extern void icpy_l2s_np_to8( __mpu_uint8_t *c, EMUSHORT *a, int np );

extern void icpy_l2s_32to16( __mpu_uint16_t *c, __mpu_uint32_t *a );
extern void icpy_l2s_np_to16( __mpu_uint16_t *c, EMUSHORT *a, int np );

#if BITS_PER_EMUSHORT > 32
extern void icpy_l2s_np_to32( __mpu_uint32_t *c, EMUSHORT *a, int np );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void icpy_np( EMUSHORT *c, EMUSHORT *a, int np_c, int np_a );


extern void icvt_s2l_8to16( __mpu_uint16_t *c, __mpu_uint8_t *a );
extern void icvt_s2l_8to32( __mpu_uint32_t *c, __mpu_uint8_t *a );
extern void icvt_s2l_8to_np( EMUSHORT *c, __mpu_uint8_t *a, int np );

extern void icvt_s2l_16to32( __mpu_uint32_t *c, __mpu_uint16_t *a );
extern void icvt_s2l_16to_np( EMUSHORT *c, __mpu_uint16_t *a, int np );

#if BITS_PER_EMUSHORT > 32
extern void icvt_s2l_32to_np( EMUSHORT *c, __mpu_uint32_t *a, int np );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void icvt_l2s_16to8( __mpu_uint8_t *c, __mpu_uint16_t *a );
extern void icvt_l2s_32to8( __mpu_uint8_t *c, __mpu_uint32_t *a );
extern void icvt_l2s_np_to8( __mpu_uint8_t *c, EMUSHORT *a, int np );

extern void icvt_l2s_32to16( __mpu_uint16_t *c, __mpu_uint32_t *a );
extern void icvt_l2s_np_to16( __mpu_uint16_t *c, EMUSHORT *a, int np );

#if BITS_PER_EMUSHORT > 32
extern void icvt_l2s_np_to32( __mpu_uint32_t *c, EMUSHORT *a, int np );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void icvt_np( EMUSHORT *c, EMUSHORT *a, int np_c, int np_a );


extern void ixchg_8( __mpu_uint8_t *a, __mpu_uint8_t *b );
extern void ixchg_16( __mpu_uint16_t *a, __mpu_uint16_t *b );
extern void ixchg_32( __mpu_uint32_t *a, __mpu_uint32_t *b );
extern void ixchg_np( EMUSHORT *a, EMUSHORT *b, int np );


extern void imul_8( __mpu_uint16_t *prod, __mpu_uint8_t *num, __mpu_uint8_t *mul );
extern void imul_16( __mpu_uint32_t *prod, __mpu_uint16_t *num, __mpu_uint16_t *mul );
#if BITS_PER_EMUSHORT > 32 /* 64 bits only */
extern void imul_32( __mpu_uint64_t *prod, __mpu_uint32_t *num, __mpu_uint32_t *mul );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void ismul_8( __mpu_uint16_t *prod, __mpu_uint8_t *num, __mpu_uint8_t *mul );
extern void ismul_16( __mpu_uint32_t *prod, __mpu_uint16_t *num, __mpu_uint16_t *mul );
#if BITS_PER_EMUSHORT > 32 /* 64 bits only */
extern void ismul_32( __mpu_uint64_t *prod, __mpu_uint32_t *num, __mpu_uint32_t *mul );
#endif /* BITS_PER_EMUSHORT > 32 */


extern void idiv_8( __mpu_uint8_t *quot, __mpu_uint8_t *rem, __mpu_uint8_t *num, __mpu_uint8_t *den );
extern void idiv_16( __mpu_uint16_t *quot, __mpu_uint16_t *rem, __mpu_uint16_t *num, __mpu_uint16_t *den );
#if BITS_PER_EMUSHORT > 32 /* 64 bits only */
extern void idiv_32( __mpu_uint32_t *quot, __mpu_uint32_t *rem, __mpu_uint32_t *num, __mpu_uint32_t *den );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void isdiv_8( __mpu_uint8_t *quot, __mpu_uint8_t *rem, __mpu_uint8_t *num, __mpu_uint8_t *den );
extern void isdiv_16( __mpu_uint16_t *quot, __mpu_uint16_t *rem, __mpu_uint16_t *num, __mpu_uint16_t *den );
#if BITS_PER_EMUSHORT > 32 /* 64 bits only */
extern void isdiv_32( __mpu_uint32_t *quot, __mpu_uint32_t *rem, __mpu_uint32_t *num, __mpu_uint32_t *den );
#endif /* BITS_PER_EMUSHORT > 32 */


extern void imul_np( EMUSHORT *prod, EMUSHORT *num, EMUSHORT *mul, int np_prod, int np_num );
extern void ismul_np( EMUSHORT *prod, EMUSHORT *num, EMUSHORT *mul, int np_prod, int np_num );

extern void idiv_np( EMUSHORT *quot, EMUSHORT *rem, EMUSHORT *num, EMUSHORT *den, int np );
extern void isdiv_np( EMUSHORT *quot, EMUSHORT *rem, EMUSHORT *num, EMUSHORT *den, int np );


extern void iatoi_8( __mpu_uint8_t *c, __mpu_char8_t *str );
extern void iatoui_8( __mpu_uint8_t *c, __mpu_char8_t *str );

extern void iatoi_16( __mpu_uint16_t *c, __mpu_char8_t *str );
extern void iatoui_16( __mpu_uint16_t *c, __mpu_char8_t *str );

#if BITS_PER_EMUSHORT > 32 /* 64 bits only */
extern void iatoi_32( __mpu_uint32_t *c, __mpu_char8_t *str );
extern void iatoui_32( __mpu_uint32_t *c, __mpu_char8_t *str );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void iatoi_np( EMUSHORT *c, __mpu_char8_t *str, int np );
extern void iatoui_np( EMUSHORT *c, __mpu_char8_t *str, int np );


extern void iitoa_8( __mpu_char8_t *str, __mpu_uint8_t *a, int radix, int uf );
extern void iuitoa_8( __mpu_char8_t *str, __mpu_uint8_t *a, int radix, int uf );

extern void iitoa_16( __mpu_char8_t *str, __mpu_uint16_t *a, int radix, int uf );
extern void iuitoa_16( __mpu_char8_t *str, __mpu_uint16_t *a, int radix, int uf );

#if BITS_PER_EMUSHORT > 32 /* 64 bits only */
extern void iitoa_32( __mpu_char8_t *str, __mpu_uint32_t *a, int radix, int uf );
extern void iuitoa_32( __mpu_char8_t *str, __mpu_uint32_t *a, int radix, int uf );
#endif /* BITS_PER_EMUSHORT > 32 */

extern void iitoa_np( __mpu_char8_t *str, EMUSHORT *a, int radix, int uf, int np );
extern void iuitoa_np( __mpu_char8_t *str, EMUSHORT *a, int radix, int uf, int np );




#ifdef  __cplusplus
}   /* ... extern "C" */
#endif

#endif /* __MPU_INTEGER_H */