0

I have an task to generate an Random numbers in assembly language just like rand function in c Language but in assembly language i had to extract the B0,B5,B6 bit from the 8 bit data number and perform the following tasks on that bit

  1. EOR B5 and B6
  2. EOR B0 and result of (B5 ^ B6)
  3. And result of task 2 will be replace to MSB bit of the 8 bit data.

I've done the first 2, but can I replace the MSB bit with the result of task 2?

2
  • ARM may have a bit-field insert instruction to replace a bit without the usual AND to clear the old value and ORR to set a new 0 or 1 value. Otherwise do that. The linked duplicate includes an implementation of setting a newbit at a given position in an existing value. Commented Apr 19, 2020 at 8:04
  • That C Q&A had over-complicated looking expressions. I'd recommend graphics.stanford.edu/~seander/bithacks.html#MaskedMerge to merge the low bits from the old value with the high bit from another register, as per the other two Q&As I added links to. My answer on Swapping bits at a given point between two bytes explains the details of how the masked xor bitdiff trick works to implement a bit blend. (Or a bit swap if you apply it both ways). Commented Apr 19, 2020 at 8:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.