Question: Computer Architecture problem Purpose : Write two simple machine programs that implement if-else logic and multiplication using a loop. (1) If-else logic program: Choose three

Computer Architecture problem

Purpose: Write two simple machine programs that implement if-else logic and multiplication using a loop.

(1) If-else logic program:

Choose three memory locations that you will use to represent the variables a, b, and c and store three integer values in these memory locations. Then, write a program that performs the following logic:

if((a - b) > 0) c = 1;

else c = a - b;

(2) Multiplication loop program:

Choose two memory locations that you will use to represent the variables x and y. Then write a program that performs a loop that calculates the following value for y:

y = x * x

To write this loop you may use looping logic similar to the loop written in this program: simplemachinesampleloop Computer Architecture problem Purpose: Write two simple machine programs that implement

#

#

# This simple machine program performs the following loop:

# N=10;

# j=0;

# for(i=0;i

#

#

# First, intialize i and j and then start the loop by checking if (i

# Note: if (i

# i=0; // init

# j=0; // init

# goto check;

0x7007 #JMP CHECK [0]

# loop: j+=i;

0x1010 #LOAD J [1]

0x800F #ADD I

0x2010 #STORE J

# i++;

0x100F #LOAD I

0x8012 #ADD ONE

0x200F #STORE I

# check: if ((i-N)

0x1011 ##LOAD N

0x900F #SUB I

0x4000 #MVAC

0x6001 #JLT LOOP

# ---------

0x0

0x0

0x0

0x0

#------- data

0x0 #I:

0x0 #J:

0xA #N:

0x1 #ONE:

This program implements the following loop:

N=10; j=0; for(i=0;i

Note that by the end of this loop j equals i * N. This fact can help you to write your loop.

Once your program is working, place your program in a file and put comments at the bottom of the file to answer the following questions:

Question 1: What is the result if x is set equal to a value between 0 and 127?

Question 2: What is the result if x is set equal to 128?

Question 3: What is the result if x is set equal to 256?

In describing the result, notice and mention what happens to y's value when x is set to the values given in the questions.

You can use either the simple machine given at

Links to an external site.http://devinriley.github.io/SimpleMachine/

or the simple machine you can access on hills.ccsf.edu.

Here is a document giving a review of the simple machine and the instructions it uses: SimpleMachineSummary.pdfif-else logic and multiplication using a loop. (1) If-else logic program: Choose

Submit each program that contains all of the machine language instructions you wrote. Each program should contain comments and a description of how your program works to add all of the numbers together and store their sum in a memory location. Additionally, each line of each program should have a comment explaining what the instruction on that line is doing.

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!