





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






**1. Number Systems ___________________ (15 points)
SubTotal ___________________ (80 points)
Extra Credit ___________________ (4 points)
Total ___________________
1. Number Systems
Convert EBBE 16 (2โs complement, 16-bit word) to the following. (6 points)
decimal ____________________________________
octal 0 ___________________________________
binary ____________________________________
Convert -171 10 to the following (assume 16-bit word). Express answers in hexadecimal. (6 points)
sign-magnitude 0x _______________________________________________
1โs complement 0x _______________________________________________
2โs complement 0x _______________________________________________
Convert +142 10 to the following (assume 16-bit word). Express answers in hexadecimal. (3 points)
sign-magnitude 0x _______________________________________________
1โs complement 0x _______________________________________________
2โs complement 0x _______________________________________________
4. Bit Operations
What is the value of %l0 after each statement is executed? Express your answers in hexadecimal.
set 0xBEADFDAD, %l set 0xB9653, %l or %l0, %l1, %l
Value in %l0 is 0x _______________________________________ (2 points)
set 0xBEADFDAD, %l sll %l0, 11, %l
Value in %l0 is 0x _______________________________________ (2 points)
set 0xBEADFDAD, %l sra %l0, 5, %l
Value in %l0 is 0x _______________________________________ (2 points)
set 0xBEADFDAD, %l set 0xB65, %l xor %l0, %l1, %l
Value in %l0 is 0x _______________________________________ (2 points)
Write the single SPARC assembly instruction to multiply the value in %l0 by 1024 without the use of .mul. Store the result back in %l0. (2 points)
5. Parameter Passing and Return Values
Write the equivalent unoptimized SPARC assembly language instructions to perform the following C code frag- ment. (10 points)
C SPARC assembly
x = foo( 172, -9876 ); /* x is mapped to %l0 */
Now optimize your answer to eliminate any delay slots. (2 points)
Optimized version of above SPARC assembly
Extra Credit
Optimize the following SPARC assembly language code fragment. There may be many ways of optimizing this code fragment, but some optimizations may be better than others. The better optimizations eliminate as many cycles as possible. The better optimizations get more points. (4 points)
Unoptimized Version Optimized Version
/* some code above here */
mov %l0, %o mov 16, %o call .mul nop
mov %o0, %l
add %fp, array_offset, %l ldub [%l2 + %l1], %l cmp %l3, โ\nโ be no_inc nop
inc %l
no_inc:
/* other code */