SlideShare ist ein Scribd-Unternehmen logo
1 von 9
ECE 3724/CS 3124 Test #2 – Summer 2005- Reese
You may NOT use a calculator. You may use only the provided reference materials. If a binary result is
required, give the value in HEX. Assume all variables are in the first 128 locations of bank 0 (access
bank) unless stated otherwise.
Part I: (82 pts)
a. (6 pts) Write a PIC18 assembly code fragment to implement the following.

         signed int i, k;
         i = k << 1;
b. (8 pts) Write a PIC18 assembly code fragment to implement the following. The code of the if{} body
    has been left intentionally blank; I am only interested in the comparison test. For the if{} body
    code, just use a couple of dummy instructions so I can see the start/begin of the if{} body.

       int i, k;
       if (i == k) {
       ..operation 1...
       ..operation 2....
       }
c. (6 pts) Write a PIC18 assembly code fragment to implement the following:

         signed char j, k;
         while ( k >= j) { operation 1...
         operation 2...
         }
d. ( 8 pts) Implement the doshift subroutine in PIC18 assembly language. Assume the value of ptr has
     been passed in the FSR0 register by the calling subroutine. Do not forget that this is a
     subroutine!!!!!!

// shift function
doshift (unsigned int *ptr){
*ptr = (*ptr) >> 1;
}

                                        loop_top:
                                        movf ___,w
                                        _____ ___,w
                                        b____ L1
                                        b____ loop_body ;if true, loop body
                                        bra loop_exit ;exit
                                        L1
                                        b____ loop_exit ;if false, exit
                                        loop_body:
                                        ...code for operation 1...
                                        ...code for operation 2....
                                        loop_exit
                                        ....rest of code....
e. (9 pts) Implement the main() code below in PIC assembly. You MUST pass the parameters for
    the a_sub() function using the CBLOCK locations for the function a_sub(). You CANNOT just use
    FSR0 for passing the ptr value to a_sub().

     a_sub (char c, long *ptr){
     // some code ...... //
     }
     main() {
     char p;
     long k;
     // some code that initializes
     // p, k ....., don’t worry about this
     //now, call a_sub() function
     a_sub( p, &k);
     }
f. (8 pts) Write a PIC18 assembly code fragment to implement the following. The code of the if{} body
     has been left intentionally blank; I am only interested in the comparison test. For the if{} body
     code, just use a couple of dummy instructions so I can see the start/begin of the if{} body.

       int i, k;
       if ((i == 0) && (k != 0) ) {
       ..operation 1...
       ..operation 2....
       }

CBLOCK 0x060 // parm. block for main
                                          // define p, k space here, fill in blanks
                                          p: ____, k: ______
                                          ENDC

CBLOCK 0x040 // parm. block for a_sub
                                          c: 1, ptr: 2
                                          ENDC
g. (6 pts) Write a PIC18 assembly code fragment to implement the following:

       long p, q;
       p = p - q;
h. (15 pts)

After the execution of ALL of the C code below, fill in the memory location values. Assume
little-endian order for multi-byte values.
Location Contents (MUST BE GIVEN IN HEX!!!!)
0x0150 ___________
0x0151 ___________
0x0152 ___________
0x0153 ___________
0x0154 ___________
0x0155 ___________
0x0156 ___________
0x0157 ___________
0x0158 ___________
0x0159 ___________
0x015A ___________

CBLOCK 0x0150
r:2, t:4, s:1, ptra:2, ptrb:2
ENDC
C code:
unsigned int r;
signed long t; // this is SIGNED!!!!!!!
signed char s; // this is SIGNED!!!!!!!
signed char *ptra;
unsigned int *ptrb;
r = 256; // specified in decimal!! (3 pts)
t = -2; // specified in decimal!! ( 3 pts)
s = -49; // specified in decimal!!!! (3 pts)
ptra = &s; (3 pts)
ptrb = &r;
ptrb++; (3 pts)
i. (16 pts)

For each of the following problems, give the FINAL contents of changed registers or memory locations.
Give me the actual ADDRESSES for a changed memory location (e.g. Location 0x0100 = 0x??).
Assume these memory/register contents at the BEGINNING of EACH problem!!!
Memory:                                  FSR1, 0x0100
0x0100 0x45                              movff PLUSW1, 0x0100
0x0101 0xFF              l. (4 pts)
0x0102 0xBA
0x0103 0x3C                              lfsr FSR1, 0x0103
0x0104 0x64
                                         movff POSTDEC1,0x100
j. (4 pts)
                         m. (4 pts) (careful on this one!!!!!)
               lfsr
                                       lfsr FSR1, 0x0103
               FSR
                                       movff FSR1H,0x100
               1,
               0x0      FSR1 = ____________
               101      Location ________ = _________
               mo
               vff      W register = 0x03
               PR
               EIN      FSR1 = ____________
               C1,      Location ________ = _________
               0x0
                        FSR1 = ____________
               100      Location ________ = _________
k. (4 pts)
                        FSR1 = ____________
               lfsr     Location ________ = _________
Part II: (18 pts) Answer 6 out of the next 8 questions. Cross out the 2 questions that you do not
want graded. Each question is worth 3 pts.
    1. Fill in memory location below, and either a CALL or RCALL instruction (use mnemonic,
         not machine code) such that a value of 0x0104 is pushed as the return address on the
         stack

Mem location instruction
__________ __________
   2. Write an 8-bit addition such that afterwards, both the V and the N flags are set.

____________ + ______________ afterwards, V=1,N=1
   3. Given an N-bit number, what number range can I represent using 2’s complement
       encoding?
4. In the code below, what is the value of i when the loop is exited? Give the value in either
    hex or decimal.

signed char i;
i = 0x80;
while (i <= -32) {
i = i >> 1;
}
5. Give the machine code for the ‘bnn 0x200’ instruction below given the locations shown:

            location
            0x0200 decf 0x02,f
            0x0202 ???
            0x0204 ???
            0x0206 ???
            0x0208 bnn 0x200
6. On the PIC18, can I nest subroutine calls as deep as I want? (i.e. subroutine A calls
    subroutine B calls Subroutine C calles Subroutine D ....etc). If NO, then why? Be
    detailed.
7. Why is the width of the FSR0, FSR1, FSR2 registers different from the width of
    registers like the WREG and general purpose registers in the data memory?
8. Why can’t subroutine calls just be implemented with GOTO statements? What is the
    special feature of CALL/RETURN instructions that is absolutely essential to
    implementing subroutines?

Weitere ähnliche Inhalte

Was ist angesagt?

เขียนโปรแกรมใช้คำสั่ง Printf scanf
เขียนโปรแกรมใช้คำสั่ง  Printf scanfเขียนโปรแกรมใช้คำสั่ง  Printf scanf
เขียนโปรแกรมใช้คำสั่ง Printf scanf
ธงชัย พาศรี
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
eShikshak
 

Was ist angesagt? (18)

Al2ed chapter18
Al2ed chapter18Al2ed chapter18
Al2ed chapter18
 
C for Java programmers (part 2)
C for Java programmers (part 2)C for Java programmers (part 2)
C for Java programmers (part 2)
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)
 
C tutorial
C tutorialC tutorial
C tutorial
 
Cbasic
CbasicCbasic
Cbasic
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Basics of c
Basics of cBasics of c
Basics of c
 
Types of pointer in C
Types of pointer in CTypes of pointer in C
Types of pointer in C
 
Advanced C programming
Advanced C programmingAdvanced C programming
Advanced C programming
 
Exercicios Resolvidos Série MIPS Embarcados
Exercicios Resolvidos Série MIPS EmbarcadosExercicios Resolvidos Série MIPS Embarcados
Exercicios Resolvidos Série MIPS Embarcados
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c language
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
C
CC
C
 
Csdfsadf
CsdfsadfCsdfsadf
Csdfsadf
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5
 
เขียนโปรแกรมใช้คำสั่ง Printf scanf
เขียนโปรแกรมใช้คำสั่ง  Printf scanfเขียนโปรแกรมใช้คำสั่ง  Printf scanf
เขียนโปรแกรมใช้คำสั่ง Printf scanf
 
Cbasic
CbasicCbasic
Cbasic
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
 

Andere mochten auch

Andere mochten auch (16)

Scott Stratten&rsquo;s Untalk 2013 at MPITechCon Feb 19, 2013
Scott Stratten&rsquo;s Untalk 2013 at MPITechCon Feb 19, 2013Scott Stratten&rsquo;s Untalk 2013 at MPITechCon Feb 19, 2013
Scott Stratten&rsquo;s Untalk 2013 at MPITechCon Feb 19, 2013
 
Synistema e le reti sociali
Synistema e le reti socialiSynistema e le reti sociali
Synistema e le reti sociali
 
The Artist at Heart : Chapter 2.1
The Artist at Heart : Chapter 2.1The Artist at Heart : Chapter 2.1
The Artist at Heart : Chapter 2.1
 
Project – Embedded
Project – EmbeddedProject – Embedded
Project – Embedded
 
MPITechCon Presentation on Future Trends of Meetings
MPITechCon Presentation on Future Trends of MeetingsMPITechCon Presentation on Future Trends of Meetings
MPITechCon Presentation on Future Trends of Meetings
 
1
11
1
 
Coup De Beast : Prologue 2
Coup De Beast : Prologue 2Coup De Beast : Prologue 2
Coup De Beast : Prologue 2
 
Coup De Beast - Prologue
Coup De Beast - PrologueCoup De Beast - Prologue
Coup De Beast - Prologue
 
Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2
 
Presentation For Wiki
Presentation For WikiPresentation For Wiki
Presentation For Wiki
 
Coup De Beast : Chapter 1.1
Coup De Beast : Chapter 1.1Coup De Beast : Chapter 1.1
Coup De Beast : Chapter 1.1
 
Turtle And The Hare
Turtle And The HareTurtle And The Hare
Turtle And The Hare
 
Presentation For Wiki2
Presentation For Wiki2Presentation For Wiki2
Presentation For Wiki2
 
The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1
 
La electricidad en_la_vida_cotidiana
La electricidad en_la_vida_cotidianaLa electricidad en_la_vida_cotidiana
La electricidad en_la_vida_cotidiana
 
【清新出品】中国风系列2~梅为水墨香染成.ppt
【清新出品】中国风系列2~梅为水墨香染成.ppt【清新出品】中国风系列2~梅为水墨香染成.ppt
【清新出品】中国风系列2~梅为水墨香染成.ppt
 

Ähnlich wie 1

EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
bolovv
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computer
Martial Kouadio
 

Ähnlich wie 1 (20)

Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Semtex.c [CVE-2013-2094] - A Linux Privelege EscalationSemtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
 
runtimestack
runtimestackruntimestack
runtimestack
 
B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 
Interesting facts on c
Interesting facts on cInteresting facts on c
Interesting facts on c
 
Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbers
 
Gsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comGsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.com
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.com
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.com
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.com
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computer
 
N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)
 
Exploiting Memory Overflows
Exploiting Memory OverflowsExploiting Memory Overflows
Exploiting Memory Overflows
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 

1

  • 1. ECE 3724/CS 3124 Test #2 – Summer 2005- Reese You may NOT use a calculator. You may use only the provided reference materials. If a binary result is required, give the value in HEX. Assume all variables are in the first 128 locations of bank 0 (access bank) unless stated otherwise. Part I: (82 pts) a. (6 pts) Write a PIC18 assembly code fragment to implement the following. signed int i, k; i = k << 1; b. (8 pts) Write a PIC18 assembly code fragment to implement the following. The code of the if{} body has been left intentionally blank; I am only interested in the comparison test. For the if{} body code, just use a couple of dummy instructions so I can see the start/begin of the if{} body. int i, k; if (i == k) { ..operation 1... ..operation 2.... }
  • 2. c. (6 pts) Write a PIC18 assembly code fragment to implement the following: signed char j, k; while ( k >= j) { operation 1... operation 2... } d. ( 8 pts) Implement the doshift subroutine in PIC18 assembly language. Assume the value of ptr has been passed in the FSR0 register by the calling subroutine. Do not forget that this is a subroutine!!!!!! // shift function doshift (unsigned int *ptr){ *ptr = (*ptr) >> 1; } loop_top: movf ___,w _____ ___,w b____ L1 b____ loop_body ;if true, loop body bra loop_exit ;exit L1 b____ loop_exit ;if false, exit loop_body: ...code for operation 1... ...code for operation 2.... loop_exit ....rest of code....
  • 3. e. (9 pts) Implement the main() code below in PIC assembly. You MUST pass the parameters for the a_sub() function using the CBLOCK locations for the function a_sub(). You CANNOT just use FSR0 for passing the ptr value to a_sub(). a_sub (char c, long *ptr){ // some code ...... // } main() { char p; long k; // some code that initializes // p, k ....., don’t worry about this //now, call a_sub() function a_sub( p, &k); } f. (8 pts) Write a PIC18 assembly code fragment to implement the following. The code of the if{} body has been left intentionally blank; I am only interested in the comparison test. For the if{} body code, just use a couple of dummy instructions so I can see the start/begin of the if{} body. int i, k; if ((i == 0) && (k != 0) ) { ..operation 1... ..operation 2.... } CBLOCK 0x060 // parm. block for main // define p, k space here, fill in blanks p: ____, k: ______ ENDC CBLOCK 0x040 // parm. block for a_sub c: 1, ptr: 2 ENDC
  • 4. g. (6 pts) Write a PIC18 assembly code fragment to implement the following: long p, q; p = p - q;
  • 5. h. (15 pts) After the execution of ALL of the C code below, fill in the memory location values. Assume little-endian order for multi-byte values. Location Contents (MUST BE GIVEN IN HEX!!!!) 0x0150 ___________ 0x0151 ___________ 0x0152 ___________ 0x0153 ___________ 0x0154 ___________ 0x0155 ___________ 0x0156 ___________ 0x0157 ___________ 0x0158 ___________ 0x0159 ___________ 0x015A ___________ CBLOCK 0x0150 r:2, t:4, s:1, ptra:2, ptrb:2 ENDC C code: unsigned int r; signed long t; // this is SIGNED!!!!!!! signed char s; // this is SIGNED!!!!!!! signed char *ptra; unsigned int *ptrb; r = 256; // specified in decimal!! (3 pts) t = -2; // specified in decimal!! ( 3 pts) s = -49; // specified in decimal!!!! (3 pts) ptra = &s; (3 pts) ptrb = &r; ptrb++; (3 pts)
  • 6. i. (16 pts) For each of the following problems, give the FINAL contents of changed registers or memory locations. Give me the actual ADDRESSES for a changed memory location (e.g. Location 0x0100 = 0x??). Assume these memory/register contents at the BEGINNING of EACH problem!!! Memory: FSR1, 0x0100 0x0100 0x45 movff PLUSW1, 0x0100 0x0101 0xFF l. (4 pts) 0x0102 0xBA 0x0103 0x3C lfsr FSR1, 0x0103 0x0104 0x64 movff POSTDEC1,0x100 j. (4 pts) m. (4 pts) (careful on this one!!!!!) lfsr lfsr FSR1, 0x0103 FSR movff FSR1H,0x100 1, 0x0 FSR1 = ____________ 101 Location ________ = _________ mo vff W register = 0x03 PR EIN FSR1 = ____________ C1, Location ________ = _________ 0x0 FSR1 = ____________ 100 Location ________ = _________ k. (4 pts) FSR1 = ____________ lfsr Location ________ = _________
  • 7. Part II: (18 pts) Answer 6 out of the next 8 questions. Cross out the 2 questions that you do not want graded. Each question is worth 3 pts. 1. Fill in memory location below, and either a CALL or RCALL instruction (use mnemonic, not machine code) such that a value of 0x0104 is pushed as the return address on the stack Mem location instruction __________ __________ 2. Write an 8-bit addition such that afterwards, both the V and the N flags are set. ____________ + ______________ afterwards, V=1,N=1 3. Given an N-bit number, what number range can I represent using 2’s complement encoding?
  • 8. 4. In the code below, what is the value of i when the loop is exited? Give the value in either hex or decimal. signed char i; i = 0x80; while (i <= -32) { i = i >> 1; } 5. Give the machine code for the ‘bnn 0x200’ instruction below given the locations shown: location 0x0200 decf 0x02,f 0x0202 ??? 0x0204 ??? 0x0206 ??? 0x0208 bnn 0x200 6. On the PIC18, can I nest subroutine calls as deep as I want? (i.e. subroutine A calls subroutine B calls Subroutine C calles Subroutine D ....etc). If NO, then why? Be detailed.
  • 9. 7. Why is the width of the FSR0, FSR1, FSR2 registers different from the width of registers like the WREG and general purpose registers in the data memory? 8. Why can’t subroutine calls just be implemented with GOTO statements? What is the special feature of CALL/RETURN instructions that is absolutely essential to implementing subroutines?