In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: Bean, I have a function fmtString FUNC 1,5,5,byte,word,byte,byte,byte and use it like this: sStr = fmtString -128,10,@ascii,7 'value=-128, output="-128",0 This compiles into: [code] 823 002D 0C80 MOV __PARAM1,#-128 ; sStr = fmtString -128,10,@ascii,7 'value=-128, output="-128",0 002E 0028 824 002F 0069 CLR __PARAM2 825 0030 0C0A MOV __PARAM3,#10 0031 002A 826 0032 0C50 MOV __PARAM4,#ascii 0033 002B 827 0034 0C07 MOV __PARAM5,#7 0035 002C 828 0036 0010 CALL @__fmtString 0037 0908 829 0038 0208 MOV sStr,__PARAM1 0039 002E [/code]SX/B assumes incorrectly that the constant is positive and smaller than 256. When using sStr = fmtString -1280,10,@ascii,7 'value=-1280, output="-1280",0 it compiles into: [code] 823 002D 0C00 MOV __PARAM1,#(-1280) & 255 ; sStr = fmtString -1280,10,@ascii,7 'value=-1280, output="-1280",0 002E 0028 824 002F 0CFB MOV __PARAM2,#(-1280) >> 8 0030 0029 825 0031 0C0A MOV __PARAM3,#10 0032 002A 826 0033 0C50 MOV __PARAM4,#ascii 0034 002B 827 0035 0C07 MOV __PARAM5,#7 0036 002C 828 0037 0010 CALL @__fmtString 0038 0908 829 0039 0208 MOV sStr,__PARAM1 003A 002E [/code]This is correct. The first should be: [code] 823 002D 0C00 MOV __PARAM1,#(-128) & 255 ; sStr = fmtString -1280,10,@ascii,7 'value=-128, output="-128",0 002E 0028 824 002F 0CFB MOV __PARAM2,#(-128) >> 8 0030 0029 [/code] regards peter ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=338519 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)