Question: Write a program code(assembly language) to calculate the following equation by using below commands. And compare the length of the program code(assembly language). X =

Write a program code(assembly language) to calculate the following equation by using below commands. And compare the length of the program code(assembly language).

X = (A + B) / ( (D - (E * F) ) + (G * H) )

ADD : Addition, SUB : subtraction, MUL : Multiplication, DIV : Division, MOV : Move data, LOAD : Load data, STOR : Store data

ex )

X = (A + B) x (C - D)

1-address instuction

LOAD A ; AC <-M[A]

ADD B ; AC <-AC + M[B]

STOR T ; M[T] <-AC

LOAD C ; AC <-M[C]

SUB D ; AC <-AC -M[D]

MUL T ; AC <-AC M[T]

STOR X ; M[X] <-AC

length of program code : 7

----------------------------------------------------------------------------

2-address instuction

MOV R1, A ; R1 <-M[A]

ADD R1, B ; R1 <-R1 + M[B]

MOV R2, C ; R2 <-M[C]

SUB R2, D ; R2 <-R2 -M[D]

MUL R1, R2 ; R1 <-R1 R2

MOV X, R1 ; M[X] <-R1

length of program code : 6

----------------------------------------------------------------------------

3-address instuction

ADD R1, A, B ; R1 <-M[A] + M[B]

SUB R2, C, D ; R2 <-M[C] -M[D]

MUL X, R1, R2 ; M[X] <-R1 R2

length of program code : 3

Q1. what is 1 Address instruction :

Q2. what is 2 Address instruction :

Q3. what is 3 Address instruction :

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!