Question

From the MARIE simulation package which you downloaded last week, there are several example programs available. In this lab,
10. Next, within the editor, click Assemble, then Assemble current file. If it is successful, a message will show up at t
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi, Hope this will help you. I know it is complicated and lengthy procedure please go through all the part for better understanding. I have explained everything in detail.

If you face any difficulty in this please let me know.

In this Ex4_2.mas has the following code

----------------code-----------------------------------------

/ Example 4.1

                ORG 100

If,            Load      X            /Load the first value      

                Subt       Y             /Subtract the value of Y, store result in AC          

                Skipcond 400      /If AC=0, skip the next instruction

                Jump     Else       /Jump to Else part if AC is not equal to 0               

Then,    Load      X            /Reload X so it can be doubled

                Add        X            /Double X

                Store     X            /Store the new value

                Jump     Endif     /Skip over the false, or else, part to end of if

Else,       Load      Y             /Start the else part by loading Y

                Subt       X            /Subtract X from Y

                Store     Y             /Store Y-X in Y

Endif,    Halt                        /Terminate program (it doesn't do much!)

X,            Dec        12          /Load the loop control variable

Y,            Dec        20          /Subtract one from the loop control variable

                END

--------------------------step 1 to 5 are done in simulator ----------

Hence the code on address

100 (instruction is) load x means loading the Value 12 of X in Accumulator. AC=12

101 (instruction is) subt y mean subtracting a value of y from Accumulator (AC= X-Y) and result store in AC (Accumulator) means AC=12-20=-8

On 102 instruction is   Skipcond 400 means (if AC=0 then skip next instruction, over here AC stores the difference between X and y, if this difference is 0 then skip next instruction. Hence we are checking if X and Y both values are same or not. If difference is 0 means both are same.

Hence condition checked is if (X=Y)

Hence answer on 6----- if (X=Y)

Now AC=-8 means the next instruction is not skipped and instruction on 103 line will be executed

Which is Jump Else

Hence Answer on 7----line with else part is execute

Now control transfer at address 108 Load Y// 20 is loaded (y’s value) in AC hence AC=20

At 109 Subt X//means AC=y-x hence X’s value is subtracted from Y hence AC=8

At 10A instruction is Store Y //means AC= 8 is stored in Y

Hence Answer on 8 -------- Y=Y-X

Now modify the code according to instruction change X=20 then assembled it and load.

Again

100 (instruction is) load x means loading the Value 20 of X in Accumulator. AC=20

101 (instruction is) subt y mean subtracting a value of y from Accumulator (AC= X-Y) and result store in AC (Accumulator) means AC=20-20=0

On 102 instruction is   Skipcond 400 means (if AC=0 then skip next instruction, over here AC stores the difference between X and y, if this difference is 0 then skip next instruction. Hence we are checking if X and Y both values are same or not. If difference is 0 means both are same.

Hence condition checked is if (X=Y)

Hence answer on 12----- if (X=Y)

Now AC=0 means the next instruction is skipped (instruction at 103 is skipped)and instruction on 104 line will be executed

Which is Then

Hence Answer on 13----line with Then part is execute

We know at address 102 Skipcond 400 means checking for X=Y, over here x and y both are equal hence next instruction (instruction at address 103) is skipped and control goes to directly at 104 address Then part in which program load X // loads AC=X, loading X’s Value in AC

At 105 ADD X//means AC=X+X=2*X doubling the value X

At 106 Store X//storing the new value X=AC

AT107 Jump endif //jump to end if where Hlt is written program ends

Hence then part is X=X*2

Hence Answer on 14---------------- X=X*2

By looking at program along with comments we can determine that

Hence Answer on 15 --------

If X=Y  

Then X=X*2

Else

Y=Y-X

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

Now we have to modify a code

If X>Y then

X=X-Y

Else

Y=X+Y

According to the if condition we are checking X>Y means AC>0 when AC=X-Y (when subtracting y from X ) >0 hence the skipcond becomes 800 (which checks the value of AC if AC>0 means we are skipping next instruction)

Please go through code and comments are associated with each line. Please go through the screen shot also.

Hence the code becomes

--------------------------------------Code---------------------------------------------------------------------        

    ORG 100
If,     Load   X   /Load the first value AC=X  
   Subt   Y   /Subtract the value of Y, store result in AC=X-Y  
   Skipcond 800   /If AC>0, skip the next instruction
   Jump   Else   /Jump to Else part if AC < 0
Then,   Load   X   /Reload X hence AC=X
   Subt   Y   /AC=X-Y subt y from x
   Store    X   /Store the new value
   Jump    Endif   /Skip over the false, or else, part to end of if
Else,   Load   X   /Start the else part by loading X AC=X
   Add   Y   /AC=X+Y
   Store    Y   /Store AC in Y
Endif, Halt       /Terminate program (it doesn't do much!)
X,      Dec   20  
Y,      Dec   20   
   END

In first screen shot Y’s Value is stored at 10D. In first screenshot X=20 and Y=20

Hence AC=X-Y=20-20=0 hence Else part is executed (Because AC is not >0, AC=0)

Hence Y=Y+X means 20+20=40 in decimal (means 028 in hex) hence you can see 028 at 10D

In second screenshot we have X=20 and Y=12

Hence AC=20-12=8 means AC>0 hence then part is executed in which

X=X-Y means 20-12=8 and this result is stored in X.

As you can see X is stored at 10C means 008 is stored in 10C.

---------------------------------------------------------------screenshot-----------------------------------------------------------------BI File = MarieSim-v1.3.01 Home Share View + 1 > This PC › Downloads > MarieSim-v1.3.01 vo Search MarieSim-v1.3.01 2 Name DatBI File € = MarieSim-v1.3.01 Home Share View > This PC › Downloads » MarieSim-v1.3.01 → vo Search MarieSim-v1.3.01 2 Name Dat

Add a comment
Know the answer?
Add Answer to:
From the MARIE simulation package which you downloaded last week, there are several example programs available....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Information About This Project             In the realm of database processing, a flat file is a...

    Information About This Project             In the realm of database processing, a flat file is a text file that holds a table of records.             Here is the data file that is used in this project. The data is converted to comma    separated values ( CSV ) to allow easy reading into an array.                         Table: Consultants ID LName Fee Specialty 101 Roberts 3500 Media 102 Peters 2700 Accounting 103 Paul 1600 Media 104 Michael 2300 Web Design...

  • The lab for this week addresses taking a logical database design (data model) and transforming it...

    The lab for this week addresses taking a logical database design (data model) and transforming it into a physical model (tables, constraints, and relationships). As part of the lab, you will need to download the zip file titled CIS336Lab3Files from Doc Sharing. This zip file contains the ERD, Data Dictionary, and test data for the tables you create as you complete this exercise. Your job will be to use the ERD Diagram found below as a guide to define the...

  • In Lab 5, you completed the MyRectangle class, which is a simple representation of a rectangle....

    In Lab 5, you completed the MyRectangle class, which is a simple representation of a rectangle. Review Lab 5 before completing this lab and retrieve the MyRectangle class that you completed for this lab, since you will need it again in this lab. Before starting this lab, edit your MyRectangle class in the following way: • change the declaration of your instance variables from private to protected This will enable access of these variables by your MySquare subclass. Here is...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such...

    Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • Exercise #1: Write a C program that contains the following steps (make sure all variables are...

    Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. Commenting out the existing coding, write the code to divide a...

  • Using C programming language Question 1 a) through m) Exercise #1: Write a C program that...

    Using C programming language Question 1 a) through m) Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT