Convert the given  code fragment to assembly code fragment, using only instructions of the following types. These instructions are generally discussed in class. Here X,Y,Z are  any memory locations;  R, R1, R2 are any general registers; L is a label in the code (you can use any names as labels, ex. L, L1, L2 etc. ). load X, R //copy contents of memory location X into R. store R, X //Store contents of R into Mem location X cmp R1, R2 //Compute R1-R2 and update condition codes;                                                 //throw away result of subtraction. jmp L                       //Jump to location L in the code. jmpp L                      //If P bit is 1, Jump to location L in the code add X, R //Add contents of X,R and store result in R;                                    //Also update the condition codes.   Be careful about what type of argument is allowed in the instruction (Memory or Register). Ex. the first argument of ADD instruction is memory, not register.   Do Not use any other instructions (in this, or some other, assembly language). I cannot get into syntax and semantics of your assembly language or its presumed cpu architecture. So follow the instructions in the question.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Convert the given  code fragment to assembly code fragment,

using only instructions of the following types.

These instructions are generally discussed in class. Here

X,Y,Z are  any memory locations;  R, R1, R2 are any general registers; L is a label in the code (you can use any names as labels, ex. L, L1, L2 etc. ).

  • load X, R //copy contents of memory location X into R.
  • store R, X //Store contents of R into Mem location X
  • cmp R1, R2 //Compute R1-R2 and update condition codes;

                                                //throw away result of subtraction.

  • jmp L                       //Jump to location L in the code.
  • jmpp L                      //If P bit is 1, Jump to location L in the code
  • add X, R //Add contents of X,R and store result in R;

                                   //Also update the condition codes.

 

Be careful about what type of argument is allowed in the instruction (Memory or Register). Ex. the first argument of ADD instruction is memory, not register.

 

Do Not use any other instructions (in this, or some other, assembly language).

I cannot get into syntax and semantics of your assembly language or its presumed cpu architecture.

So follow the instructions in the question.

Ex. do not use JMPZ, JMPN etc. in these questions.

Ex. Do not say: cmp X, Y. The question says that the two arguments in the cmp instruction are registers, not memory locations.

 The code segment:­­

while ((X  != Y) X = X + Z;

L:

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education