Professional Documents
Culture Documents
Assignment 1 Solution_29e8954948de09f86fb86e13da78933d
Assignment 1 Solution_29e8954948de09f86fb86e13da78933d
Assignment 1 Solution_29e8954948de09f86fb86e13da78933d
1. Suppose the following 8051 delay subroutine is used for a certain program
SOLUTION
Label instruction cycle
DELAY : MOV R2,#250 2
AGAIN : MOV R3,#250 2
HERE : NOP 1
NOP 1
DJNZ R3,HERE 2
DJNZ R2,AGAIN 2
RET 1
(a) Determine the total number of instructions that runs throughout this
subroutine.
((3x250) + 2)x250 + 2 = 188,002 total number of instructions
(b) Determine the average cycles per instruction for this subroutine.
Total cycles = ((4x250) + 4)x250 + 3 = 251,003 cycles
Average CPI = total cycle / total instruction
= 251,003 / 188,002
= 1.33 @ 1.34
[1]
Universiti Malaysia Perlis
NDJ20903 COMPUTER SYSTEM 2023/2024 Sem 2
2. Suppose you have a 242,500 instruction program with the following instruction mix :
(a) What is the total number of clock cycles to complete this program?
ALU cycles = 35% of 242,500 = 84,875 x 1 = 84,875 cycles
Loads cycles = 25% of 242,500 = 60,625 x 2 = 121,250 cycles
Stores cycles = 15% of 242,500 = 36,375 x 2 = 72,750 cycles
Branches cycles = 25% of 242,500 = 60,625 x 5 = 303,125 cycles
(c) If the program runs on a 500MHz processor, what is the execution time for
each operation?
1 cycle time, ct = t = 1/f ➔ 1 / 500 x 106 ➔ 2 ns
Execution time, TEX = I x CPI x ct, where I x CPI = total clock cycles, C
Execution time for each operation :
ALU = 84,875 x 2 ns = 169.75 us
Loads = 121,250 x 2 ns = 242.5 us
Stores = 72,750 x 2 ns = 145.5 us
Branches = 303,125 x 2 ns = 606.25 us
[2]
Universiti Malaysia Perlis
NDJ20903 COMPUTER SYSTEM 2023/2024 Sem 2
(e) We observe that 35% of the ALU operation are paired with a load, and thus a
new program version with an additional operation is introduced. The new
operation takes 2 clock cycle but reduces the branch cycle to 3. Show the new
version’s table of instruction mix.
Operation Frequency Clock Cycle
ALU 23% 1
ALU+Loads 12% 2
Loads 25% 2
Stores 15% 2
Branches 25% 3
(g) If the new version runs on the same processor, determine the performance
between the old and the new program.
Performance New / Performance Old =
TEXOld / TEXNew = 2.4 / 2.02 = 1.19 @ New is 19% faster
[3]
Universiti Malaysia Perlis