The procedure to calculate the execution time ET for an asse

The procedure to calculate the execution time (ET) for an assembly code is as follows: Determine the period (T) of the microcontroller clock using the equation: T = 1/(Frequency(f)) Determine the total number of cycles (C) to execute the code. This is done by determining the number of cycles for each instruction and adding them. The number of cycles each instruction takes to execute is found in the datasheet for the micro-controller. Calculate the execution time for the code using the following equation: ET = T * C Assuming that the below assembly code is running on a micro-controller being clocked by a 4MHz oscillator, answer the following: Calling Program BSA CMP HEX 100 DEC 32 Subroutine CMP, HEX 0 LDA CMP I STA PTR ISZ CMP LDA CMP I CMA INC STA CTR LOP, LDA PTR I CMA STA PIR I ISZ PTR I ISZ CTR BUN LOP ISZ CMP BUN CMP I PTR, --- CTR. --- Determine the period of the microcontroller clock using the equation?

Solution

Happy New Year 2017.

I could not get the datasheet with clock cycles you referred here.

So, I have assumed every instruction takes 1 clock cycle. Please go through the datasheet and calculate accordingly.

a)    Given microcontroller frequency = 4MHz.

   The Time period = 1/f = 1/(4MHz)
                       = 250ns.
                         
b)   Here CALLING PROGRAM has 3 instruction => 3 clock cycles. (Based on my assumption)
   SUBROUTINE has 18 instructions => 18 clock cycles.
       (I have not considered looping in the SUBROUTINE. If your want to do so, please do it)
      
   Total instructions = 3 + 18 = 21.
  
c)    Execution Time (ET) = T * C
                       = 250ns * 21
                       = 5250ns.
                      
ns = nano seconds.
T value obtained from (a)
C value obtained from (b)

 The procedure to calculate the execution time (ET) for an assembly code is as follows: Determine the period (T) of the microcontroller clock using the equation

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site