CS 2318 (Assembly Language) by Lee S. Koh

Final Exam Study Guide 

■ General



● When:


    SectionDateStart Time


    25705-07-2026 (Thursday)05:00 pm



    256
05-07-2026 (Thursday)08:00 pm


● Duration: 2 hours 30 minutes (in-class, face-to-face).

● Test will be closed books / notes / online-resources / discussion and no calculating devices of any kind are allowed.


► All allowed reference material (such as the first 2 pages of this posted under Other Resources) will be provided as part of the exam.

● Exam will be comprehensive (i.e., cumulative).



■ For earlier (previously tested) topics: refer to Exam 1 Study Guide and Exam 2 Study Guide previously posted.

■ For latter topics, following is a checklist of (most if not all) the things you are expected to know and/or know how to do/apply:

● How to develop assembly language program requiring (in addition to sequence) selection (decision-making) and repetition (looping) logic


► Know how to re-write C++ code involving selection (if and if-else) and/or repetition (for, while and do-while) and/or one-way transfer (break and continue) in terms of conditional and unconditional goto's.



○ (NOTE: Prerequisite C++ neatly used to play "pseudo-code" role in this course.)



○ May be nested and may involve compound conditions (i.e., conditions involving logical AND and/or logical OR).



○ May have question(s) testing student's ability to read (interpret)/debug/complete/modify/... code involving above use of conditional and unconditional goto's (in like fashion as Assignment 2 Part 2).

● How to translate into MIPS assembly language code (based on algorithm expressed in C++ or pseudocode) - in like fashion as Assignment 2 Part 3 and Assignment 3 Part 1:


► Code that can be successfully exercised on MARS (Java-based MIPS emulator modified for use in this class).


► Code that make use of instructions/pseudoinstructions listed in MIPS instructions/pseudoinstructions covered in class that have been covered (plus any not on the list but seen used in class).


► May involve arithmetic, bit manipulation and main memory data movement.


► May involve selection (if and if-else) and/or repetition (for, while and do-while) and/or one-way transfer (break and continue).



○ May be nested and may involve compound conditions (i.e., conditions involving logical AND and/or logical OR).



○ Including traversing/processing arrays.


► May involve the Stack Segment and MIPS support for doing functions.



○ How to allocate, use (load and store values) and deallocate stack segment memory (for local variables).
(In contrast to global variables in data segment.)




♯ Use of $sp register.




♯ Stack grows with decreasing address - subtract from $sp to allocate, add to $sp to deallocate.



○ What roles jal and jr instructions and the $ra register play.



○ How to do function (in MIPS) in "small-time, unregulated" fashion.



○ Know the inadequacies/limitations (thus "dangers") of doing function (in MIPS) in "small-time, unregulated" fashion.


(There are typically multiple questions, ranging from "simpler, low-value" to "more involved, high-value".)


(May involve reading(interpreting)/debugging/modifying/completing (such as filling in "holes" intentionally made)/... given code.)

● Knowledge related to MIPS32's 3 main instruction formats (Register, Immediate and Jump) and how to put them to use in encoding/decoding MIPS instructions, and MIPS addressing modes (register, immediate, base-displacement/offset, PC-relative and pseudodirect) involved.


► Immediate value in a branch instruction specifies words (not bytes).



○ (WOffset --> words relative to PC)


► How destination address is formed from (or encoded into) the target ("pseudoaddress") of a J-format (especially the jump) instruction.



○ (destination address = upper-4-bits-of-PC | target | 00)

( and whatever mixed-bag items below we get to cover up to and including the last lectures on 04/30/2026 )
( don't have to worry about those not ("time-permittingly") covered )

● "Deeper/quirky/idiosyncratic" things about MIPS.


► What lui instruction does and when it is useful.


► Use of u in instructions is overloaded.



○ Don't sign extend (but zero extend) - e.g.: lbu vs lb.



○ Don't trap overflow (just keep silent about it and continue) - e.g.: addu vs add.



○ Do unsigned compare (not signed compare) - e.g.: sltu vs slt.


► How 16-bit immediate field is extended.



○ Arithmetic instructions (e.g.: addi and addiu) - always sign extend.



○ Load/store instructions (e.g.: lb and lbu) - always sign extend.



○ Logical instructions (e.g.: ori) - always zero extend.



○ Set instructions (e.g.: slti and sltiu) - sign extend if no u (not unsigned version), otherwise zero extend.


► How loaded value (that is sub-word-sized) is extended.



○ Sign extend if no u (not unsigned version such as lb), otherwise (such as lbu) zero extend.

● Conceptual knowledge/understanding of how to do functions (in MIPS) in "big-time, regulated" fashion.


► Concept of and motivation for putting in place some facilitating/regulating function-call convention (set of rules).


► "stack to the rescue" for situations calling for preservation (as functions call each other) of contents of some registers (with registers being the "fast but few" premium resource).



○ Splitting of responsibility leads to caller-saved and callee-saved registers.



○ Invariably, need to save and restore (in order to preserve), which in turn leads to . . .




. . . need to source secondary ("plenty but slow" and less premium) storage as staging area (place to save to and restore from).


► "stack to the rescue" for still other aspects that lead to need to source secondary ("plenty but slow" and less premium) storage.



○ Sizeable (and often addressable) scratch storage (such as temporary local arrays and variables).



○ Additional overhead storage to support less common cases (such as functions involving uncommonly high number of arguments).



○ . . .


► Deal with various "stack to the rescue" storage needs in unified fashion with a one-stop resource widely referred to as stack frame or activation record.



○ "allocate (construct) stack frame" in  function's prolog, "deallocate (tear down) stack frame" in function's epilog.

Other Resources/Tips

■ Online resources



● Reference material.


► Class Recordings page (on Canvas), especially the Key Resource briefs that point to items located elsewhere:



○ Lecture Notes



○ Examples



○ Drills and Challenges



○ Assignments

● You may want to check out sample past exam questions posted on the class homepage (under Other Resources).


► You should not however, expect the questions to be identical in number, kind, topic coverage, etc.


► Notion very ill-advised to harbor:
     I take it I will do well in current exams if I can do the sample past exam questions well.


► You should not have to worry about questions being written on topics we have not (or not yet) covered; some such questions may appear as sample past questions because the associated topics were appropriate at that time.


■ You may want to review Exam1 and Exam 2.
■ Somewhat indirect question(s) may be written that test(s) your understanding of and your ability to apply the concepts covered/discussed during the semester, individually (involving a single concept) or in combination (involving multiple concepts).
■ If you are eligible and intend to use extended time accommodation:

● Do the following:


► Follow proper procedure to request taking the exam at the ATSD.



○You typically need to do the request at least a certain number of (non-weekend?) hours in advance.



○The exam date of your request should be the same as the (regularly) scheduled date of the exam.



○The exam start time of your request should be closest to the (regularly) scheduled start time of the exam.