Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

9. Write a PIC24 instruction sequence that computes k=j+1-i where i,j, and k are

ID: 2247932 • Letter: 9

Question

9. Write a PIC24 instruction sequence that computes k=j+1-i where i,j, and k are uint16 variables. Allocate these variables as follows: i is at memory location 0x1000, j is at memory location 0x1002 and k is at memory location 0x1004.

10. Find the machine code for instruction mov 0x1234, W4

Register Value 0x1006 0xABBA OxACDC 0x1002 0x1003 Memory Location 0x1002 0x1000 0x1004 0x1006 0x1008 Value 0xBEEF 0xFB80 0x8BAD 0xE7CO 0x4F00 0 4 Assume the memory/register contents shown in the table above at the start of each instruction. In your answer provide modified memory location or register and its content.

Explanation / Answer


k=j+1-i
b. i=((k-j)>>4)& 0x0F
c. if(i<=j) {
if-body statements
} else {
else-body statements
}

10)

$t0, 0x1234ABCD ==> lui $at, 0x1234

ori $t0, $at, 0xABCD

d. while (i != j) {
loop-body statements
}