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

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

View Full Document Right Arrow Icon
1 Login: cs30x_______ Name _________________________ Student ID ____________________ Signature_______________________ CSE 30 Spring 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 ___________________ (22 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 ___________________ (215 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.

View Full Document Right Arrow Icon
2 1. Number Systems Convert FB3C 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 415 10 to the following (assume 16-bit word). Express answers in hexadecimal. (3 points) sign-magnitude _______________________________________________ 1’s complement _______________________________________________ 2’s complement _______________________________________________ Convert -396 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) 1. loader 5. program execution 9. resulting .s file 2. executable (.exe/a.out) 6. assembler 10. resulting .o file 3. compiler 7. preprocessor 4. source code (.c file) 8. 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) 00101100 01110110 10101010 +11010100 +01001101 +11010110 --------- --------- --------- N Z V C N Z V C N Z V C ----------------- ----------------- ----------------- | | | | | | | | | | | | | | | ----------------- ----------------- ----------------- 3. Branching Given the following SPARC assembly code write the equivalent function in C. Use only standard loops and if/else statements; no gotos ! (19 points) SPARC ASSEMBLY C .global subtract .section ".text" subtract: save %sp, -96, %sp mov %g0, %l0 ! local var count ! mapped to %l0 cmp %i0, %i1 be L3 nop bl L2 nop L1: inc %i1 inc %l0 cmp %i0, %i1 bne L1 nop mov %l0, %i0 ret restore L2: inc %i0 inc %l0 cmp %i0, %i1 bne L2 nop mov %l0, %i0 neg %i0 ret restore L3: mov %g0, %i0 ret restore
Image of page 3

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

View Full Document Right Arrow Icon
4 4. Bit Operations What is the value of %l0 after each statement is executed? Express your answers in hexadecimal.
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