In SX Microcontrollers, SX/B Compiler and SX-Key Tool, skynugget wrote: Thanks for the aha moment, i get it now! how about this? [code] SHIFT_LEFT: tmpb1 = GET_LONIB hrs tmpb2 = GET_HINIB mins hrs = merge tmpb1,tmpb2 tmpb1 = GET_LONIB mins tmpb2 = GET_HINIB secs mins = merge tmpb1,tmpb2 tmpb1 = GET_LONIB secs secs = merge tmpb1,$F [/code] [code] GET_LONIB FUNC 1, 1, 1, byte GET_HINIB FUNC 1, 1, 1, byte MERGE FUNC 1, 2, 2, Byte, Byte, Byte [/code] [code] ' Use: bResult = GET_LONIB value ' -- returns high nibble of value FUNC GET_LONIB ASM AND __param1, #$0F ' clear high nibble ENDASM RETURN ENDFUNC ' ------------------------------------------------------------------------- ' Use: bResult = GET_HINIB value ' -- returns high nibble of value FUNC GET_HINIB ASM AND __param1, #$F0 ' clear low nibble SWAP __param1 ENDASM RETURN ENDFUNC ' ------------------------------------------------------------------------- ' Use: bResult = MERGE value1, value2 ' -- merge two 4-bit values into a byte ' -- value1 to high nibble, value2 to low nibble ' -- values truncated to four bits FUNC MERGE ASM AND __param1, #$0F ' truncate to 4 bits SWAP __param1 ' move to high nibble AND __param2, #$0F ' truncate to 4 bits OR __param1, __param2 ' merge ENDASM RETURN 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=408151#m410296 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)