Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 6 pages
Exam (elaborations)

CS/ECE 3810 Computer Organization | CS / ECE 3810 Midterm 2 Solutions – Answered 100% correct.

Document preview thumbnail
Preview 2 out of 6 pages

CS/ECE 3810 Computer Organization | CS / ECE 3810 Midterm 2 Solutions – Answered 100% correct - University of Utah.

Content preview

Name:
UID:




CS / ECE 3810 Midterm 1 – Feb 17th, 2026

Notes: Students are allowed to bring 1 A4/letter-sized sheet of paper with anything written/printed on both
sides. In addition, you may bring the “green sheet”. No phones, laptops, or internet access are allowed. You
may bring a simple calculator with no internet connectivity, that can be used for any numeric calculations
(but it’s also ok to write a mathematical term, say 1.4/2.2 GHz without doing the calculation). You may
of course not use your phone to surf the web or consult with others during the test. You may also not
use the MARS simulator or other calculators/tools for numeric conversions. If necessary, make reasonable
assumptions and clearly state them. The only clarifications you may ask for during the exam are definitions
of terms. You will receive partial credit if you show your steps and explain your line of thinking, so attempt
every question even if you can’t fully solve it. Complete your answers in the space provided (including the
back side of each page). Turn in your answer sheets before 12:10pm. The test is worth 100 points and you
have about 90 minutes, so allocate time accordingly. Confirm that you have 12 questions on 7 pages.

1. Perform the following conversions. Show your steps!

(a) Convert the binary integer 1110 0110 into a hexadecimal integer. (2 points)
Solution: 0xe6
(b) Convert the hexadecimal integer c2 into a decimal integer. (2 points)
Solution: 12 × 16 + 2 = 194.
(c) Convert the decimal integer 38 into an 8-bit binary integer. (2 points)
Solution: 0010 0110

2. When defining and designing a processor today, would you use a RISC-style architecture or a CISC-
style architecture? Why? (4 points)
Solution: Since the 1990s, it has become clear that RISC is the technically better approach, so that is
what we should use if we can define a new architecture from scratch. RISC keeps the instructions sim-
ple, thus allowing the hardware to have a smaller footprint in terms of area, cost, power, and energy.
It also has faster circuits, which can help with performance. As we will learn later, simple instructions
are also easier to analyze and re-order for high performance. Occasionally, CISC instructions are ok
if the benefit clearly outweighs the above penalties.

3. Provide an example of a pseudo-instruction. What MIPS instruction(s) does the assembler convert it
to? (4 points)
Solution: There are many pseudo instructions. One example is “blt $t1, $t2, label”, which is con-
verted into “slt $1, $t1, $t2; bne $1, $zero, label”. ($1 is a register that MARS uses for such pseudo
instructions; it’s ok if you used some other register, but got the concept right. Also ok to mention other
simpler pseudo-instructions like subi, mov, etc.)

4. Consider the following MIPS/MARS code. The programmer has used two labels (label1 and label2)
in the code. What does the assembler do when it encounters label1 in the code? What does the as-
sembler do when it encounters label2 in the code? Show the actual MIPS instructions produced by

1

, the assembler that do not use the terms label1 and label2. (8 points)


.data
label1: .word 7
.text
label2:
la $t1, label1
lw $t2, 0($t1)
j label2

Solution: When the assembler sees label1 in the .data segment, it allocates four bytes of space in the
global memory. It remembers that future references to label1 should use an address with offset 0 from
$gp. When it later sees label1 in the .text segment, it puts $gp+0 into $t1.
When the assembler sees label2, it remembers the corresponding line number (PC essentially). When
it encounters “j label2”, it calculates that label2 is 8 bytes prior. So label2 is replaced with -8
(actually, it’s -12 because this offset is added to the default new PC of PC+4, but it’s ok for now if
you stated -8 or -12).
The new code produced by the assembler would therefore be:

addi $t1, $gp, 0
lw $t2, 0($t1)
j -12

5. Consider a program that declares global integer variables x, y, z[10]. These variables are allocated
starting at a base address of decimal 6000. The base address 6000 has been placed in $gp. Write the
two instructions that load y and z[2] into registers $s1 and $s2. (6 points)
Solution:

lw $s1, 4($gp) # loading y into $s1
lw $s2, 16($gp) # loading z[2] into $s2

6. For the pseudo assembly code below, replace X and Y with the smallest set of instructions to save/restore
values on the stack and update the stack pointer. procA is the caller procedure; it calls procedure
procB (not shown); both procedures are not using $fp. Both procedures are written independently by
two different programmers who are following the MIPS guidelines for caller-saved and callee-saved
registers. (12 points)

procA:
$s1 = ...
$s3 = ...
$t1 = ...
$t2 = ...
$t3 = ...
... = $a0




2

Document information

Uploaded on
May 3, 2026
Number of pages
6
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$14.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
MindCraft
3.8
(47)
Sold
370
Followers
7
Items
2789
Last sold
11 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions