Question: Problem 5 . The subroutine delay sub uses a simple loop to implement a delay. The assembly listing of this subroutine is 0 0 0

Problem 5. The subroutine delay sub uses a simple loop to implement a delay. The assembly
listing of this subroutine is
000002f4 :
2f4: 004080 mov.w count, w0
2f6: f1 ff 2f mov.w #0xffff, w1
000002f8 :
2f8: 008040 add.w w1, w0, w0
2fa: 000000 nop
2fc: fd ff 3a bra NZ,0x2f8
2fe: 000006 return
Assume an instruction frequency of 16 MHz for an an instruction cycle time of 62.5 ns.
(a) How many bytes of program memory does this subroutine, delay sub, occupy? How many
bytes of data memory are used?
(b) What value should be used for the variable count if the delay is to be as close as possible to,
but no greater than, 10 ms?
(c) To make this delay exactly 10 ms we may need to add nop instruction(s). Where in the code
and how many nop instructions, if any, should be added?
(d) On exiting this subroutine, what are the values of the ALU bits (N, OV, Z, and C), in the
status register?
(e) Can this subroutine be used to implement a 20 ms delay? Suggest a simple way to do this.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!