I'm implementing a 16-bit bit shifter to rotate bits to the left by r. I only have access to the AND
, NOT
and ADD
operations. There are 3 condition codes: negative, zero and positive, which are set when you use any of these operations.
AND
the number with 1000 0000 0000 0000
to set condition codes to positive if the most significant bit is 1
.ADD
the number with itself. This shifts bits to the left by one.1
, ADD
1
to the result.Are there any other efficient ways I can do this?
Since this is homework, I'll help you think about it.
2 * 2 = 4
4 * 2 = 8
8 * 2 = 16
0010 * 0010 = 00100
0100 * 0010 = 01000
1000 * 0010 = 10000
A left shift is a [some unknown] operation. That [some unknown] operation can be implemented using AND, NOT and ADD by doing...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With