Question: please Don't Copy @@ please Don't Copy @@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't

please Don't Copy @@ please Don't Copy @@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy@@ please Don't Copy

5 instructions:

  • if( x == 0 ) go to line L
  • x = x - 1
  • x = x + 1
  • go to line L
  • stop

We will ask you to write several programs using the above instructions. Note that you cant use anything else apart from these given instructions. But once you have implemented a new instruction, you will be allowed to use it in the next task.

EXAMPLE: Lets start with a simple example. Suppose we ask you to achieve x=0, i.e. to set the contents of a given location to 0. x=0 is not listed in the given instruction, so we must implement it ourselves. The solution is shown below.

(1) if(x == 0) goto (4)

(2) x = x-1

(3) goto (1)

(4) stop

As just mentioned, once we have written a code to achieve a new type of instruction, we will be allowed to use the new instruction in the following tasks. So from now on, x=0 is allowed to be used in our code.

Your task for this worksheet is to write programs with the given mini-assembler to perform the following functions.

  1. multiply x to y, i.e. x = x*y [4 marks]
  2. divide x by y, i.e. x = x/y. This is an integer division. The reminder should be stored in z. For example, after 10/3, x should be 3 and z should be 1. [4 marks]

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!