Problem 3. The unconditional branch instruction bra 0x2ec assembles into the 24-
ID: 2248314 • Letter: P
Question
Explanation / Answer
Answer:-3) PIC24 has 16-bit(8-bit + 8-bit) of wide memory, 24-bit machine code will take position in three 8-bit locations starting from 0x2d6, then 0x2d7 and ending at address 0x2d8. So next instruction will start from 0x2d9.
Answer:-4)a) mov w3, [w14] :- encoding format is 1001_1kkk_kBkk_kddd_dkkk_ssss.B=> Byte(1) or Word(0) movement s=> source, d=> destination, and k=> constant(max 10-bit value) offset if added with destination. So here we have s= 0011 for w3, d= 1110 for w14 and k= 0000000000. Hence the 24-bit machine code is:- 1001_1000_0000_0111_0000_0011.
b) add #-121, w0 :- Format is 1011_0000_0Bkk_kkkk_kkkk_dddd. In 10-bit binary, -121 = 11_1000_0111, d= 0000 for w0 and B=0 since add.b is not used. So machine code is:- 1011_0000_0011_1000_0111_0000.
c) bra LE, 0x28d :- Format is 0011_0100_nnnn_nnnn_nnnn_nnnn where n=> 16-bit address. For us n= 0x28d = 0000_0010_1000_1101 so the machine code is:- 0011_0100_0000_0010_1000_1101.
Answer:-5)a) The final value in W2 is -1. As MOV #100, W2 loads W2 with 100. REPEAT W2 means repeat next innstruction (W2 + 1 ) times, so DEC W2, W2 would execute 101 times making one decrement in W2 each time. Hence when 101th decrement is done then value in W2 will be -1.
b) We have the instruction frequency is 16 MHz i.e one machine cycle(MC) is 0.0625 micro second.
MOV #100, W2 takes 1 MC, REPEAT W2, W2 takes 1 MC and DEC W2, W2 takes ( 1 x 101 ) MC, so a total of 103 MC i.e time taken is 103 x 0.0625 microsecond = 6.4375 microsecond.
c) W14 has address 0x200 and it's a 16-bit memory location having 16-bit value 0x000a given. At address 0x202, 16 -bit value is 0x1014. The given program runs in a loop till value at address in W14 i.e 0x000a becomes zero, note that every loop execution decreases 0x000a by 2. So finally when loop terminates after five iterations value 0x000a has changed to 0x0000.
Then MOV [W14], W1 copies value present at address in W14 (i.e at address 0x200) to W1, hence W1 has value 0x0000 i.e zero. W0 has value 0x0000 on last loop iteration.
MOV W1, [W14 + 2], in W1 value is 0x0000 now and W14 has address 0x200 adding 2 to this gives 0x202 and at this address i.e at 0x202 value from W1, 0x0000 is copied. Hence at address 0x202 value has been changed from 0x1014 to 0x0000.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.