In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: If you need to test a specific bit in a value for 0 or 1 you can do it like this: [code]CHECK_BIT FUNC 1, 3, 3, Byte, Word, Byte[/code] [code]' Use: result = CHECK_BIT value, bitpos FUNC CHECK_BIT testVal VAR __WPARAM12 bitPos VAR __PARAM3 mask VAR __WPARAM45 result VAR __PARAM1 ASM CJA bitPos, #15, @CB_False MOV mask_LSB, #1 CLR mask_MSB TEST bitPos JZ @Do_Check Shift_Mask: CLC RL mask_LSB RL mask_MSB DJNZ bitPos, @Shift_Mask Do_Check: AND mask_LSB, testVal_LSB AND mask_MSB, testVal_MSB MOV result, #1 MOV W, mask_LSB OR W, mask_MSB SNZ CB_False: CLR result CB_Exit: ENDASM ENDFUNC[/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=371089#m371145 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)