Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 instructions: if( x == 0 ) go to line L x = x - 1 x = x + 1 go to line L

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]

can anyone help me this Principle of Computing plssss!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions