In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: Here's Bean's code wrapped up in a function so that it can be called from anywhere and applied to any [byte] variable -- this also checks for and handles 10's rolloever. [code]FUNC INC_BCD tmpB1 = __PARAM1 ' save parameter tmpB2 = tmpB1 & $0F ' extract low nib IF tmpB2 < $9 THEN INC tmpB1 ' inc ones ELSE tmpB1 = tmpB1 + 7 ' clear ones, inc tens tmpB2 = tmpB1 & $F0 ' extract high nib IF tmpB2 > $90 THEN ' check for 10s rollover tmpB1 = $00 ENDIF ENDIF RETURN tmpB1 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=191288#m191324 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)