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?

C for Java programmers (part 3)
C for Java programmers (part 3)C for Java programmers (part 3)
C for Java programmers (part 3)Dmitry Zinoviev
 
C for Java programmers (part 2)
C for Java programmers (part 2)C for Java programmers (part 2)
C for Java programmers (part 2)Dmitry Zinoviev
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)Dmitry Zinoviev
 
Types of pointer in C
Types of pointer in CTypes of pointer in C
Types of pointer in Crgnikate
 
Advanced C programming
Advanced C programmingAdvanced C programming
Advanced C programmingClaus Wu
 
Exercicios Resolvidos Série MIPS Embarcados
Exercicios Resolvidos Série MIPS EmbarcadosExercicios Resolvidos Série MIPS Embarcados
Exercicios Resolvidos Série MIPS EmbarcadosElaine Cecília Gatto
 
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 languagegourav kottawar
 
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)Saifur Rahman
 
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 #5Ismar Silveira
 
เขียนโปรแกรมใช้คำสั่ง Printf scanf
เขียนโปรแกรมใช้คำสั่ง  Printf scanfเขียนโปรแกรมใช้คำสั่ง  Printf scanf
เขียนโปรแกรมใช้คำสั่ง Printf scanfธงชัย พาศรี
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppteShikshak
 

Was ist angesagt? (18)

C for Java programmers (part 3)
C for Java programmers (part 3)C for Java programmers (part 3)
C for Java programmers (part 3)
 
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

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, 2013Kyle Hillman
 
Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2iOinkyDoink
 
Coup De Beast - Prologue
Coup De Beast - PrologueCoup De Beast - Prologue
Coup De Beast - PrologueiOinkyDoink
 
Coup De Beast : Chapter 1.1
Coup De Beast : Chapter 1.1Coup De Beast : Chapter 1.1
Coup De Beast : Chapter 1.1iOinkyDoink
 
Presentation For Wiki
Presentation For WikiPresentation For Wiki
Presentation For Wikicarissime
 
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 MeetingsKyle Hillman
 
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.1iOinkyDoink
 
Synistema e le reti sociali
Synistema e le reti socialiSynistema e le reti sociali
Synistema e le reti socialiEmilioRebora
 
The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1iOinkyDoink
 
Project – Embedded
Project – EmbeddedProject – Embedded
Project – Embeddedaryutomo
 
Coup De Beast : Prologue 2
Coup De Beast : Prologue 2Coup De Beast : Prologue 2
Coup De Beast : Prologue 2iOinkyDoink
 
Presentation For Wiki2
Presentation For Wiki2Presentation For Wiki2
Presentation For Wiki2carissime
 
La electricidad en_la_vida_cotidiana
La electricidad en_la_vida_cotidianaLa electricidad en_la_vida_cotidiana
La electricidad en_la_vida_cotidianaAlfonso Pérez
 
【清新出品】中国风系列2~梅为水墨香染成.ppt
【清新出品】中国风系列2~梅为水墨香染成.ppt【清新出品】中国风系列2~梅为水墨香染成.ppt
【清新出品】中国风系列2~梅为水墨香染成.pptjohn cheung
 

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
 
Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2
 
Coup De Beast - Prologue
Coup De Beast - PrologueCoup De Beast - Prologue
Coup De Beast - Prologue
 
Coup De Beast : Chapter 1.1
Coup De Beast : Chapter 1.1Coup De Beast : Chapter 1.1
Coup De Beast : Chapter 1.1
 
Presentation For Wiki
Presentation For WikiPresentation For Wiki
Presentation For Wiki
 
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
 
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
 
1
11
1
 
Turtle And The Hare
Turtle And The HareTurtle And The Hare
Turtle And The Hare
 
Synistema e le reti sociali
Synistema e le reti socialiSynistema e le reti sociali
Synistema e le reti sociali
 
The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1
 
Project – Embedded
Project – EmbeddedProject – Embedded
Project – Embedded
 
Coup De Beast : Prologue 2
Coup De Beast : Prologue 2Coup De Beast : Prologue 2
Coup De Beast : Prologue 2
 
Presentation For Wiki2
Presentation For Wiki2Presentation For Wiki2
Presentation For Wiki2
 
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

Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughterQuinn Wilton
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
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 EscalationKernel TLV
 
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)MahiboobAliMulla
 
NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016Mikhail Sosonkin
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)bolovv
 
Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersPVS-Studio
 
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.comamaranthbeg8
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.combellflower148
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.combellflower169
 
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.combellflower126
 
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 2PVS-Studio
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computerMartial Kouadio
 
N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)Selomon birhane
 
Exploiting Memory Overflows
Exploiting Memory OverflowsExploiting Memory Overflows
Exploiting Memory OverflowsAnkur Tyagi
 

Ä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 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
 
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
 
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

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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 Scriptwesley chun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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...Miguel Araújo
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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...apidays
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

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?