1. For 8-bit 2’s complement math, express each number as hexadecimal. For each s
ID: 3883870 • Letter: 1
Question
1. For 8-bit 2’s complement math, express each number as hexadecimal. For each set of numbers below, perform the logical operations:
a. -5 AND -38
b. 120 AND 53
c. -45 AND -90
d. Use AND to clear bits 2, 3, 4 of 0x96, leaving other bits untouched. Show the result in hex.
e. -5 OR -38
f. 120 OR 53
g. -45 OR -90
h. Use OR to set bits 0, 3, 6, 7 of 0x96, leaving other bits untouched. Show the result in hex.
i. -5 XOR -38
j. 120 XOR 53
k. -45 XOR -90
l. Use XOR to flip bits 2, 4, 6 of 0x96, leaving others untouched. Show the result in hex.
5. Perform an arithmetic shift left, arithmetic shift right, logical shift left, and logical shift right for the following 8-bit numbers. Show the result in binary.
a. 0x73
b. 0x85
c. 0xFF
d. (16 bit number) 0x80AC
Explanation / Answer
a
So we start with:
-5 --> 2's complemnt of minus (0000 0101) --> 1111 1011
-38--> 2's complemnt of minus (0010 0110) --> 1101 1010
-----------------------------------------------------------
We AND them to get --> 1101 1010
--> DA
b
120--> 2's complemnt of (0111 1000) --> 0111 1000
53 --> 2's complemnt of (0011 0101) --> 0011 0101
-----------------------------------------------------------
We AND them to get --> 0011 0000
--> 30
c
-45--> 2's complemnt of minus (0010 1101) --> 1101 0011
-90--> 2's complemnt of minus (0101 1010) --> 1010 0110
-----------------------------------------------------------
We AND them to get --> 1000 0010
--> 82
d
0x96 ---> 1001 0110
---> 1110 0011
---------------------------
AND --> 1000 0010
--> 82
e
So we start with:
-5 --> 2's complemnt of minus (0000 0101) --> 1111 1011
-38--> 2's complemnt of minus (0010 0110) --> 1101 1010
-----------------------------------------------------------
We OR them to get --> 1111 1011
--> FB
f
120--> 2's complemnt of (0111 1000) --> 0111 1000
53 --> 2's complemnt of (0011 0101) --> 0011 0101
-----------------------------------------------------------
We OR them to get --> 0111 1101
--> 7D
g
-45--> 2's complemnt of minus (0010 1101) --> 1101 0011
-90--> 2's complemnt of minus (0101 1010) --> 1010 0110
-----------------------------------------------------------
We OR them to get --> 1111 0111
--> F7
h
0x96 ---> 1001 0110
---> 1110 0011
---------------------------
OR --> 1111 0111
--> F7
Champ, we are suppose to answer only 4 sub questions, but for you I have answered 8 of them. Have a look at them and let me know if you like it. If you are facing any issue with the questions, please commment below. I shall be glad to help you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.