Final.winter07

# SPARC Architecture, Assembly Language Programming, and C (2nd Edition)

• Homework Help
• PresidentHackerCaribou10582
• 15
• 100% (1) 1 out of 1 people found this document helpful

This preview shows pages 1–5. Sign up to view the full content.

1 cs30x_______ Name _________________________ Student ID ____________________ Signature_______________________ CSE 30 Winter 2007 Final Exam 1. Number Systems ___________________ (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points) 3. Branching ___________________ (17 points) 4. Bit Operations ___________________ (13 points) 5. Recursion/SPARC Assembly ___________________ (10 points) 6. Local Variables, The Stack, ld/st, and Return Values ___________________ (28 points) 7. Bit Slinging ___________________ (12 points) 8. Floating Point ___________________ (12 points) 9. Machine Instructions ___________________ (20 points) 10. Linkage, Scope, Lifetime, Data ___________________ (34 points) 11. Load/Store/Memory ___________________ (9 points) 12. Miscellaneous ___________________ (35 points) SubTotal ___________________ (217 points) Extra Credit ___________________ (10 points) Total ___________________

This preview has intentionally blurred sections. Sign up to view the full version.

2 1. Number Systems Convert 0xFBA9 (2’s complement, 16-bit word) to the following. (6 points) binary ______________________________________ (straight bit pattern translation) octal ________________________________________(straight bit pattern translation) decimal ____________________________________ (pos/neg decimal value from 2's complement encoding) Convert 309 10 to the following (assume 16-bit word). Express answers in hexadecimal. (3 points) sign-magnitude __________________________________ 1’s complement __________________________________ 2’s complement __________________________________ Convert -428 10 to the following (assume 16-bit word). Express answers in hexadecimal. (6 points) sign-magnitude ___________________________________ 1’s complement __________________________________ 2’s complement __________________________________ 2. Binary Addition/Condition Code Bits/Overflow Detection Indicate what the condition code bits are when adding the following 8-bit 2’s complement numbers. (12 points) 00011011 01010101 10110110 +01101011 +11011001 +01001010 --------- --------- --------- N Z V C N Z V C N Z V C ----------------- ----------------- ----------------- | | | | | | | | | | | | | | | ----------------- ----------------- -----------------
3 3. Branching Write the SPARC assembly statements to perform the following C statements. Do not optimize nops. Be sure to properly ld/st local vars. Remember logical OR short circuiting. (17 points) C _SPARC assembly_ int a; ! local var a mapped to %fp - 4 int b; ! local var b mapped to %fp - 8 /* other stmts here giving a and b values */ save %sp, -(92 + 8) & -8, %sp if ( a != 15 || b < 35 ) { a = foo( b % 17 ); } else { b = a - b; } /* other stmts here */

This preview has intentionally blurred sections. Sign up to view the full version.

4 4. Bit Operations What is the value of %l0 after each statement is executed? Express your answers in hexadecimal. set 0xCAFE2007, %l0 set 0x867B5309, %l1 or %l0, %l1, %l0 Value in %l0 is _______________________________________ (2 points) set 0xCAFE2007, %l0 sll %l0, 9, %l0 Value in %l0 is _______________________________________ (2 points) set 0xCAFE2007, %l0 srl %l0, 9, %l0 Value in %l0 is _______________________________________ (2 points) set 0xCAFE2007, %l0 set 0x????????, %l1 xor %l0, %l1, %l0 ! Value in %l0 is now OxFEEDFACE Value set in %l1 must be this bit pattern _______________________________________ (3 points) set 0xCAFE2007, %l0 set 0x867B5309, %l1 and %l0, %l1, %l0 Value in %l0 is _______________________________________ (2 points) set 0xCAFE2007, %l0 sra %l0, 11, %l0 Value in %l0 is _______________________________________ (2 points)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern