Computer Engineering Dushyant Rathod (210280107541) : Practical: - 4
Computer Engineering Dushyant Rathod (210280107541) : Practical: - 4
Computer Engineering Dushyant Rathod (210280107541) : Practical: - 4
Practical: - 4
Aim: Write Assembly language Program to implement subtraction between two number
using 2's complement - in GNU Simulator
Theory:
In 8085, the SUB instruction is used 2’s complemented method for
subtraction. When the first operand is larger, the result will be positive. It will not
enable the carry flag after completing the subtraction. When the result is negative,
then the result will be in 2’s complemented form and carry flag will be enabled.
We are using two numbers at location 8000H and 8001H. When the numbers are
78H and 5DH, then the result will be (78 – 5D = 1B) and when the numbers are
23H and CFH, then the result will be (23 – CF = 154) Here 1 indicates the number
is negative. The actual result is 54H. It is in 2’s complemented form.
Instructions:
LDA 2050H
MOV B,A
LDA 2051H
CMA
INR A
ADD B
STA 2052H
HLT
Practical: - 5
ss
Theory:
Instructions:
MVI C,08H
LXI H,2052H
UP: STC
CMC
LDA 2051H
RAR
STA 2051H
JNC ZRO
LDA 2050H
ADD M
STA 2052H
STC
CMC
ZRO: LDA 2050H
RAL
STA 2050H
DCR C
JNZ UP
HLT
Practical: - 6
Aim: Implement the flowchart of signed magnitude Addition and subtraction in logisim
Simulator
For an add operation, identical signs dictate that the magnitudes be added. For a
subtract operation, different signs dictate that the magnitudes be added.
The magnitudes are added with a microoperation EA A + B, where EA is a register that
combines E and A. The carry in E after the addition constitutes an overflow if it is equal
to 1. The value of E is transferred into the add-overflow flip-flop AVF.
The two magnitudes are subtracted if the signs are different for an add operation or
identical for a subtract operation. The magnitudes are subtracted by adding A to the 2's
complemented B. No overflow can occur if the numbers are subtracted so AVF is cleared
to 0.
Practical: - 7