In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Johnson Rod wrote: to fix test for an overflow condition, on overflow add "wrap around value" to result rotosub_9bit cjb value1, result1, r9_no_overflow ; if v > r then overflow cjb value0, result0, r9_no_overflow ; on overflow r = r + 512 - v or result1, #$02 ; r = r + 512 r9_no_overflow mov w, value0 ; r = r - v sub result0, w mov w, value1 sc movsz w, ++value1 sub result1, w ret ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=89622#m89666 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)