Question

In: Electrical Engineering

I have a question about machine languages. Why do values that are being compare have to...

I have a question about machine languages. Why do values that are being compare have to be either signed or unsigned? Why cant one value be signed while the other is unsigned in machine language? If you don't understand what I mean by machine language, I am referring to programming language where instructions such as load and store is used. Thank you.

Solutions

Expert Solution

Q - "I have a question about machine languages. Why do values that are being compare have to be either signed or unsigned? Why cant one value be signed while the other is unsigned in machine language?"

A - It is because of the fact that, unlike C and other languages, in machine languages, there is no concept of data type (signed datatype or unsigned datatype). So, the machine language uses same instructions for both signed and unsigned cases. Therefore, if you want to get correct results, either compare signed values or compare unsigned values; otherwise, you will get wrong results in many cases.

Example ==>

Suppose you have a 4-bit processor ==>

And there are two registers A and B; and ==>

A = 1011 in binary

B = 1101 in binary

If A is signed, then A = -5 in decimal

If A is unsigned, then A = 11 in decimal

If B is signed, then B = -3 in decimal

If B is unsigned, then B = 13 in decimal

Suppose, you want to perform addition operation on registers A and B and you gave the following command ==>

ADD A,B

The result of this command will be 1000 in binary and carry (C) bit is set, i.e., carry(C) =1.

Now, let's cross-check.

(i) Signed A + Signed B = -5 + (-3) = -8 decimal = 1000 binary and C=1

(ii) Signed A + Unsigned B = -5+13 = 8 decimal = 1000 binary and C=0

(iii) Unsigned A + Signed B = 11-3 = 8 decimal = 1000 binary and C=0

(iv) Unsigned A + Unsigned B = 11+13 = 24 decimal = 1000 binary and C=1

You can see here that only (i) and (iv) matches with the desired result.


Related Solutions

I have been given a project to do that will have the potential of being implemented....
I have been given a project to do that will have the potential of being implemented. The scope of the project is to come up with a remote monitoring system for the status of a pump-motor arrangement which has a valve in front of it that also had to be monitored. The level of the water in the tank where the pump is pumping has to be monitored by the use of float switches. This all has to be with...
I have to do a presentation where I explain and compare the ratio analysis of the...
I have to do a presentation where I explain and compare the ratio analysis of the IBERDROLA company of years 2015 and 2016, and say at the end if I would like to invest in such a company/business. And comment alittle bit on accounting policies cash flow statement BS IS and notes. The link of this is bellow: https://www.iberdrola.com/wcorp/gc/prod/en_US/corporativos/docs/FinancialStatements_AuditorsReport_Consolidated16.pdf at this link you find everything, also the financial statements, or you can google it
I have a quick question about this C ++ problem in my intro class. I have...
I have a quick question about this C ++ problem in my intro class. I have been able to get the first answer consistently when I test it, but my second seems to either be high or low no matter how I change it. Can you show me how you would do this problem with the setprecision(2) Paula and Danny want to plant evergreen trees along the back side of their yard. They do not want to have an excessive...
why you think your values and being self- aware of these values are an essential aspect...
why you think your values and being self- aware of these values are an essential aspect of understanding your Ethical Responsibilities as a Human Service Professional. How does your personal values and biases impact professional applications or practice of human services.
I have looked at other answers on here in regards to this question. But I do...
I have looked at other answers on here in regards to this question. But I do not know what "In" stands for and those who answer are using different descriptions than I am used to. Here is the question. Number of Periods. How long will it take for $400 to grow to $1,000 at the interest rate specified? (LO1) a. 4% b. 8% c. 16%. Could someone please break this down a little further for me.
I answered the questions but do not feel 100% about my answer want to compare it...
I answered the questions but do not feel 100% about my answer want to compare it to another Maria Santos was recently promoted to senior vice president and assistant to the CFO at Paradise Environmental Designs (PED). In her new position, Maria is responsible for raising external funds for PED. When the firm needs to raise capital, her team recommends the type of financial instrument that should be issued, completes the appropriate paperwork, negotiates with PED’s investment bankers, and so...
I have to do a system disorder about heart failure
I have to do a system disorder about heart failure
Hi, I have a question about the perceptual set. I have known what the perceptual set...
Hi, I have a question about the perceptual set. I have known what the perceptual set is, but I have no idea about is it better described as a kind of bottom-up processing or top-down processing? Please help me. I do highly appreciate your help. Regards,
I have searched the percentage of each question, but I want to know why there are...
I have searched the percentage of each question, but I want to know why there are differences? a. What's the percentage of loans out of total assets for Bank of America and Central Bank? What explains such a significant difference? BOA:40.2%, Central Bank:67%. b. What's the percentage of total deposits out of total liabilities (including capital) for Bank of America and Central Bank? Again, why do you think there is a significant difference? BOA:66.1%, Central Bank:89%.
I have no clue how to do the math here and get the values asked? Please...
I have no clue how to do the math here and get the values asked? Please help by working out the equation.   Two species of algae (called Blue and Green) compete. Their dynamics can be described using the Lotka-Volterra competition equations: dNB/dt = rBNB(KB-NB- aBGNG)/KB dNG/dt = rGNG(KG-NG- aGBNB)/KG                                                                      The following information is known: dNB/dt = 0 when NB = 100 and NG = 0 dNB/dt = 0 when NB = 50 and NG = 25 dNG/dt = 0 when...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT