SlideShare una empresa de Scribd logo
1 de 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?

Más contenido relacionado

La actualidad más candente

La actualidad más candente (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
 

Destacado

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
 

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

Similar a 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
 

Similar a 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
 

Último

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Último (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

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?