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 The PIC and the XC compiler assume multibyte values are stored in littleendian
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 at address x
b The long integer at address x
c The integer at address x
d The char E at address xASCII encoding
Problem Assume each instruction below is located at xbea. Using the Programmers
Reference Manual for the PIC handassemble each of the following individual instructions.
a add #xdb w
b bra xa
c mov ww
Problem Foreachinstruction below assume initially PCxAESRxwxFFFF
wxAwxa and the contents of the sequential bytes in data memory begin
ning at x are xxxxxxAB, xCD and xEF. Give the contents of any
registers which have changed after each of the following instructions executes:
a mov.b #xw
b sub www
c mov ww
d nop
e bra Nxb
Problem Two bit signed integers in twos complement are to be added using a PICF
microcontroller. These two numbers, in hex, are xAF and xBC
a These two numbers are located in the sequential data RAM locations x to x The
rst number, xAF is at address x the second number, xBC is at address
x Show the contents of memory locations x to x
b These two numbers are moved into the working registers with the double word move instruc
tions, mov.d xw and mov.d xw Show the contents of registers w to w as bit
hex numbers after these move instructions execute.
c Thesequence of two instructions,
add www
addc www
are used to do the bit addition. What is the result of this addition as hex values found in
the register pair w and w immediately after these two instructions execute?
d The 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?
EE
Fall
Problem The subroutine delay
listing of this subroutine is
f :
f:
sub uses a simple loop to implement a delay. The assembly
mov.w
f: f ff f
f :
f:
fa:
fc: fd ff a
fe:
mov.w
add.w
nop
bra
return
count, w
#xffff w
w w w
NZxf
Assume an instruction frequency of MHz for an an instruction cycle time of 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, ms
c To make this delay exactly ms we may need to add nop instructions 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 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
