Sorry, can't do it for you! But your teacher most likely told you how and you missed the boat!
Let's do these things backwards from simplest to most complex!
You're teacher must have taught you that a 1's complement is the inversion (flipping) of the bits.
Asm
0A5h
1010 0101 0A5h (165 unsigned, -165 signed)
0101 1010 05Ah (90)
2's complement is used for a subtraction operation. 1's complement then add 1
Asm
0101 1011 05Bh (91)
So
Asm
0111 1011 07Bh (123)
0001 0111 17h (23) {subtract}
1110 1000 E8h 1's complemenet 17h
1110 1001 E9h 2's complement
now sum
0111 1011 7Bh (123)
1110 1001 E9h {ADD}
--------------
0110 0100 64h ( 100)
WOW! MAGIC!!!!
Okay next problem.
Processors typically have two kinds of shifts though some have four such as the 80x86.
Shift Logical Left
Shift Arithmetic Left
Are the same thing.
Asm
01011010 5Ah (90)
10110100 B4h (180)
The bits get shifted left by N bits. In that case it was by 1 bit. This is effectively a multiply!
Logical Shift Right
Asm
1010 0101 A5 (165)
0101 0010 -> 1 52 (82)
In a Logical Shift Right a zero bit was clocked into the high bit!
For an Arithmetic Shift Right the MSB (Most Significant Bit) the sign bit, acts like a sticky bit. It stays in place and then shifts the data down.
Asm
1010 0101 A5 (165 unsigned -91 signed))
1101 0010 ->1 D2 (210 unsigned -46 signed)
So shift left once is a divide by 2. Shift left twice is a divide by 4.
They cheated here and made this number a base 2.
2^1 = 2
2^2 = 4
2^3 = 8
Left shift????
Also 2^3 = 2*2*2 three 2's.
5^3 = 5*5*5 = 125
Left Shift & Right Shift
Left Rotate & Right Rotate
This post has been edited by wildgoose: 31 Oct, 2009 - 10:21 AM