看你的编译器定义,与STM8S无关。
STM8S的汇编本身是有位指令操作的,你可以自定义,也可以用现成的。
在STM8S的库下面有个文件叫STM8S.H,里面已经帮你写好了。你可以直接调用- /*============================== Handling bits ====================================*/
- /*-----------------------------------------------------------------------------
- Method : I
- Description : Handle the bit from the character variables.
- Comments : The different parameters of commands are
- - VAR : Name of the character variable where the bit is located.
- - Place : Bit position in the variable (7 6 5 4 3 2 1 0)
- - Value : Can be 0 (reset bit) or not 0 (set bit)
- The "MskBit" command allows to select some bits in a source
- variables and copy it in a destination var (return the value).
- The "ValBit" command returns the value of a bit in a char
- variable: the bit is reseted if it returns 0 else the bit is set.
- This method generates not an optimised code yet.
- -----------------------------------------------------------------------------*/
- #define SetBit(VAR,Place) ( (VAR) |= (u8)((u8)1<<(u8)(Place)) )
- #define ClrBit(VAR,Place) ( (VAR) &= (u8)((u8)((u8)1<<(u8)(Place))^(u8)255) )
- #define ChgBit(VAR,Place) ( (VAR) ^= (u8)((u8)1<<(u8)(Place)) )
- #define AffBit(VAR,Place,Value) ((Value) ? \
- ((VAR) |= ((u8)1<<(Place))) : \
- ((VAR) &= (((u8)1<<(Place))^(u8)255)))
- #define MskBit(Dest,Msk,Src) ( (Dest) = ((Msk) & (Src)) | ((~(Msk)) & (Dest)) )
- #define ValBit(VAR,Place) ((u8)(VAR) & (u8)((u8)1<<(u8)(Place)))
- #define BYTE_0(n) ((u8)((n) & (u8)0xFF)) /*!< Returns the low byte of the 32-bit value */
- #define BYTE_1(n) ((u8)(BYTE_0((n) >> (u8)8))) /*!< Returns the second byte of the 32-bit value */
- #define BYTE_2(n) ((u8)(BYTE_0((n) >> (u8)16))) /*!< Returns the third byte of the 32-bit value */
- #define BYTE_3(n) ((u8)(BYTE_0((n) >> (u8)24))) /*!< Returns the high byte of the 32-bit value */
- /*============================== Assert Macros ====================================*/
- #define IS_STATE_VALUE_OK(SensitivityValue) \
- (((SensitivityValue) == ENABLE) || \
- ((SensitivityValue) == DISABLE))
- /*-----------------------------------------------------------------------------
- Method : II
- Description : Handle directly the bit.
- Comments : The idea is to handle directly with the bit name. For that, it is
- necessary to have RAM area descriptions (example: HW register...)
- and the following command line for each area.
- This method generates the most optimized code.
- -----------------------------------------------------------------------------*/
- #define AREA 0x00 /* The area of bits begins at address 0x10. */
- #define BitClr(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) &= (~(1<<(7-(BIT)%8))) )
- #define BitSet(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) |= (1<<(7-(BIT)%8)) )
- #define BitVal(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) & (1<<(7-(BIT)%8)) )
- /* Exported functions ------------------------------------------------------- */
- #endif /* __STM8S_H */
复制代码
|