Question: Problem 6. The following fragment of C code i=0; while(i <100) { i++;} compiles to the following assembly code 0x314: CLR W0 0x316: MOV W0,

Problem 6. The following fragment of C code i=0; while(i<100) { i++;} compiles to the following assembly code 0x314: CLR W0 0x316: MOV W0, [W14+6] 0x318: BRA 0x320 0x31A: MOV [W14+6], W0 0x31C: INC W0, W0 0x31E: MOV W0, [W14+6] 0x320: MOV [W14+6], W1 0x322: MOV #0x63, W0 0x324: SUB W1, W0, [W15] 0x326: BRA LE, 0x31A Each line begins with the program memory address on the left followed by the assembly code instruction at that address.

(a) How many bytes of physical program memory does this code occupy?

(b) How long does it take this code to execute?

(c) The assembly code shown above uses the stack. Here W14 is the frame pointer and W15 is the stack pointer. The assembly code can be simplified if we dont use the stack. Rewrite the assembly code shown to eliminate W14 and W15.

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 Databases Questions!