Register Assume the memory/register contents shown in the table above at the sta
ID: 3886920 • Letter: R
Question
Register
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.
problem1: 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.
2.) Find the machine code for instruction mov 0x1234, W4
Register
Value Memory Location Value W0 0x1006 0x1002 0xBEEF W1 0xABBA 0x1000 0xFB80 W2 0xACDC 0x1004 0x8BAD W3 0x1002 0x1006 0xE7C0 W4 0x1003 0x1008 0x4F00Explanation / Answer
Solution:1
The PIC24 instruction sequence that computes k=j+i-33 is given below:
mov 0x1000, W1 (the statement will move i into register W1)
Modification after this statement execution: [ W1 <- 0xFB80 ]
mov 0x1002, W2 (the statement will move j into register W2)
Modification in the table after this statement execution: [ W1 <- 0xBEEF ]
add W1, W2, W0 (the statement will add i and j and stores the result in W0)
Modification in the table after this statement execution: [ W0 <- W1 + W2 = 0xFB80 + 0xBEEF= 0x1BA6F ]
sub W0, #33, W0 (the statement will subtract 33 from the value stored in W0)
Modification in the table after this statement execution: [W0 <- W0 - 33 = 0x1BA6F - 33 = 0x1BA3C ]
mov WREG, 0x1004 (the statement will move the result to location 0x1004 i.e. k)
Modification in the table after this statement execution: [ 0x1004 <- W0 = 0x1BA3C ]
2.
$t0, 0x1234ABCD ==> lui $at, 0x1234
ori $t0, $at, 0xABCD
d. while (i != j) {
loop-body statements
}