In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: Bill, Masking is a pretty common in programming, especially embedded programming. I'm working on a book called "Practical SX/B" right now and make sure that the topic gets good coverage. What's important to understand how the basic operators | (or), & (and) and ~ (not) behave. With & (and), anything "anded" with zero is zero, so you can clear bits by putting zeros into the positions you want cleared, hence: [code]someValue = someValue & $0F[/code] will cause the the upper bits of 'someValue' to be cleared, while the lower bits will remain intact (1 stays 1, 0 stays 0). Using masking and SWAP generates less assembly code in SX/B that shifting by four bits. Since I wrote StampWorks (yes, I am the artist formerly known as Jon Williams) I think it's a great book, but it is focused on the BS2 and a lot of very cool tricks that are built into the BASIC Stamp that don't exist in other languages, even SX/B. My new book points out those differences when appropriate to help BS2 programmers make the move to SX/B without stress or pain. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=161442#m161609 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)