Microprocessor Question -- ALU operations

  • Thread starter Thread starter jaus tail
  • Start date Start date
  • Tags Tags
    Alu Operations
Click For Summary

Discussion Overview

The discussion revolves around the operations of an Arithmetic Logic Unit (ALU) in microprocessors, specifically focusing on the manipulation of binary numbers using 2's complement and 1's complement methods. Participants explore the implications of dividing binary numbers by two, particularly in the context of negative numbers represented in 2's complement form.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant states that dividing a negative number by 2 should yield a negative result, implying that the output must remain in 2's complement form.
  • Another participant questions the initial steps taken to convert a 2's complement number back to its original form, suggesting that the method used may be incorrect.
  • Several participants discuss the representation of the binary string, with some asserting it represents a negative number due to the most significant bit (MSB) being 1.
  • One participant describes a complex method involving rotating bits and taking complements, expressing frustration over the memorization required for such operations.
  • Another participant explains how to interpret the binary representation in terms of its decimal value, particularly focusing on the significance of the MSB in determining the sign of the number.
  • There is a mention of the carry bit and its potential relevance in the context of the operations being discussed.

Areas of Agreement / Disagreement

Participants express differing views on the correct method for converting and manipulating 2's complement numbers, with no consensus reached on the correct approach or final answers. The discussion remains unresolved regarding the specific steps and interpretations of the binary operations.

Contextual Notes

Some participants highlight the complexity of the operations and the potential for confusion, particularly in exam settings. There are references to the importance of understanding the roles of 1's complement and 2's complement in representing negative numbers, but specific mathematical steps remain unresolved.

Who May Find This Useful

This discussion may be useful for students studying microprocessor operations, particularly those grappling with binary arithmetic and the concepts of 2's complement and 1's complement in the context of ALU functions.

jaus tail
Messages
613
Reaction score
48

Homework Statement


upload_2017-12-17_17-9-15.png
[/B]

Homework Equations


Division by two means moving the bits right by 1 unit.
2's complement = 1's complement + 1

The Attempt at a Solution


For Question: 6
Number is 11010110 This is 2's complement.
So to find original number we subtract by 1 and get: 11010101
Now we do 1's complement to get original number: 00101010
Now we move right by 1 bit and get: 00010101

But book says answer is D
Where am I wrong?
 

Attachments

  • upload_2017-12-17_17-9-15.png
    upload_2017-12-17_17-9-15.png
    12.5 KB · Views: 1,061
Physics news on Phys.org
If you divide a negative number by 2, the quotient is a negative number. Since 2s compliment numbers represent negative, the result should be in 2s compliment form
 
  • Like
Likes   Reactions: jaus tail
jaus tail said:
For Question: 6
Number is 11010110 This is 2's complement.
So to find original number we subtract by 1 and get: 11010101 This is where I think you are wrong
Now we do 1's complement to get original number: 00101010
Now we move right by 1 bit and get: 00010101

But book says answer is D - Where am I wrong?
You know you are wrong, because you start with a negative number, divide by +2 and end up with a positive number.

I think you have wrongly reversed the trick for making numbers into 2's comp.
 
  • Like
Likes   Reactions: jaus tail
jaus tail said:
For Question: 6
Number is 11010110 This is 2's complement.
Is this binary string representing a positive number or a negative number?
 
Thanks. I took 2's complement of number, did rotate by 1 to right side of each bit and then again took 2's complement and that gave me the answer.
So 2's complement of:
110110110
first do minus 1
So I get:
110110110
- 00000001
= 11010101

Now I do 1's complement of this and get:
00101010
Now rotate by 1 bit right side and this becomes
00101010
to
00010101
Now first take 1's complement
00010101
becomes
11101010
Now take 2's complement means add +1 and this becomes
11101011
This is answer. Thanks. But this is horrible. In exam I'd get stuck somewhere. There is so much to remember.
How to solve the next part?
I don't even know how to start?
Carry Bit is 0. Does 1's complemet or 2's complement change that?

But how to solve the next question. Book answer is A. I
 
NascentOxygen said:
Is this binary string representing a positive number or a negative number?

I think it's negative number because MSB is 1
For positive number the 1's complement and 2's complement is same number.
Like: +4 = 0100
It's 1's complement and 2's complement is 0100
I checked on google.
 
jaus tail said:
I think it's negative number because MSB is 1
So once you've determined that number, don't forget to show its negative sign.
 
  • Like
Likes   Reactions: jaus tail
jaus tail said:
... But this is horrible. In exam I'd get stuck somewhere. There is so much to remember.
Yeah, I know how you feel. If you do it a lot, it will become easy like common arithmetic. But I don't. I'm no good at maths, so I just remember how the numbers work and use column values.
So for 8 bits, MSB is worth -128 and the other 7 bits, +64,+32 ..., +1. (Then you could just do the arith in denary if you like!)

But to think of the binary; say you had -108 for eg. That would be -128 +16 +4 or 1001 0100
Now if you want that divided by 2 (to get -54) you could have that as -64 +8 +2 because that is half of all the column values.

But in 8bit 2's comp only the MSB is negative. So we replace that -64 with -128 +64 and our result is then -128 +64 +8 +2 or 1100 1010
What you've done is to simply shift the 2's comp right 1 bit, as you might expect for div by 2, but keep the MSB at 1

Any time you have a 2's comp negative number, MSB is 1 and Rshift moves it to be half the value but positive instead of negative. So long as the MSB is replaced with another 1, the total of these two becomes half the MSB value but negative.

If the 2's comp is a positive number, MSB is 0 and R shifting it means it is still 0. If we keep the MSB as 0, then nothing has changed here, but all the positive values have moved down 1 bit and are half their value as required.
2sComp.png


Once you've got your correct result, by whatever means, you can see how the bits move. Then it's easy to decide which shift operations do the job.
Remember they've mentioned the carry bit (which is often ignored), so that probably gets used here.
 

Attachments

  • 2sComp.png
    2sComp.png
    2.6 KB · Views: 435
  • Like
Likes   Reactions: jaus tail
Thanks for all the replies.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
9
Views
37K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
3K