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
Exam (elaborations)

CEG 2136 DGD4 2.25 Exercises

Rating
-
Sold
-
Pages
11
Grade
A+
Uploaded on
07-03-2026
Written in
2025/2026

2.25 Exercises Appendix A describes the MIPS simulator, which is helpful for these exercises. Although the simulator accepts pseudoinstructions, try not to use pseudoinstructions for any exercises that ask you to produce MIPS code. Your goal should be to learn the real MIPS instruction set, and if you are asked to count instructions, your count should reflect the actual instructions that will be executed and not the pseudoinstructions. There are some cases where pseudoinstructions must be used (for example, the la instruction when an actual value is not known at assembly time). In many cases, they are quite convenient and result in more readable code (for example, the li and move instructions). If you choose to use pseudoinstructions for these reasons, please add a sentence or two to your solution stating which pseudoinstructions you have used and why. 2.1 [5] §2.2 For

Show more Read less
Institution
Revision
Course
Revision

Content preview

2.25 Exercises
Appendix A describes the MIPS simulator, which is helpful for these
exercises. Although the simulator accepts pseudoinstructions, try not
to use pseudoinstructions for any exercises that ask you to produce
MIPS code. Your goal should be to learn the real MIPS instruction
set, and if you are asked to count instructions, your count should
reflect the actual instructions that will be executed and not the
pseudoinstructions.
There are some cases where pseudoinstructions must be used (for
example, the la instruction when an actual value is not known at
assembly time). In many cases, they are quite convenient and result
in more readable code (for example, the li and move instructions). If
you choose to use pseudoinstructions for these reasons, please add a
sentence or two to your solution stating which pseudoinstructions
you have used and why.

2.1 [5] <§2.2> For the following C statement, what is the
corresponding MIPS assembly code? Assume that the C
variables f, g, and h, have already been placed in registers $s0,
$s1, and $s2, respectively. Use a minimal number of MIPS
assembly instructions.
f = g + (h – 5);
2.2 [5] <§2.2> Write a single C statement that corresponds to the
two MIPS assembly instructions below.
add f, g, h
add f, i, f
2.3 [5] <§§2.2, 2.3> For the following C statement, write the
corresponding MIPS assembly code. Assume that the variables
f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and
$s4, respectively. Assume that the base address of the arrays A
and B are in registers $s6 and $s7, respectively.
B[8] = A[i–j];
2.4 [5] <§§2.2, 2.3> For the MIPS assembly instructions above,
what is the corresponding C statement? Assume that the

, variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2,
$s3, and $s4, respectively. Assume that the base address of the
arrays A and B are in registers $s6 and $s7, respectively.




2.5 [5] <§2.3> Show how the value 0xabcdef12 would be
arranged in memory of a li le-endian and a big-endian
machine. Assume the data are stored starting at address 0 and
that the word size is 4 bytes.
2.6 [5] <§2.4> Translate 0xabcdef12 into decimal.
2.7 [5] <§§2.2, 2.3> Translate the following C code to MIPS.
Assume that the variables f, g, h, i, and j are assigned to
registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that
the base address of the arrays A and B are in registers $s6 and
$s7, respectively. Assume that the elements of the arrays A and
B are 8-byte words:
B[8] = A[i] + A[j];
2.8 [10] <§§2.2, 2.3> Translate the following MIPS code to C.
Assume that the variables f, g, h, i, and j are assigned to
registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that
the base address of the arrays A and B are in registers $s6 and
$s7, respectively.
addi $t0, $s6, 4
add $t1, $s6, $0
sw $t1, 0($t0)

Written for

Institution
Revision
Course
Revision

Document information

Uploaded on
March 7, 2026
Number of pages
11
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$10.99
Get access to the full document:

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

Get to know the seller

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.
Abbyy01 Exam Questions
Follow You need to be logged in order to follow users or courses
Sold
96
Member since
4 year
Number of followers
33
Documents
1337
Last sold
3 days ago

3.5

13 reviews

5
5
4
2
3
3
2
1
1
2

Recently viewed by you

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