In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: As and idea... you could rename the nibble write routines and create complimentary read routines. For example: [code]' Use: bResult = RD_NIB_LO value ' -- returns low nibble of value FUNC RD_NIB_LO ASM AND __param1, $0F ' clear high nibble ENDASM ENDFUNC ' Use: bResult = RD_NIB_HI value ' -- returns high nibble of value FUNC RD_NIB_LO ASM AND __param1, $F0 ' clear low nibble SWAP __param1 ENDASM ENDFUNC ' Use: bResult = WR_NIB_LO target, value ' -- moves value into low nibble of target ' -- value truncated to four bits FUNC WR_NIB_LO ASM AND __param1, #$F0 ' clear low nib AND __param2, #$0F ' truncate to 4 bits OR __param1, __param2 ' merge the nibbles ENDASM ENDFUNC ' Use: bResult = NIB_HI target, value ' -- moves value into high nibble of target ' -- value truncated to four bits FUNC WR_NIB_HI ASM AND __param1, #$0F ' clear high nib AND __param2, #$0F ' truncate to 4 bits SWAP __param2 ' move value to high nib OR __param1, __param2 ' merge ENDASM 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 ENDFUNC[/code] Now you could do something like this to scroll the digits left (blanking the right-most display element): [code]SUB DISPLAY_LEFT SWAP hrs ' move 1s to 10s position tmpB1 = RD_NIB_HI mins ' get 10s from next section hrs = WR_NIB_LO tmpB1 SWAP mins tmpB1 = RD_NIB_HI secs secs = WR_NIB_LOW tmpB1 SWAP secs secs = WR_NIB_LOW $F ' blanking value ENDSUB[/code] Note that this is not designed to be cute or clever (i.e., optimized), it is meant to be obvious and easy. Running this routine six times with a delay in between will scroll the time off. Now... if you want the seconds to be updating during the scrolling, well, that's going to take some more work. Try this first, then move on to that if it is a requirement. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=408151#m410027 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)