On Thu, 25 Jul 1996, Andrew Warren wrote: > Martin J. Maney wrote: > > mechanically adding a mask to register addresses to shut this up is > > likely to turn off the only diagnostic of a serious and > > easily-committed error [attempting to store a 9-bit value in an > > 8-bit register, etc.]. Actually, I was thinking there of the all-too-easy error of accessing a register without getting the page select bit correctly set. The attempt to use bsf on "bit 8" or loading a literal that doesn't fit into 8 bits is the sort of error the assembler diagnoses correctly (actually, I'm taking the bit-index-out-of-range on faith, as I can't recall ever having seen that). > If the masking is performed the way some people INSIST that it > should be done -- that is, by ANDing the value with 0x7F -- this is > true; the mask will force all values to 7 bits, and there will be no > indication that you've screwed up. As a matter of fact, my macro hack uses XOR to translate the true addresses into 7-bit addresses. This allows a simple representation for "unknown" in the current-page state variable, too. ;-) > If, on the other hand, you "mask" the value by XORing it with 0x80, > attempts to store 9-bit values will still generate errors, as will > attempts to mask addresses that already ARE only 7 bits wide. What I feel falls short about this sort of masking - and it doesn't make any matter whether you AND or XOR - is that there's no checking at all that the correct page is selected. Aside from its value as an eyecatcher that says "here's a page 1 address, dude," all this does is make sure you "know" which page a particular register is on. Now, getting even that limited visibility of the register's page into the code is a good thing, but I've found that an imperfect, rather cumbersome macro package that provides a more dynamic check is worth its weight in gold. I can see ways to make it even better, but I'm about at the limit of what I feel is practical for the rather weak macro language of MPASM (1), and this would all be a lot easier to implement from inside the assembler. Or maybe not, depending on how bad its internal structure has become after years of incremental modification. :-( 1) barring a complete rethinking of the basic approach, maybe.