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

The following contents of registers and memory should be used in the solution of

ID: 3786822 • Letter: T

Question

The following contents of registers and memory should be used in the solution of homework problems. Specify addressing modes for each operand. the contents is the same prior to all instructions.

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.

Q: Write a PIC24 instruction sequence that computes k=j+i-33 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.

Register Value Memory Location Value W0 0x1006 0x1002 0xBEEF W1 0xABBA 0x1000 0xFB80 W2 0xACDC 0x1004 0x8BAD W3 0x1002 0x1006 0xE7C0 W4 0x1003 0x1008 0x4F00

Explanation / Answer

Solution:

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 ]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote