Netcruzer Advanced Helper Functions, means to internal use. More...
Go to the source code of this file.
Macros | |
#define | nzWordSwapBytes_ASM_R(W) |
#define | nzWordBitToggle(w, bitPosition) __builtin_btg(w,bitPosition) |
#define | nzByteSwapNibble_ASM_R(W) |
#define | nzWordPosOfFirstMsbBit_ASM(W, WPos) |
#define | nzWordPosOfFirstLsbBit_ASM(W, WPos) |
#define | nzWordPosOfFirstChangeMsb(value) __builtin_fbcl(value); |
#define | nzWordShiftLefs_ASM(W, Number) |
#define | nzWordShiftRight_ASM(W, Number) |
#define | nzMemSet_ASM_RRR(adr, c, count) |
#define | nzMemCpy_ASM_RRR(pDst, pSrc, countReg) |
#define | nzMemCpy2_ASM_RRR(pDst, pSrc, countReg) |
#define | nzMemCpyDec_ASM_RRR(pDst, pSrc, countReg) |
#define | nzMemCpyDec2_ASM_RRR(pDst, pSrc, countReg) |
#define | nzMemCpyDecNoOut_ASM_RRR(pDst, pSrc, countReg) |
#define | nzMemCpy_ASM_RRC(pDst, pSrc, count) |
#define | nzMemCpyDec_ASM_RRC(pDst, pSrc, count) |
Functions | |
BYTE | nzBytePosOfFirstClearedMsbBit (BYTE b) |
BYTE | nzBytePosOfFirstClearedLsbBit (BYTE b) |
Netcruzer Advanced Helper Functions, means to internal use.
This module contains code for implementing a variable size circular buffers. The size can be configured at run time. It is not limited to a power of 2 value.
The following defines are used to configure this module, and should be placed in projdefs.h. Note that all items marked [-DEFAULT-] are defaults, and do not have to be placed in projdefs.h if they contain desired configuration! For details, see Project Configuration.
The software supplied herewith is owned by Modtronix Engineering, and is protected under applicable copyright laws. The software supplied herewith is intended and supplied to you, the Company customer, for use solely and exclusively on products manufactured by Modtronix Engineering. The code may be modified and can be used free of charge for commercial and non commercial applications. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license.
THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
File History
2010-11-24, David H. (DH):
#define nzByteSwapNibble_ASM_R | ( | W) |
#define nzMemCpy2_ASM_RRR | ( | pDst, | |
pSrc, | |||
countReg | |||
) |
Alternative version for nzMemCpy_ASM_RRR. The "countReg" input does not get modified in this version!
#define nzMemCpy_ASM_RRC | ( | pDst, | |
pSrc, | |||
count | |||
) |
Copy src array to destination array, countReg times, using ASM code. Parameters have to be (RRC): REGISTER (pDst), REGISTER (pSrc), CONSTANT (countReg)
!!! IMPORTANT !!!
When returning, pDst and pScr will both BE INCREMENTED countReg times !!! If this is not required, use the nzMemCpy() function. The XC16 compiler seems to ALWAYS increment pDst and pSrc, even if temporary variables are created and passed to pDst and pSrc. If this is done, the compiler optimization ignores these temporary variables, and still increments pSrc and pDst.
So, remember:
! NOTE on compiler optimization ! If after this macro the pDst and pSrc variables are restored to their original values, it seems like the XC16 compiler IGNORES it (optimization on). It assumes these bytes still have their original values, and ignores this code!
Example
pDst | Destination array, must be a BYTE* variable! |
pSrc | Source array, must be a BYTE* variable! |
count | Number of bytes to write, ENSURE IT IS NOT 0! Must be a WORD literal constant! |
#define nzMemCpy_ASM_RRR | ( | pDst, | |
pSrc, | |||
countReg | |||
) |
Copy src array to destination array, countReg times, using ASM code. Parameters have to be (RRR): REGISTER (pDst), REGISTER (pSrc), REGISTER (countReg)
!!! IMPORTANT !!!
When returning, pDst and pScr will both BE INCREMENTED countReg times !!! If this is not required, use the nzMemCpy() function. The XC16 compiler seems to ALWAYS increment pDst and pSrc, even if temporary variables are created and passed to pDst and pSrc. If this is done, the compiler optimization ignores these temporary variables, and still increments pSrc and pDst.
So, remember:
! NOTE on compiler optimization ! If after this macro the pDst and pSrc variables are restored to their original values, it seems like the XC16 compiler IGNORES it (optimization on). It assumes these bytes still have their original values, and ignores this code!
Example
pDst | Destination array, must be a BYTE* variable! |
pSrc | Source array, must be a BYTE* variable! |
countReg | Number of bytes to write, ENSURE IT IS NOT 0! Must be a WORD variable! |
#define nzMemCpyDec2_ASM_RRR | ( | pDst, | |
pSrc, | |||
countReg | |||
) |
Alternative version for nzMemCpy_ASM_RRR. The "countReg" input does not get modified in this version!
#define nzMemCpyDec_ASM_RRC | ( | pDst, | |
pSrc, | |||
count | |||
) |
Same as nzMemCpy_ASM_RRC(), but copies backwards.
#define nzMemCpyDec_ASM_RRR | ( | pDst, | |
pSrc, | |||
countReg | |||
) |
Save as nzMemCpy_ASM_RRR(), but increments pointers backwards.
!!! IMPORTANT !!!
When returning, pDst and pScr will both BE DECREMENTED countReg times !!!
#define nzMemCpyDecNoOut_ASM_RRR | ( | pDst, | |
pSrc, | |||
countReg | |||
) |
Similar to nzMemCpyDec_ASM_RRR, but NOT garaunteed that pDst and pSrc will be incremented on return (no output). They could be, but should not be relied on!
!!! IMPORTANT !!!
When returning, pDst and pScr will both BE DECREMENTED countReg times !!!
#define nzMemSet_ASM_RRR | ( | adr, | |
c, | |||
count | |||
) |
Sets the given memory with the given byte.
adr | Destination address of array |
c | Byte to set array to |
count | Number of bytes to write |
#define nzWordBitToggle | ( | w, | |
bitPosition | |||
) | __builtin_btg(w,bitPosition) |
Toggle bit in word.
w | A pointer to the data item for which a bit should be toggled. |
bitPosition | A literal value in the range of 0 to 15. |
#define nzWordPosOfFirstChangeMsb | ( | value) | __builtin_fbcl(value); |
Finds the first bit change from left in value. This is useful for dynamic scaling of fixed-point data. Find the first occurrence of a one (for a positive value), or zero (for a negative value), starting from the Most Significant bit after the sign bit of Ws and working towards the Least Significant bit of the word operand. The bit number result is sign-extended to 16 bits. The next Most Significant bit after the sign bit is allocated bit number 0 and the Least Significant bit is allocated bit number -14. This bit ordering allows for the immediate use of Wd with the SFTAC instruction for scaling values up. If a bit change is not found, a result of -15 is returned and the C flag is set. When a bit change is found, the C flag is cleared.
!!!!! This instruction operates in Word mode only !!!!!
value | Integer number of first bit change. |
#define nzWordPosOfFirstLsbBit_ASM | ( | W, | |
WPos | |||
) |
Finds the first occurrence of a 1 starting from the Least Significant bit of given WORD, and working towards the Most Significant bit. The bit number result is zero-extended to 16 bits. Bit numbering begins with the Least Significant bit (allocated number 1) and advances to the Most Significant bit (allocated number 16). A result of zero indicates a 1 was not found.
!!!!! This instruction operates in Word mode only !!!!!
#define nzWordPosOfFirstMsbBit_ASM | ( | W, | |
WPos | |||
) |
Finds the first occurrence of a 1 starting from the Most Significant bit of given WORD, and working towards the Least Significant bit. The bit number result is zero-extended to 16 bits. Bit numbering begins with the Most Significant bit (allocated number 1) and advances to the Least Significant bit (allocated number 16). A result of zero indicates a 1 was not found.
#define nzWordShiftLefs_ASM | ( | W, | |
Number | |||
) |
#define nzWordShiftRight_ASM | ( | W, | |
Number | |||
) |
#define nzWordSwapBytes_ASM_R | ( | W) |
BYTE nzBytePosOfFirstClearedLsbBit | ( | BYTE | b) |
Finds the first occurrence of a 0 starting from the Least Significant bit of given BYTE, and working towards the Most Significant bit. The bit number result is zero-extended to 8 bits. Bit numbering begins with the Least Significant bit (allocated number 1) and advances to the Most Significant bit (allocated number 8). A result of zero indicates a 0 was not found.
b | Byte to search |
BYTE nzBytePosOfFirstClearedMsbBit | ( | BYTE | b) |
Finds the first occurrence of a 0 starting from the Most Significant bit of given BYTE, and working towards the Least Significant bit. Bit numbering begins with the Most Significant bit (allocated number 8) and advances to the Least Significant bit (allocated number 1). A result of zero indicates a 0 was not found.
!!!!! IMPORTANT !!!!! Note that this function returns 1 for LSB bit, and 8 for LSB. The equavalent WORD function nzWordPosOfFirstMsbBit_ASM() return 1 for MSB (16 for LSB)!
b | Byte to search |