exam_final_109_spring_2020_sol

docx

School

North Carolina State University *

*We aren’t endorsed by this school

Course

109

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

14

Uploaded by CaptainVultureMaster1051

Report
Name: ________________________________________ Section : ____________ ECE 109 Final Exam w/ Solutions May 4, 2020 Cover Sheet This exam is Open Note, Open Book, Open Calculator, Open Computer for notes. No correspondence is allowed with anyone other than the instructor/proctor. You absolutely may NOT access online resources (Google, Yahoo, Chegg, etc.) to obtain any problem solutions or previous class work from ANY organization! This applies before and during the exam. You may NOT have any materials printed/downloaded which were received from Anyone other than the instructor or TAs. Absolutely NO IMs, E-Mails, Verbal Messages, or other communications during the exam! If you do not have a printer available you may complete your exam on plain/lined paper and upload it at the end. You MUST have a camera turned on you during the entire exam. If your computer does not have an exam use a cell phone. Be sure to have your charger cable ready to cover the entire exam period. This is a 120 minute exam. Students who arrive late will NOT be given extra time on the exam. You are allotted 15 minutes to print the exam, 120 minutes to complete the exam, and then a final 15 minutes to scan and upload the exam. If you are still working on the exam past the 120 minute time, this will be considered cheating. You WILL be required to show your work for full credit! Partial Credit will be Generous! Please turn in your exam when asked! I consider it cheating to continue to work on an exam when told to stop and will count this as an Honor Offence!! Exam Problem Grading: 10% For Trying. Writing anything intelligent on the test paper. 40% for choosing the correct methods and formulae 50% for placing the proper values into the proper places and for carrying through the math to get the final answer Failure to abide by these rules and the NCSU Honor Policy will result in a zero on the exam and will be treated as a violation of the NCSU Code of Student Conduct.
Name: __________________________ Read and sign the following statement. Failure to sign the statement will result in a zero on the exam. I have neither given nor received unauthorized assistance on this test. I have notified the proctor of any violations of the above policies. Signature: __________________________________________________ Grader : _____________________________________________ ECE 109 Spring 2020 Final Exam w/ Solutions Page 2 of 14 Question Points Topic Score 1 10 Transistor Gates 2 10 POS/SOP 3 15 State Diagrams 4 10 Assembly / Machine Conversions 5 10 Subroutines 6 27 Code Segments 7 18 Code Line Counting 8 10 Interrupts 9 10 Stack TOTAL 120
Name: __________________________ [1] [10 pts. Total] Transistor Circuits Complete the truth table and equations. Solving for intermediate nodes R and Q is not required but may help you in solving the final solution at node Z. ECE 109 Spring 2020 Final Exam w/ Solutions Page 3 of 14
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name: __________________________ [2] [10 pts total ] Logic Complete the circuit for the function shown. Choose your design to use the lowest number of gates. ECE 109 Spring 2020 Final Exam w/ Solutions Page 4 of 14
Name: __________________________ [ 3] [15 points total] State Machines Construct the next state and output table for the following state diagram. ECE 109 Spring 2020 Final Exam w/ Solutions Page 5 of 14
Name: __________________________ [4] [10 points] Assembly Language and Machine Code [a] For the following table convert the assembly language commands to machine code. Assume that each command is located at PC=x3100. This code is NOT sequential. 1. STR R2, R5, x0C 0111 010 101 001100 2. LD R2, VIR 0010 010 1 1010 0100 x1A4 3. ST R2, RATLANTA 0011 010 0 1001 1100 x09C 4. LEA R5, SEBRING 1110 101 1 1111 1111 x1FF Assume the following Symbol Locations: SEBRING x3100 DAYTONA x3127 VIR x30A5 RATLANTA x319D RAMERICA x465E WATKINS x31DE BARBER x3164 LAGUNA x316A ECE 109 Spring 2020 Final Exam w/ Solutions Page 6 of 14
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name: __________________________ [5] [10 pts] Subroutines [a] [2 pts] Upon jumping to a subroutine, where is the return address saved? R7 [b] [5 pts] The current PC = x3180. What are the min and max address values to which a subroutine may jump using the JSR command? 11 bits +1023 / -1024 x3FF / -x400 x2D80 / x3580 [c] [3 pts] To what addresses can a JSRR command jump to? Anywhere. 16 bit location ECE 109 Spring 2020 Final Exam w/ Solutions Page 7 of 14
Name: __________________________ [6] [27 points] Code Segments Complete the following code segments [a] [4 pts] Add R6 to R4 and put the result in R2 ADD R2, R6, R4 [b] [ 4 pts] Subtract R4 from x3248 and leave the result in R1 LD R1, BIGNUM NOT R4, R4 ADD R4, R4, #1 ADD R1, R1, R4 BRnzp NEXT BIGNUM .FILL x3248 NEXT [c] [4 pts] Compute R3 OR R5 and put result in R1 NOT R3, R3 NOT R5, R5 AND R1, R3, R5 NOT R1 [d] [10 pts] Assume string NUMS contains only chars ‘0’-‘9’. Add all the binary numeric values and leave the sum in memory at MYSUM. String NUMS is already defined. AND R3, R3, #0 ; clear sum LEA R5, NUMS ; get start of string LOOP1 LDR R0, R5, #0 ; get char BRz GO1 ; end of string ADD R0, R0, NEGASCII ; subtract ASCII Offset ADD R3, R3, R0 ; add to sum ADD R5, R5, #1 ; increment ptr to next char BRnzp LOOP1 GO1 ST R3, MYSUM BRnzp NEXT MYSUM .FILL x0000 NEGASCII .FILL #-48 NEXT ECE 109 Spring 2020 Final Exam w/ Solutions Page 8 of 14
Name: __________________________ [e] [5 pts] Read a character from the keyboard using GETC and compare to ‘F’. Set R5 =1 if character is F, set R5 = 0 if other. GETC ; read char LD R2, NEGF ; get negative ‘F’ AND R5, R5, #0 ; clear return code ADD R1, R0, R2 ; compare BRz GOHOME ADD R5, R5, #1 ; set return code to 1 BRnzp GOHOME NEGF .FILL #-70 GOHOME Alternative Solution uses KYBSR and KYBDR as GETC was not originally specified. ECE 109 Spring 2020 Final Exam w/ Solutions Page 9 of 14
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name: __________________________ [7] [18 pts] Code Counting Suppose the LC-3 has the code loaded as shown. Answer each question. [a] What is the address of the last instruction or variable declaration? x3075 [b] What is the address of the first instruction? x3030 [c] After the first LEA is executed, what is the value in R0? x303B [d] After the LDI instruction is complete, what value is in R2? x006D or ‘m’ [e] What is the first output to the display? Zoom Zoom! [f] What is the last output to the display? Podium Finish! [g] After the JSRR is executed what is the address of the next instruction fetched? x305D ECE 109 Spring 2020 Final Exam w/ Solutions Page 10 of 14 ; ; Final Code Counting .ORI G x3030 ; Comment Line 1 LEA R0, FERRARI PUTS LDI R2, MERC AND R4, R4, #0 ADD R4, R4, #7 LD R3, REDBULL LEA R5, BOXBOX JSRR R5
Name: __________________________ [8] [10] points Interrupts [a] [2 pts] When an internal interrupt occurs, due to events such as an illegal opcode, privileged operation, etc., this is called: Exception [b] [6 pts] Name three (3) things that must be preserved before servicing an interrupt. Processor Status Register, Program Counter, Registers [c] [2 pts] Where are these saved during the processing of an interrupt? On the Supervisor (Super) Stack ECE 109 Spring 2020 Final Exam w/ Solutions Page 11 of 14
Name: __________________________ [9] [10 pts total] Stack [a] [5 pts] Write the code to set up a user stack with x20 locations in memory. Set up the labels as required. In the main code above your stack setup show how to setup the Stack Pointer (SP, TOS, TOP) Do not worry about jumping around the .FILLs and .BLKWs, etc. MAIN LEA R6, STACKTOP HALT ; not required to show STACK .BLKW x1F STACKTOP .FILL x0000 [b] [5 pts] A stack is set up with the TOS (R6) pointing to x5000. After 5 PUSH and 2 POP operations, what is the new R6 value? x4FFD ECE 109 Spring 2020 Final Exam w/ Solutions Page 12 of 14
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name: __________________________ ECE 109 Spring 2020 Final Exam w/ Solutions Page 13 of 14
Name: __________________________ ECE 109 Spring 2020 Final Exam w/ Solutions Page 14 of 14 TRAP TABLE n 2 n -8 0.00390625 -7 0.0078125 -6 0.015625 -5 0.03125 -4 0.0625 -3 0.125 -2 0.25 -1 0.5 0 1 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 1 0 1024 1 1 2048