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 to do a discussion about this question and I'm having trouble finding legitimate sources:...
I have to do a discussion about this question and I'm having trouble finding legitimate sources: "How can we ensure that farmers and ranchers, not government agencies, are driving the management of natural resources?" Anything would be appreciated!
Do in c++ programming languages Question 1: Solve the complete Question with all parts and subparts....
Do in c++ programming languages Question 1: Solve the complete Question with all parts and subparts. a) What do you understand by the term DATA TYPE? b) Is it possible to replace for loop with a while loop. Justify your answer with reasoning and example. c) Draw a flow chart for Do-While loop for controlled/uncontrolled infinite loop iterations. d) Write down a function prototype that takes an array and its length as an argument and also return the same array...
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...
Hello There! I have a question to answer please, I don't understand it, it is about...
Hello There! I have a question to answer please, I don't understand it, it is about data communication and networking "Wireshark" Capture ICMP packets with “Wireshark” and analyze the results. Capturing Basics and Filters 1_ Create a filter to show only HTTP traffic with destination port 80. 2_ Create a filter to exclude ARP and ICMP traffic from visualization. 3_ Create a filter to show DNS queries to a specific domain. TIP: Use the keyword contains to search a specific...
I have to respond to this question on the pro side of it. “Do teachers have...
I have to respond to this question on the pro side of it. “Do teachers have biases toward students based upon their race?”
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 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 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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT