In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: @Bean, Adding 2 words generates 5488 01B8 0219 ADD dacValue_MSB,adcValue_MSB ;dacValue = dacValue + adcValue 01B9 01F7 5489 01BA 0218 ADD dacValue_LSB,adcValue_LSB 01BB 01F6 5490 01BC 0603 ADDB dacValue_MSB,C 01BD 02B7 If adding the MSB parts generates overflow (C set) but adding the LSB parts does not, then the overflow is not detected. If the code was changed to mov w,adcValue_LSB add dacValue_LSB,w mov w,adcValue_MSB snc movsz w,++adcValue_MSB ;leaves C intact add dacValue_MSB,w then we can detect 16bit overflow by testing carry. This takes the same amount of code. (code was found on sxlist.com) 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=340221 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)