00001 00006 /* 00007 * The contents of this file are subject to the Mozilla Public License 00008 * Version 1.0 (the "License"); you may not use this file except in 00009 * compliance with the License. You may obtain a copy of the License 00010 * at http://www.mozilla.org/MPL/ 00011 * 00012 * Software distributed under the License is distributed on an "AS IS" 00013 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00014 * the License for the specific language governing rights and 00015 * limitations under the License. 00016 * 00017 * The Original Code is legOS code, released October 17, 1999. 00018 * 00019 * The Initial Developer of the Original Code is Markus L. Noga. 00020 * Portions created by Markus L. Noga are Copyright (C) 1999 00021 * Markus L. Noga. All Rights Reserved. 00022 * 00023 * Contributor(s): Markus L. Noga <markus@noga.de> 00024 */ 00025 00026 #ifndef __sys_bitops_h__ 00027 #define __sys_bitops_h__ 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00034 // 00035 // Functions 00036 // 00038 00039 // g++ warns about __asm__ const. we define the problem away. 00040 // the CXX symbol is predefined in the Makefile 00041 // 00042 #if defined(CXX) || __GNUC__ >= 3 00043 # define ASMCONST 00044 #else 00045 # define ASMCONST const 00046 #endif 00047 00048 // 00049 // the H8/300 processor offers many useful bit operations. 00050 // sometimes, we have to help gcc to realize their full 00051 // potential. 00052 // 00053 // the bit operations don't alter cc except for bld 00054 // 00055 00057 00059 #define bit_set(byte,bit) \ 00060 __asm__ ASMCONST ( "bset %0,@%1\n" : : "i" (bit),"r" (byte)) 00061 00063 00065 #define bit_clear(byte,bit) \ 00066 __asm__ ASMCONST ( "bclr %0,@%1\n" : : "i" (bit),"r" (byte)) 00067 00069 00071 #define bit_load(mask,bit) \ 00072 __asm__ ASMCONST ( "bld %0,%1l\n" : : "i" (bit),"r" (mask):"cc") 00073 00075 00077 #define bit_iload(mask,bit) \ 00078 __asm__ ASMCONST ( "bild %0,%1l\n" : : "i" (bit),"r" (mask):"cc") 00079 00081 00083 #define bit_store(byte,bit) \ 00084 __asm__ ASMCONST ( "bst %0,@%1\n" : : "i" (bit),"r" (byte)) 00085 00086 #ifdef __cplusplus 00087 } 00088 #endif 00089 00090 #endif // __sys_bitops_h__
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |