Professional Documents
Culture Documents
Microprocessors: 8-Bit 2's Complement Calculator
Microprocessors: 8-Bit 2's Complement Calculator
Design of Experiment
Name:
Course/Section: COE121L/E01
Group No.: 6
Professor
Objectives
The objective of this project is to create a program that would complement its
input.
The program should be able to take an 8-bit input and complement the input with
2’s complement.
Design of Experiment
Learning Objectives:
DISCUSSION
Binary Number System is one of the most recognizable types of number representation
technique that is commonly used in digital system. In the binary system wherein there
are only two digit values, particularly 0 (off state) and 1 (on state) which represented by
any device that only operates in two operating state condition.
There are two types used in complementing binary numbers: (i) 1’s complement and 2’s
complement. In 1’s complement in binary system, it will just invert the given binary
number whereas to get the 2’s complement is simply add 1 to the inverted given value.
Implementation of a 4-bit 2’s complement number system is shown below.
Figure 1. Implementation of a 4-bit 2’s complement number system
Signed complement forms of binary number system can either use 1’s complement or
2’s complement as it permit representation of negative numbers. The method of 2’s
complement arithmetic are mostly used in computers in handling negative numbers.
In 2’s complement inversion and adding one works which shows mathematical shortcut
of a straight forward computation. It is a method to represent negative binary numbers
in a signed binary numbers. The positive numbers will be the same as the unsigned
binary number representation whereas different for negative number as its resulted to
inaccurate due to its corresponding positive equivalent value in zero. The advantage of
2’s complement is it doesn’t result to double-zero problems. The arithmetic operations
will be relatively easier to perform when the numbers is represented in 2’s complement
format.
Non-negative integers will start with ‘0’ and will have as many leading zero depending to
the required number of bits. Negative integers will always begin with ‘1’. 2’s complement
numbers are same with unsigned binary numbers except for the most significant bit
position as it has a weight of −2 N−1instead of 2 N−1 as it will overcomes shortcomings
from signed magnitude numbers. No overflow occurrence is when the value of the bit
carried into the most significant bit is equal to the value carried out of the most
significant bit. Occurrence of overflow means that the value of the bit carried into the
most significant bit is not equal to the bit carried out.
MATERIALS
EDSIM51 Dynamic Interface is the software used for this project. The EdSim51 is
a software of GUI that simulates three microcontroller concepts which are the
memory read cycle, memory write cycle and the Instruction execution cycle.
Basically it is a software based on a microcontroller which contains SSD, LED
displays, DC motor and such.
PROCEDURE
QUESTIONS
Q1. Complete the table below. Run the program to fill in answers. Provide
illustrations
Screenshot 1:
Screenshot 2:
Screenshot 3:
Screenshot 4:
Screenshot 5:
The LED will show the 2’s complement. When the LED is on, it represents
0. When the LED is off, it represents 1. This is because LEDs are active
low. To display a high value, the corresponding LED is OFF. Otherwise,
the LED is ON. When inputting values, a pressed switch is considered 0
while a not pressed switch is 1.
Q3. In 2’s complement, what do all the positive numbers have in common?
Q4. What advantage does 2’s complement have over 1’s complement?
In 2’s complement there is only one way to represent 0 and it simplifies our
representation scheme.____________________________________________
Interpretation of Results
In this Project, the group created a program that would complement n 8-bit binary input
with the use of the 2’s complement. With the help of the Microcontroller simulator the
EDSIM51, we constructed a series of commands that would help aid the computation of
the 2’s complement of the input. Observing the opcodes, there were several commands
that were used similar to the experiments performed in the simulation. CPL, ADD and
MOV were some of the similar opcodes used in the simulation. The Opcodes were
placed in the IDE of the simulation which was there it was processed and debug by the
simulation. The software would detect the problems in the codes and misplaced
opcodes or declarations. The input is then placed in the LED in the lower left of the
simulation as observed in the screenshot of the program. The input is placed after the
program starts. Starting the program, it will compile it’s instructions and run. There the
input is then placed on the LED. The Seven-segment Display would then project the
output of the program as seen on the screenshot. The output is the 2’s complement of
the input. In changing the values of the input simply place the desired value on the
lower left of the program where the led buttons are located. It would then be displayed
on the SSD.
CONCLUSION
After performing the design experiment, we therefore conclude that:
o Both 1's complement and 2's complement are binary representations of
signed quantities where the most significant bit on the leftmost is the sign bit.
o 2’s complement comes from the fact that a negative number is a 2’s
complement of a positive number.
REFERENCE
- https://www.tutorialspoint.com/two-s-complement
- https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html
- https://www.sciencedirect.com/topics/computer-science/twos-complement-number
- https://www.ele.uri.edu/courses/ele447/proj_pages/divid/twos.html
- https://www.edsim51.com
- http://www.keil.com/support/man/docs/is51/is51_opcodes.htm
-