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

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

1 Login: cs30x_______ Name _________________________ Student ID ____________________ Signature_______________________ CSE 30 Fall 2007 Final Exam 1. Number Systems ___________________ (25 points) 2. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points) 3. Branching ___________________ (19 points) 4. Bit Operations ___________________ (13 points) 5. Recursion/SPARC Assembly ___________________ (10 points) 6. Local Variables, The Stack, Return Values ___________________ (20 points) 7. More Recursive Subroutines ___________________ (12 points) 8. Floating Point ___________________ (12 points) 9. Machine Instructions ___________________ (20 points) 10. Linkage, Scope, Lifetime, Data ___________________ (32 points) 11. Load/Store/Memory ___________________ (9 points) 12. Miscellaneous ___________________ (29 points) SubTotal ___________________ (213 points) Extra Credit ___________________ (10 points) Total ___________________
Image of page 1

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

2 1. Number Systems Convert FB4B 16 (2’s complement, 16-bit word) to the following. (6 points) binary _____________________________________ (straight base conversion) octal _______________________________________ (straight base conversion) decimal ____________________________________ (convert to signed decimal) Convert 432 10 to the following (assume 16-bit word). Express answers in hexadecimal. (3 points) sign-magnitude _______________________________________________ 1’s complement _______________________________________________ 2’s complement _______________________________________________ Convert -389 10 to the following (assume 16-bit word). Express answers in hexadecimal. (6 points) sign-magnitude _______________________________________________ 1’s complement _______________________________________________ 2’s complement _______________________________________________ C Compiling Sequence Put the following in the correct order/sequence using the numbers to the left of each word: (10 points) A. executable (.exe/a.out) B. assembler C. resulting .o file D. loader E. program execution F. resulting .s file G. compiler H. preprocessor I. source code (.c file) J. linkage editor _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____
Image of page 2
3 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) 00101101 00110111 11101001 +11010100 +01001001 +10010111 --------- --------- --------- N Z V C N Z V C N Z V C ----------------- ----------------- ----------------- | | | | | | | | | | | | | | | ----------------- ----------------- ----------------- 3. Branching Given the following C code write the equivalent function in unoptimized SPARC Assembly. Just perform a direct translation using the proper if-else structure discussed in class/notes (think opposite logic). (19 points) C SPARC Assembly int .global checkIfEvenAndPositive checkIfEvenAndPositive( int value ) .section ".text" { checkIfEvenAndPositive: if ( ((value % 2) == 0) && (value > 0) ) save %sp, -96, %sp return 1; else return 0; } In C, how could you rewrite/replace the expression (value % 2) == 0 to check if value is even such that the new expression is more optimal and does not translate into a function call or an expensive operation in SPARC Assembly? Give the more optimal expression:
Image of page 3

Info icon 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?
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern