In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: Jim, You can't use __WPARAM34 as the result of a division because those bytes (__PARAM3 and __PARAM4) are actually used to hold the divisor during the division -- you code is clobbering you divisor as it runs. I've been "looking under the hood" a lot and finding areas where internal variables can be used -- here are some examples; you'll see that for TX_DEC5 you do in fact need three user words. [code] SUB TX_BYTE SEROUT TX, Baud, __PARAM1 ENDSUB ' ------------------------------------------------------------------------- SUB TX_STR strAddr VAR __WPARAM34 sChar VAR __PARAM1 strAddr = __WPARAM12 DO READINC strAddr, sChar IF sChar = 0 THEN EXIT TX_BYTE sChar LOOP ENDSUB ' ------------------------------------------------------------------------- SUB TX_DEC5 wDividend VAR tmpW1 wDivisor VAR tmpW2 wResult VAR tmpW3 wIdx VAR tmpB1 wChar VAR wResult_LSB \ SB __PARAMCNT.1 \ CLRB __WPARAM12_MSB wDividend = __WPARAM12 wDivisor = 10_000 FOR wIdx = 4 TO 0 STEP -1 wResult = wDividend / wDivisor wDividend = __WREMAINDER wChar = wChar + "0" TX_BYTE wChar wDivisor = wDivisor / 10 NEXT ENDSUB[/code] As you can see there are no opportunities to use internal variables with TX_DEC5; __PARAM1 - __PARAM4 are used by / and __PARAM5 is used for __PARAMCNT. Sometimes it just works that way. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=287524#m287604 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)