ALGORITHM 1: Implementation of bit masking and shifting by loading a 32-bit regi
ID: 3542804 • Letter: A
Question
ALGORITHM 1: Implementation of bit masking and shifting by loading a 32-bit register with all 1's (this will be hexadecimal FFFFFFFF) then to perform an exclusive OR with a 32-bit hexadecimal value of AAAA5555 Then rotate the result 16 bits (either left or right) and finally display the result in hexadecimal.
ALGORITHM 2: evaluate the sum of the mathematical series (2x +4) where x goes from 1 through 5. With a loop in assembly language and Register Addressing Mode, Immediate Addressing Mode AND Direct Addressing Mode.
Finally TWO algorithms in just one assembly language prog.
Explanation / Answer
It is possible to use bitmasks to easily check the state of individual bits regardless of the other bits. Querying the status of the 4th bit
EG:
LOAD A, FFFFFFFF
AND FFFFFFFE => to make the LSB 0, since E=1110 in binary,
use, FFFFFFFB (B=1011 ) to mask the third bit to 0 from the last.
to make the bit 1, use 'OR 1111 (F)' at the appropriate locations
For shifting:
LOAD A, FFFFFFFF
RAL
RAL
RAL
RAL => TO ROTATE OR SHIFT LEFT THE 16 BITS
LOAD A, FFFFFFFF
RAR
RAR
RAR
RAR => TO ROTATE OR SHIFT RIGHT THE 16 BITS
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.