Log In
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
0 votes

(c) The following are some assembly language instructions of a hypothetical CPU. The instructions are written to find the remainder when 16 is divided by 7 and store the remainder in a memory location

location assembly instruction

0 load  16

1 sub   7  

2 bge   1

3 store 4

4 (unknown) 

The operands of the above instructions are given in decimal. (i) Translate the first four assembly instructions (at locations 0 to 3) into 8-bit machine language instructions (3 bits for operation code and 5 bits for operand) using the following table. Ignore the last column at this moment.








operand (5 bits) meaning
100 load x load the value x into the accumulator
101 sub x
subtract the value x from the accumulator A (i.e., A - x) and store result in A.
110 add x add the value x to the accumulator A (i.e., A + x) and store result in A.
111 bge x branch to location x if the content of the accumulator A is greater than or equal to zero. In other words, if A >= 0, the next instruction to execute is at location x. Normally the next instruction's location is one larger than the current memory location.
000 store x store the content of the accumulator to location x

For example, the assembly instruction at location 3 (store 4) is translated to "000 00100" since "store" corresponds to 000 and 410 = 001002 .

(ii) This part is difficult. Upon the reset of the CPU, the first instruction to execute is at location 0. Then the CPU executes the instructions one by one from the top to the bottom unless changed by the "bge" instruction. The machine has a register called the accumulator A which can be used to store a number. Now you need to trace the execution of the above assembly instructions.

• What is wrong with the above instructions?

• Suggest some changes in the assembly instructions that make the code work as intended.

(d) Show your working steps in performing the following conversions:

(i) Convert 0101 10012 to decimal.

(ii) Convert 4E16 to decimal.

(iii) Convert 1100 00112 to hexadecimal.


in Compilers, Architecture, HPC 147 views

location  opcode operand

0            100      10000

1            101       00111

2            111        00001

3            000        00100

(ii) here 16-7 = 9..  since  9>=0 , so again 9-7 = 2..since 2>=0 , so 2-7 = -5 -5 <0 , so we get -5 but we want 16 mod 7 =2..So , modification will be :-

location assembly instruction

0            load 16

1            sub 7

2            bge 1

3             add 7

4             store 4

Please log in or register to answer this question.

Related questions

1 vote
1 answer
125 views asked Sep 22, 2019 in CO and Architecture Jit Saha 1 125 views
2 votes
1 answer
105 views asked Sep 22, 2019 in CO and Architecture Jit Saha 1 105 views
0 votes
4 answers
A sorting technique that guarantees that records with same primary key in the same order in the sorted list as in the original unsorted list is said to be....
asked Sep 22, 2019 in DS Nukku 302 views