In: Computer Science
Write a microprogramming for this operation using one - address, two - address, and three - address? Y = (A * B) -(CD)
I need the answer as soon as possible
One Address Instructions –
This use a implied ACCUMULATOR register for data manipulation.One
operand is in accumulator and other is in register or memory
location.Implied means that the CPU already know that one operand
is in accumulator so there is no need to specify it.
Expression: Y = (A*B)-(CD)
AC is accumulator
M[ ] is any memory location
M[T] is temporary location
LOAD A // AC = M[A]
MUL B // AC = AC * M[B]
STORE T1 // M[T1] = AC
LOAD C // AC = M[C]
MUL D // AC = AC * M[D]
STORE T2 // M[T2] = AC
LOAD T1 // AC = M[T1]
SUB T2 // AC = AC - M[T2]
STORE Y // M[Y] = AC
Two Address Instructions –
This is common in commercial computers.Here two address can be
specified in the instruction.Unlike earlier in one address
instruction the result was stored in accumulator here result cab be
stored at different location rather than just accumulator, but
require more number of bit to represent address.
Here destination address can also contain operand.
Expression: Y = (A*B)-(CD)
R1, R2 are registers
M[] is any memory location
MOV R1, A // R1 = M[A]
MUL R1, B // R1 = R1 * M[B]
MOV R2, C // R2 = C
MUL R2, D // R2 = R2 * D
SUB R1, R2 // R1 = R1 - R2
MOV Y, R1 // M[Y] = R1
Three Address Instructions –
This has three address field to specify a register or a memory
location. Program created are much short in size but number of bits
per instruction increase. These instructions make creation of
program much easier but it does not mean that program will run much
faster because now instruction only contain more information but
each micro operation (changing content of register, loading address
in address bus etc.) will be performed in one cycle only.
Expression: Y = (A*B)-(CD)
R1, R2 are registers
M[] is any memory location
MUL R1, A, B // R1 = M[A] * M[B]
MUL R2, C, D // R2 = M[C] * M[D]
SUB Y, R1, R2 // M[Y] = R1 - R2