In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: For subtracting this is generated 5488 01B8 0218 SUB dacValue_LSB,adcValue_LSB ;dacValue = dacValue - adcValue 01B9 00B6 5489 01BA 0703 SUBB dacValue_MSB,/C 01BB 00F7 5490 01BC 0219 SUB dacValue_MSB,adcValue_MSB But again underflow may be missed. Alternative code from sxlist.com mov W, adcValue_LSB sub dacValue_LSB,w mov w,adcValue_MSB sc movsz w,++adcValue_MSB sub dacValue_MSB,w ; dest=dest-source, with valid carry (although the Z flag is not valid). 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#m340227 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)