Breaking News

CS501 Assignment 01 Solution Fall 2021

 CS501 Assignment 01 Solution Fall 2021


CS501 Assignment 01 Solution Fall 2021




Copy from here:

CS501 Assignment 01 Solution Fall 2021


Question no.01:
a.Write the instructions for 0-address machine to evaluate the following expression.
    z = x2 + y2 + 2xy
Solution:
0 address instructions
PUSH x
PUSH x
MUL
PUSH y
PUSH y
MUL
AD
Push x
PUSH y
MUL
PUSH 2
MUL
AD
POP z
b.Calculate the execution time for 0-address machine using the above given expression by considering the following parameters:
 
Average CPI Processor Frequency (f)    
6 2 GHz  
Solution:
Execution Time = IC * CPI * T
Where, 
 
IC=instruction count    
CPI=average number of system clock periods to execute an instruction  


T = clock period
putting the given value
ET=14X6X2
ET=168T
Question no. 02
        Reverse assemble the following SRC machine language instructions:
         a.B2064000h
         b.1A0C0022h
Solution(a):
B2064000h
First, convert the hexadecimal into binary pattern which is:
1011 0010 0000 0110 0100 0000 0000 0000
The first 5 bits of the binary pattern represent the opcode which is 22. This opcode 22 belongs to or instruction which is a D instruction of SRC.The  format of modified D instruction is:

31                    27  26                   22    21                 17    16                  12    11             0         
 
opcode ra rb rc unused  

In modified D instruction, the first 5 bits represent opcode, and next 15 bits represent the one destination and two source operands of 5-bits each. We split the given bit pattern according to the modified type-D instruction format following:

Next, we specify the instruction field for each the section as following:

 
10110 01000 00011 00100 00000    
or R8 R3 R4 unused  

Hence, the SRC instruction will be: or R8,R3,R4
(b)1A0C0022h

First, convert the hexadecimal into binary pattern which is:

0001 1010 0000 1100 0000 0000 0010 0010

The first 5 bits of the binary pattern represent the opcode which is 3. This opcode 3 belongs to st instruction which is a C instruction of SRC.The  format of C instruction is:
                     31                         27  26        22  21       17 16                0
 
         opcode    ra    rb c2  



Next, we specify the instruction field for each the section as following:

 
00011 01000 00110 00000000000100010    
st R8 R6 34  

Hence, the SRC instruction will be: st R8,R6,34


CS501 Assignment 1 Solution 2021, CS501 Assignment 01 Solution 2021, CS 501 Assignment 01 Solution 2021, CS501 Assignment No. 1 Solution 2021, CS501 Assignment No. 1Solution 2021, CS 501 Assignment 1 Solution Fall 2021, CS601 Assignment 1 solution 21



No comments