1. 25 points) Consider the following code segment. mov.w #mys, R14 mov.w #myaa,
ID: 3890477 • Letter: 1
Question
1. 25 points) Consider the following code segment. mov.w #mys, R14 mov.w #myaa, R13 sub.w R14, R13 rra RI3 mov.w #0x7FFF, R7 6 7 1loop: mov.w R14+,R15 ige lskip mov.w R15, R7 10 11 1skip: dec.w R13 12 13 14 15 16 17 mya: dc16 4,5,6, -150 -45, 255 18 myaa jnz 1loop mov.b R7, PIOU swpb R7 mov.b R7, P2OU A. (4 points) How many words is allocated by the assembly directive in line 17? B. (4 points) What is the content of register R13 after the instruction in line 4 is completed? C. (8 points) what does this code segment do? Explain your answer. Hint: what does #0x7FFF represent? D. (4 points) What is the value of PIOUT and P2OUT at the end of the program. E. (5 points) Calculate the total execution time in seconds for the code sequence from above (line line 15) We know the following: the average CPI is 2 clocks per instruction. Assume the clock frequency is 1 MHz What is MIPS rate for this code?Explanation / Answer
A) DC16 allocated 16 bits or 2 bytes => 96 bits
B) mov.w #mya, R14 // move value mya into R14
mov.w #myaa, R13 // move value myaa into R13
sub.w R14,R13 // R13 = R13 – R14 = a
rra R13 // right shift R13 ( a or 97(1100001) ASCII value for a ) => 48
C) 0x7FFF is the highest 16-bit signed number. This code iterates over array mya storing values in register R15. Then compare these values to value stored in R7 which is initialized to 0x7FFF. If R7 >= R15 then decrement R13 otherwise update R7 by R15. When loop completed final value stored in R7 is copied to P1OUT. Swpb instruction takes LSB byte of register R7 and appends 0 in front to make it a 32bit word and this is copied to P2OUT.
D) P1OUT = 42
P2OUT = 42
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.