SlideShare une entreprise Scribd logo
1  sur  9
Télécharger pour lire hors ligne
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?

Contenu connexe

Tendances

Tendances (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
 

En vedette

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
 
Synistema e le reti sociali
Synistema e le reti socialiSynistema e le reti sociali
Synistema e le reti socialiEmilioRebora
 
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
 
Project – Embedded
Project – EmbeddedProject – Embedded
Project – Embeddedaryutomo
 
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
 
Coup De Beast : Prologue 2
Coup De Beast : Prologue 2Coup De Beast : Prologue 2
Coup De Beast : Prologue 2iOinkyDoink
 
Coup De Beast - Prologue
Coup De Beast - PrologueCoup De Beast - Prologue
Coup De Beast - PrologueiOinkyDoink
 
Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2Coup De Beast : Chapter 1.2
Coup De Beast : Chapter 1.2iOinkyDoink
 
Presentation For Wiki
Presentation For WikiPresentation For Wiki
Presentation For Wikicarissime
 
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 Wiki2
Presentation For Wiki2Presentation For Wiki2
Presentation For Wiki2carissime
 
The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1The Artist at Heart : Chapter 1
The Artist at Heart : Chapter 1iOinkyDoink
 
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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 

Dernier (20)

Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 

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?