Final.wi09

# Final.wi09 - Login: cs30x_ Name _ Student ID _ Signature_...

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

1 Login: cs30x_______ Name _________________________ Student ID ____________________ Signature_______________________ CSE 30 Winter 2009 Final Exam 1. Number Systems / C Compiling Sequence ___________________ (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points) 3. Branching ___________________ (20 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 ___________________ (10 points) 8. Floating Point ___________________ (12 points) 9. Machine Instructions ___________________ (20 points) 10. Linkage, Scope, Lifetime, Data ___________________ (32 points) 11. Load/Store/Memory ___________________ (11 points) 12. Miscellaneous ___________________ (27 points) SubTotal ___________________ (202 points) Extra Credit ___________________ (15 points) Total ___________________

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

View Full Document
2 1. Number Systems Convert 0xFB76 (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 429 10 to the following (assume 16-bit word). Express answers in hexadecimal. (3 points) sign-magnitude _______________________________________________ 1’s complement _______________________________________________ 2’s complement _______________________________________________ Convert -392 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) 11010110 10111001 01011101 +10111011 +01010110 +01101001 --------- --------- --------- N Z V C N Z V C N Z V C ----------------- ----------------- ----------------- | | | | | | | | | | | | | | | ----------------- ----------------- -----------------
3 3. Branching (20 points) Given the following SPARC assembly code write the equivalent function in C. Use only standard loops and if/else statements; no gotos ! SPARC ASSEMBLY C .global branching .section ".text" branching: save %sp, -96, %sp call rand nop mov %o0, %l1 ! local var int x ! mapped to %l1 cmp %l1, 99 bge L4 nop L1: cmp %l1, 42 bl L2 nop add %l1, 4, %l1 ba L3 nop L2: mov %l1, %o0 mov 5, %o1 call .rem nop mov %o0, %l1 L3: cmp %l1, 99 bl L1 nop L4: add %l1, 17, %l1 mov %l1, %i0 ret restore For the following instruction sequence, mark with an X under the conditional branch instructions which would transfer control to doit if used in place of ba . [+1 correct; -1 incorrect] Instruction sequence blu bpos bgu bne ble bge bneg bvs mov -5, %l0 cmp %l0, 8 ba doit nop

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## Final.wi09 - Login: cs30x_ Name _ Student ID _ Signature_...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online