CS-401 Computer Architecture & Assembly Language Programming Lecture-10 Bit Manipulation
In the Last Lecture We discussed -Bubble sorting
Signed/unsigned numbers
Signed / Unsigned Numbers Number Representation 2 0x0002 -2 0xFFFE ; two’s compliment of ; decimal 65534
Signed / Unsigned Numbers Example mov ax, -2 ; ax = 65534 mov ax, 2 ; bx = 2 cmp ax, bx ja label1 ; true! 65534 > 2
Signed / Unsigned Numbers Example mov ax, 65534 ; ax = 0xFFFE mov ax, -2 ; bx = 0xFFFE ; same representation ; different interpretation
Signed / Unsigned Numbers Order and Range (16 – Bit) Unsigned Numbers: 0<1<2<3<4 <………<65535 Signed Numbers: -32768<-32767<…..<0<……<32767
Multiplication 1 1 0 1 1 3 x 0 1 0 1 x 5 1 1 0 1 0 0 0 0 x 1 1 0 1 x x 0 0 0 0 x x x 1 0 0 0 0 0 0 1 6 5
Shift Instructions shr shift logical right shl shift logical left sar shift arithmetic right sal shift arithmetic left
Rotate Instructions rol rotate left rcr rotate through carry right ror rotate right rol rotate left rcr rotate through carry right rcl rotate through carry left
shr CF 1 1 1 1 1
shl CF 1 1 1 1 1
sal CF 1 1 1 1 1
sar CF 1 1 1 1 1 1 CF 1 1 1 1 1 1
ror CF 1 1 1 1
rol CF 1 1 1 1 1
rcr CF 1 1 1 1
rcl CF 1 1 1 1 1