Computer Organization and Architecture 10th Edition SUBS X S

Computer Organization and Architecture (10th Edition)

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 resasonbly 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.

Solution

1). Data transfer: Location X to accumulator, accumulator to location X
Assuming we keep locations Y,Z as base space & 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
2) Addition: Add contents of location X to accumulator
Addition is the same as negating, the negative accumulator subtract X.
subs Y ; store accumulator in Y ( Y was zeroed )
subs Z ; zero out accumulator and Z
subs Z
subs X ; X and accumulator are negate original X value
subs Y ; Y and accumulator are negate 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
3.)Conditional branch
Consider a straight branch to the line which is the value in the accumulator below the
jump instruction (considering n-1 bit numbers).
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 change
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 before the branch.
4). Logical OR
(A OR B) is A+B minus the carry of A+B plus the carry of A+B (shifted right).

Computer Organization and Architecture (10th Edition) SUBS X Subtract the contents of location X from the accumulator, and store the result in location X and th
Computer Organization and Architecture (10th Edition) SUBS X Subtract the contents of location X from the accumulator, and store the result in location X and th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site