CS 315-02 Lecture/Lab — Meeting Summary (Fall 2025)¶
Date: September 24, 2025
Time: 06:33 PM Pacific (US and Canada)
Meeting ID: 868 6589 0521
Quick Recap¶
- The session covered code understanding and grading practices, responsible use of AI tools, and a notable bug in Project 3 that may appear on the exam.
- The team worked through string implementation challenges and strategies for manipulating string indices.
- The course progression from C programming to RISC-V assembly and onward to RISC-V machine code was outlined.
- The lecture included detailed explanations of bitwise operators, shift operations, and rounding behavior for signed and unsigned integers.
- Next session: begin analyzing RISC-V machine instruction words and building a basic emulator.
Next Steps¶
- Students should ensure they fully understand their code for interactive grading.
- Students may use AI as a learning aid but must be able to explain any submitted code.
- Prepare for Project 4 interactive grading sessions.
- Study bit manipulation and bitwise operators for the upcoming RISC-V machine code emulator project.
- Understand the difference between logical and arithmetic right shifts for the emulator implementation.
Detailed Summary¶
Code Understanding and Grading¶
- Greg emphasized that students must be able to explain their code during interactive grading, even when AI tools (e.g., ChatGPT) are used as study aids.
- A student-identified bug in Project 3 was discussed, including why it passed tests despite being incorrect; the bug may appear on the exam.
- The rotation schedule for interactive grading was clarified.
- Grading consistency is maintained through coordination between Greg and the TAs.
Recursive String Implementation Challenges¶
- A recursive string implementation was analyzed that locates the null terminator by referencing a previous string in memory—a fragile, “hacky” approach.
- The challenge: design a legitimate base case and correctly null-terminate the destination string without relying on undefined memory relationships.
String Index Manipulation Approach¶
- Greg and Treyos discussed using source and destination indices to minimize invasive operations.
- Proposed strategy: initialize the source index to 0 and the destination index to source_length − 1.
- Consider detecting an alternating pattern in the source as a base case.
- Alternative idea: decrement the source index down to 0 to enable a swap at index 0 without checking for the null terminator.
RISC-V Machine Code Progression¶
- The course has completed C programming and RISC-V assembly modules and is transitioning to RISC-V machine code.
- Objective: build a RISC-V emulator in C that decodes and executes machine instructions.
- The course provides three execution pathways for assembly programs:
- Assembler/Compiler
- Emulator
- Custom-built processor
Bitwise Operators in C and RISC-V¶
- Reviewed bitwise operators: AND, OR, NOT, left shift, right shift.
- Distinguished bitwise operators from relational operators.
- Clarified binary terminology: false/true, unset/set, low/high (digital design equivalents).
Binary to Decimal Conversion¶
- Explained conversion using bit positions and powers of two.
- Demonstrated with 8-bit examples, then extended to 32-bit values relevant to RISC-V instruction words.
- Emphasized understanding bit positions and decomposing values into bytes.
Bitwise Operators: Demonstration¶
- Demonstrated AND, OR, and NOT at the single-bit level and extended to 8-, 16-, 32-, and 64-bit values by applying operations bit by bit.
- Clarified inclusive vs. exclusive OR behavior.
- Invited questions; stressed that the process is identical regardless of bit width.
Shift Operations in Assembly¶
- Focused on logical shifts:
- Logical left shift: shifts bits left, fills with zeros, drops high-order bits.
- Logical right shift: shifts bits right, fills with zeros, drops low-order bits.
- Used 0101 0011 as a working example.
Logical vs. Arithmetic Shifts and Division¶
- Logical left/right shifts correspond to multiplication/division by powers of two (for non-overflowing values).
- Introduced arithmetic right shift to preserve sign during division of signed integers.
- Reviewed two’s complement conversion for negative values.
- Noted rounding behavior:
- Arithmetic right shift on negative values rounds toward negative infinity (effectively “rounds up” in magnitude).
- Positive values round down toward zero under right shifts.
Shift Operations in C¶
- C’s right shift behavior depends on the operand type:
- Unsigned types: logical right shift.
- Signed types: implementation-defined for negatives but typically arithmetic right shift on modern compilers/architectures.
- Examples were shown in binary and hexadecimal, including operations on +54 and −54.
- Assembly uses distinct instructions for logical vs. arithmetic shifts.
Integer Rounding and Emulator Basics¶
- Explored rounding differences for signed vs. unsigned right shifts:
- Unsigned right shifts round down.
- Signed right shifts for negative values effectively round toward negative infinity.
- Next session will begin analysis of RISC-V instruction words and the construction of a basic emulator.
- Lab 6 is due Tuesday night.