Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

12.7 Consider a hypothetical computer with an instruction set of only two n-bit

ID: 3818865 • Letter: 1

Question

12.7 Consider a hypothetical computer with an instruction set of only two n-bit instructions. The first bit specifies the opcode, and the remaining bits specify one of the 2^(n-1)
n-bit words of main memory. The two instructions are as follows:
SUBS X Subtract the contents of location X from the accumulator, and store the
result in location X and the accumulator.
JUMP X Place address X in the program counter.
A word in main memory may contain either an instruction or a binary number in
twos complement notation. Demonstrate that this instruction repertoire is reasonably
complete by specifying how the following operations can be programmed:
a. Data transfer: Location X to accumulator, accumulator to location X
b. Addition: Add contents of location X to accumulator
c. Conditional branch
d. Logical OR
e. I/O Operations

Explanation / Answer

a)

Data transfer:

in this the transfer of data will take place i.e from location X to accumulator and from accumulator to location X

Presuming we keep locations Y, Z as scratch space which we always leave as zero, we can move X to the accumulator using

subs Z ; zero accumulator

subs Z

subs X ; negate X

subs Z ; zero accumulator

subs Z subs X ; restore X and copy to accumulator and the accumulator to X using

subs Z ; store accumulator in Z

subs X ; zero accumulator and X

subs X

subs Z ; accumulator is negative of original

subs X ; now negative value is in X

subs Z ; put zero back in Z

subs Z

subs X ; original value back in X and accumulator

b).

Addition:

by addition operation . The addition of contents of location X to accumulator takes place

Addition is the same as negating, the negative accumulator subtract X.

subs Y ; store accumulator in Y (presumes Y was zeroed previously)

subs Z ; zero out accumulator and Z

subs Z

subs X ; X and accumulator are negative original X value

subs Y ; Y and accumulator are negative the sum of original values

subs Z

subs Z

subs X ; restore the X value

subs Z

subs Z

subs Y ; Y and accumulator are now the sum of the values

c).

Conditional branch:

In the Conditional branch operation consider a straight branch to the line which is the value in the accumulator below the jump instruction (presuming that the architecture manipulates n-1 bit numbers). Simply

add to the default jmp 0 address.

subs Y ; store accumulator in Y (presumes Y was zeroed previously)

subs Z ; zero out accumulator and Z

subs Z

subs BCH ; X and accumulator are negative original X value

subs Y ; Y and accumulator are negative the sum of original values

subs BCH

subs BCH

subs Y

subs BCH ; final modification

subs Y

subs Y ; clear Y

BCH jump BCH+1 ; jump instruction which was modified

Conditional branch can be done by placing either a particular value or 0 in the accumulator

prior to the branch.

d)

Logical OR (A OR B) is A+B minus the carry of A+B plus the carry of A+B (shifted right)

e).

I/O operations : here all the i/operation will be done and result will be obtain from these operation.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote