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

• Homework Help
• PresidentHackerCaribou10582
• 15

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

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 ___________________

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

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 _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____ —> _____
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

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.
This is the end of the preview. Sign up to access the rest of the document.
• Winter '08
• Ord

{[ 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