Netcruzer Library API
V2.03
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Macros
Groups
Pages
nz_helpersCx.h
Go to the documentation of this file.
1
46
#ifndef NZ_HELPERS_CX_H
47
#define NZ_HELPERS_CX_H
48
49
#if defined(HAS_WEBSERVER)
50
//Function prototypes for functions defined in Helpers.h
51
BYTE btohexa_high(BYTE b);
52
BYTE btohexa_low(BYTE b);
53
#endif
54
55
56
#if defined(__C30__)
57
#define nzWordSwapBytes_ASM_R(W) \
58
{ asm( "SWAP.w %0" \
59
: "+r" (W)
/*outputs*/
); }
60
#elif defined(__PIC32MX__)
61
//TODO PIC32MX - Fix this function! Current code is just to get XC32 to compiler for testing!
62
#else
63
#error "Unknown processor or compiler."
64
#endif
65
73
#if defined(__C30__)
74
#define nzWordBitToggle(w, bitPosition) __builtin_btg(w,bitPosition)
75
#elif defined(__PIC32MX__)
76
//TODO PIC32MX - Fix this function! Current code is just to get XC32 to compiler for testing!
77
#else
78
#error "Unknown processor or compiler."
79
#endif
80
81
82
#if defined(__C30__)
83
#define nzByteSwapNibble_ASM_R(W) \
84
{ asm("SWAP.b %0" \
85
: "+r"(W)
/*outputs*/
); }
86
#elif defined(__PIC32MX__)
87
#else
88
#error "Unknown processor or compiler."
89
#endif
90
91
102
#if defined(__C30__)
103
#define nzWordPosOfFirstMsbBit_ASM(W, WPos) \
104
{ asm( "FF1L %1,%0" \
105
: "=r"(WPos)
/*outputs*/
\
106
: "r"(W)
/*inputs*/
); }
107
#elif defined(__PIC32MX__)
108
#else
109
#error "Unknown processor or compiler."
110
#endif
111
112
123
#if defined(__C30__)
124
#define nzWordPosOfFirstLsbBit_ASM(W, WPos) \
125
{ asm( "FF1R %1,%0" \
126
: "=r"(WPos)
/*outputs*/
\
127
: "r"(W)
/*inputs*/
); }
128
#elif defined(__PIC32MX__)
129
#else
130
#error "Unknown processor or compiler."
131
#endif
132
133
153
#if defined(__C30__)
154
//#define nzWordPosOfFirstChangeMsb( W, WPos) asm( "FBCL %1,%0" : "=r"(WPos) /*outputs*/ : "r"(W) /*inputs*/)
155
#define nzWordPosOfFirstChangeMsb(value) __builtin_fbcl(value);
156
#elif defined(__PIC32MX__)
157
#else
158
#error "Unknown processor or compiler."
159
#endif
160
161
176
BYTE
nzBytePosOfFirstClearedMsbBit
(BYTE b);
177
178
190
BYTE
nzBytePosOfFirstClearedLsbBit
(BYTE b);
191
192
193
#if defined(__C30__)
194
#define nzWordShiftLefs_ASM(W, Number) \
195
{ asm( "SL %0, #%1, %0" \
196
: "+r" (W)
/*outputs*/
\
197
: "i" (Number)
/*inputs*/
); }
198
#elif defined(__PIC32MX__)
199
#else
200
#error "Unknown processor or compiler."
201
#endif
202
203
204
205
#if defined(__C30__)
206
#define nzWordShiftRight_ASM( W, Number) \
207
{ asm( "SR %0, #%1, %0" \
208
: "+r" (W)
/*outputs*/
\
209
: "i" (Number)
/*inputs*/
); }
210
#elif defined(__PIC32MX__)
211
#else
212
#error "Unknown processor or compiler."
213
#endif
214
215
216
224
#if defined(__C30__)
225
#define nzMemSet_ASM_RRR(adr, c, count) \
226
{ asm( "MOV %0,w0 \n REPEAT #(%2-1) \n MOV.B %1,[w0++]" \
227
:
/*no outputs*/
\
228
: "r" (adr), "r" (c), "i" (count) \
229
: "w0"); }
230
#elif defined(__PIC32MX__)
231
#define nzMemSet_ASM_RRR(adr, c, count) memset(adr,c,count)
232
#else
233
#error "Unknown processor or compiler."
234
#endif
235
236
286
#if defined(__C30__)
287
#define nzMemCpy_ASM_RRR(pDst, pSrc, countReg) \
288
{ asm volatile ( "DEC %2,%2 \n REPEAT %2 \n MOV.B [%1++],[%0++] \n INC %2,%2" \
289
: "+d" (pDst), "+d" (pSrc)
/* outputs, + = input/outputs */
\
290
: "d" (countReg)
/* inputs (must be "d", DEC required a W reg) */
\
291
: "cc" ); }
292
#elif defined(__PIC32MX__)
293
#define nzMemCpy_ASM_RRR(pDst, pSrc, countReg) memcpy(pDst, pSrc, countReg)
294
#else
295
#error "Unknown processor or compiler."
296
#endif
297
298
302
#if defined(__C30__)
303
#define nzMemCpy2_ASM_RRR(pDst, pSrc, countReg) \
304
{ asm volatile ( "MOV %2,w0 \n DEC w0,w0 \n REPEAT w0 \n MOV.B [%1++],[%0++]" \
305
: "+d" (pDst), "+d" (pSrc)
/* outputs, + = input/outputs */
\
306
: "r" (countReg)
/* inputs (can be "r", is copied to a W reg by MOV) */
\
307
: "w0", "cc" ); }
308
#elif defined(__PIC32MX__)
309
#define nzMemCpy2_ASM_RRR(pDst, pSrc, countReg) memcpy(pDst, pSrc, countReg)
310
#else
311
#error "Unknown processor or compiler."
312
#endif
313
314
324
#if defined(__C30__)
325
#define nzMemCpyDec_ASM_RRR(pDst, pSrc, countReg) \
326
{ asm ( "DEC %2,%2 \n REPEAT %2 \n MOV.B [%1--],[%0--] \n INC %2,%2" \
327
: "+d" (pDst), "+d" (pSrc)
/* outputs, + = input/outputs */
\
328
: "d" (countReg)
/* inputs */
\
329
: "cc" ); }
330
331
#elif defined(__PIC32MX__)
332
//TODO PIC32MX - Fix this function! Currently just put memcpy in here so it compiles for testin
333
#define nzMemCpyDec_ASM_RRR(pDst, pSrc, countReg) memcpy(pDst, pSrc, countReg)
334
#else
335
#error "Unknown processor or compiler."
336
#endif
337
338
342
#if defined(__C30__)
343
#define nzMemCpyDec2_ASM_RRR(pDst, pSrc, countReg) \
344
{ asm volatile ( "MOV %2,w0 \n DEC w0,w0 \n REPEAT w0 \n MOV.B [%1--],[%0--]" \
345
: "+d" (pDst), "+d" (pSrc)
/* outputs, + = input/outputs */
\
346
: "r" (countReg)
/* inputs */
\
347
: "w0", "cc" ); }
348
#elif defined(__PIC32MX__)
349
//TODO PIC32MX - Fix this function! Currently just put memcpy in here so it compiles for testin
350
#define nzMemCpyDec2_ASM_RRR(pDst, pSrc, countReg) memcpy(pDst, pSrc, countReg)
351
#else
352
#error "Unknown processor or compiler."
353
#endif
354
355
366
#if defined(__C30__)
367
#define nzMemCpyDecNoOut_ASM_RRR(pDst, pSrc, countReg) \
368
{ asm ( "DEC %2,%2 \n REPEAT %2 \n MOV.B [%1--],[%0--] \n INC %2,%2" \
369
:
/* outputs, + = input/outputs */
\
370
: "d" (pDst), "d" (pSrc), "d" (countReg)
/* inputs */
\
371
: "cc" ); }
372
#elif defined(__PIC32MX__)
373
//TODO PIC32MX - Fix this function! Currently just put memcpy in here so it compiles for testin
374
#define nzMemCpyDecNoOut_ASM_RRR(pDst, pSrc, countReg) memcpy(pDst, pSrc, countReg)
375
#else
376
#error "Unknown processor or compiler."
377
#endif
378
379
429
#if defined(__C30__)
430
#define nzMemCpy_ASM_RRC(pDst, pSrc, count) \
431
{ asm( "REPEAT #(%2-1) \n MOV.B [%1++],[%0++]" \
432
: \
433
: "r" (pDst), "r" (pSrc), "i" (count) ); }
434
#elif defined(__PIC32MX__)
435
#define nzMemCpy_ASM_RRC(pDst, pSrc, countReg) memcpy(pDst, pSrc, countReg)
436
#else
437
#error "Unknown processor or compiler."
438
#endif
439
440
444
#if defined(__C30__)
445
#define nzMemCpyDec_ASM_RRC(pDst, pSrc, count) \
446
{ asm volatile ( "REPEAT #(%2-1) \n MOV.B [%1--],[%0--]" \
447
: "+r" (pDst), "+r" (pSrc)
/* outputs, + = input/outputs */
\
448
: "i" (count)
/* inputs */
); }
449
#elif defined(__PIC32MX__)
450
//TODO PIC32MX - Fix this function! Current code is just to get XC32 to compiler for testing!
451
#define nzMemCpyDec_ASM_RRC(pDst, pSrc, countReg) memcpy(pDst, pSrc, countReg)
452
#else
453
#error "Unknown processor or compiler."
454
#endif
455
456
#endif
netcruzer
lib
nz_helpersCx.h
Generated on Tue Dec 9 2014 15:08:19 for Netcruzer Library API by
1.8.4