





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Binary Arithmetic: Bit Shifting, 2s Complement ... Convert from binary to decimal AND ... 2s-Complement to Decimal method is the same!
Typology: Lecture notes
1 / 29
This page cannot be seen from the preview
Don't miss anything!






















Binary Arithmetic: Bit Shifting, 2s Complement
Intro to Assembly Language
CS 64: Computer Organization and Design Logic Lecture # Winter 2019 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB
~(0x3E | 0xFC)
1001 << 2 = 100100
1100 (arithmetic) >> 1 = 1110
So, –6(10) = 1010(2) according to this rule
0110 1001 1010
First take the unsigned (abs) value (i.e. 6) and convert to binary: Then negate it (i.e. do a “NOT” function on it): Now add 1:
Let’s do it Backwards… By doing it THE SAME EXACT WAY!
NOTE : Opposite numbers show up as symmetrically opposite each other in the circle.
NOTE AGAIN : When we talk of 2s complement, we must also mention the number of bits involved
of bits differs between positive and negative binary numbers
0 to
and
+2N^ – 1 for positive numbers –2N-1^ to +2N-1^ – 1 for 2’s Complement negative numbers
Q: What’s being assumed here??? A: That these are purely positive numbers
Theoretically , I can add any binary no. with N1 digits to any other binary no. with N2 digits. Practically , a CPU must have a defined no. of digits that it’s working with. WHY???
Implementing an 8-bit adder: