Question: Problem 1 . The PIC 2 4 and the XC 1 6 compiler assume multibyte values are stored in little - endian form. For each

Problem 1. The PIC24 and the XC16 compiler assume multibyte values are stored in little-endian
form. For each of the following decimal values show how it is stored in data memory by listing the
contents of each byte used.
(a) The unsigned integer 9057 at address 0x810.
(b) The long integer-13467 at address 0x812.
(c) The integer 2748 at address 0x816.
(d) The char E at address 0x818.(ASCII encoding).
Problem 2. Assume each instruction below is located at 0x000bea. Using the Programmers
Reference Manual for the PIC24, hand-assemble each of the following individual instructions.
(a) add #0xdb, w0
(b) bra 0x037a
(c) mov w2,[w14]
Problem 3. Foreachinstruction below assume initially (PC)=0x2AE,(SR)=0x0000,(w0)=0xFFFF,
(w1)=0x080A,(w15)=0x080a, and the contents of the 8 sequential bytes in data memory begin
ning at 0x0806 are 0x01,0x23,0x45,0x67,0x89,0xAB, 0xCD, and 0xEF. Give the contents of any
registers which have changed after each of the following instructions executes:
(a) mov.b #0x12,w0
(b) sub w1,w0,w1
(c) mov [w15++],[--w1]
(d) nop
(e) bra N,0x0002b4
Problem 4. Two 32-bit signed integers in twos complement are to be added using a PIC24F
microcontroller. These two numbers, in hex, are 0x8A691F60 and 0x20B7C050.
(a) These two numbers are located in the 8 sequential data RAM locations 0x800 to 0x807. The
rst number, 0x8A691F60, is at address 0x800, the second number, 0x20B7C050, is at address
0x804. Show the contents of memory locations 0x800 to 0x807.
(b) These two numbers are moved into the working registers with the double word move instruc
tions, mov.d 0x800,w0 and mov.d 0x804,w2. Show the contents of registers w0 to w3 as 16-bit
hex numbers after these move instructions execute.
(c) Thesequence of two instructions,
add w0,w2,w0
addc w1,w3,w1
are used to do the 32-bit addition. What is the result of this addition (as hex values) found in
the register pair w0 and w1 immediately after these two instructions execute?
(d) The 32-bit addition in (c) will a ect bits in the Status Register (SR). Immediately after the
addc instruction completes what are the values for the N, OV, Z, and C bits in this register?
EE2361
Fall 2024
Problem 5. The subroutine delay
listing of this subroutine is
000002f4 :
2f4: 004080
sub uses a simple loop to implement a delay. The assembly
mov.w
2f6: f1 ff 2f
000002f8 :
2f8: 008040
2fa: 000000
2fc: fd ff 3a
2fe: 000006
mov.w
add.w
nop
bra
return
count, w0
#0xffff, w1
w1, w0, w0
NZ,0x2f8
Assume an instruction frequency of 16 MHz for an an instruction cycle time of 62.5 ns.
(a) How many bytes of program memory does this subroutine, delay
bytes of data memory are used?
sub, occupy? How many
(b) What value should be used for the variable count if the delay is to be as close as possible to,
but no greater than, 10 ms?
(c) To make this delay exactly 10 ms we may need to add nop instruction(s). Where in the code
and how many nop instructions, if any, should be added?
(d) On exiting this subroutine, what are the values of the ALU bits (N, OV, Z, and C), in the
status register?
(e) Can this subroutine be used to implement a 20 ms delay? Suggest a simple way to do this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!