Question

How do I assign the highest nibble (4 bits) in one register (8 bits), to the highest nibble of another register in one step? without altering the 4 LSbs?

Here is my proposed solution, when I can do it in two steps, but I believe there is more ingenious solution to do it in only one step (maybe with less gates or instructions):

  • REGA &= (REGB | 0x0F);
  • REGA |= (REGB & 0xF0);

Could anyone good with digital design help? (it's 3 AM and I can't sleep without a relief :-/)

Was it helpful?

Solution

A = (A & 0x0F) | (B & 0xF0)

(Note that this operation requires zero gates, though...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top