Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program code(assembly language) to calculate the following equation by u

ID: 3740732 • Letter: W

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 = (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 :

Explanation / Answer

1)1-address instruction:

LOAD G ; AC <-M[G]

MUL H ; AC <- AC*M[H]

STOR T ; M[T] <-AC

LOAD E ; AC <- M[E]

MUL F; AC <- AC*M[F]

STOR T1 ; M[T1] <- AC

LOAD D ; AC <- M[D]

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

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

STOR T; M[T]<- AC

LOAD A; AC <- M[A]

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

DIV T ; AC <- AC/M[T]

STOR X ; M[X] <- AC

length of program code : 14.

2) 2 address instruction:

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

MUL R1, H ; R1 <- R1*M[H]

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

MUL R2, F ; R2 <- R2*M[F]

MOV R3, D ; R3<- M[D]

SUB R3,R2 ; R3 <- R3 - R2

ADD R3,R1 ; R3 <- R3+R1

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

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

DIV R2,R3 ; R2<- R2/R3

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

length of program code : 11

3) 3 address instruction:

MUL R1,G,H ; R1 <- M[G]*M[H]

MUL R2,E,F ; R2<-M[E]*M[F]

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

ADD R2,R2,R1 ; R2 <- R2+ R1

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

DIV X,R1,R2 ; M[X]<- R1/R2

length of program code: 6

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote