Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/13/04 05:42
Read: times


 
#77295 - RE: Working on nibble
Responding to: ???'s previous message
Q1

A = {R1 AND 0Fx} OR {R2 AND F0x}

It's a technique called bit masking. You should be able to look it up in most texts.

The equation above states that the byte described by the contents of the left braces will be logically ORed with the byte described by the contents of the right braces, and placed in the accumulator. In other words, if a given bit B_n | n = 0 - 7 is a one in either of the bytes described by the contents of either of the brace pairs then the corresponding bit B_n in the accumulator will also be one.

The contents of the left braces state that the contents of R1 will be logically ANDed with 0Fx, which is to say 00001111. A given bit B_n | n = 0 - 7, in the resultant byte, will be a one if and only if the corresponding bits B_n in both R1 and 0Fx are also one. Since the high nibble of 0Fx is all zeroes, the high nibble of the result will also be all zeroes. Since the low nibble of 0Fx is all ones, the lower bits of the resultant byte will be ones if and only if they were ones in R1. Thus, the resultant byte will be all zeroes in the high nibble and whatever was in the low nibble of R1. In this case, 0Fx is the bit mask.

The same technique is applied in the right braces to isolate the high nibble of R2. Then, when the two resultant bytes are ORed together, the accumulator will have the high nibble from R2 and the low nibble from R1.

I'll leave it as an exercise to translate it into whatever language you want to program in.

List of 10 messages in thread
TopicAuthorDate
Working on nibble            01/01/70 00:00      
   RE: Working on nibble            01/01/70 00:00      
      RE: Working on nibble            01/01/70 00:00      
   RE: Working on nibble            01/01/70 00:00      
   RE: Working on nibble            01/01/70 00:00      
      RE: Working on nibble            01/01/70 00:00      
         RE: Working on nibble            01/01/70 00:00      
         First Step            01/01/70 00:00      
   RE: Working on nibble            01/01/70 00:00      
   RE: Working on nibble            01/01/70 00:00      

Back to Subject List