CS 315-01 Lecture/Lab — Fall 2025¶
Meeting Summary
- Date: Sep 02, 2025
- Time: 08:10 AM Pacific (US and Canada)
- Meeting ID: 886 4953 2573
Quick Recap¶
The session reviewed Project 1 requirements and implementation details: Makefiles, separate compilation, and C programming concepts (structs, printf). Greg emphasized code quality, formatting, documentation, and adherence to team standards. The meeting concluded with an introduction to assembly programming, including RISC‑V (“RISC 5”) instructions, and announcements about upcoming lab activities and grading.
Next Steps¶
- Complete Project 1 by tonight’s deadline.
- Implement the
num_infoandnum_conversionexecutables in the Project 1 repository. - Write custom conversion functions; do not use
printf("%d"),printf("%x"),scanf, oratoifor required conversions. Useprintf("%s")to print converted string values. - Always output results in fixed order from low base to high base, regardless of command-line option order.
- Use separate compilation:
- Factor shared helpers into
num_helpers.cwith a matchingnum_helpers.h. - Avoid putting logic in
main; break code into smaller functions. - Create and update a Makefile:
- Produce binaries for
num_infoandnum_conversion. - Add targets for new object files and header dependencies.
- Use a tab character for each rule’s action line.
- Follow code quality standards:
- Consistent formatting, spacing, and commenting.
- Use spaces (not tabs) for indentation in source code.
- Prefer
snake_caseovercamelCaseto match C library conventions.
Summary¶
Project 1: Compilation Guidelines¶
Greg outlined expectations for Project 1:
- Use Makefiles and separate compilation; build num_info and num_conversion.
- printf("%s") is allowed for outputting converted strings; avoid standard library conversion helpers for the assignment’s required conversions.
- Output order is fixed (low base to high base), regardless of CLI option order.
- Hexadecimal digits may be uppercase or lowercase.
- Helper functions used in num_info may be reused in num_conversion.
C Code Refactoring and Compilation¶
- Refactor common code into separate
.cfiles with corresponding.hheaders. - Place function prototypes in headers to provide type signatures.
- Compile and link multiple C files with GCC; structure the Makefile to track object files and header dependencies so changes trigger correct recompilation.
Code Quality and Consistency Standards¶
- Maintain consistent formatting and syntax for readability and maintainability.
- Adhere to team standards used in open-source and professional codebases.
- Prefer spaces for indentation to avoid tab/space alignment issues across editors and platforms.
C Code Quality and Structs¶
- Prefer
snake_caseto align with C libraries and large codebases (e.g., the Linux kernel). - Break complex logic into smaller functions; keep
mainminimal. - Use structs to pass related data between functions; use pointers to structs and
->to access fields where appropriate.
C Programming Best Practices¶
- It is acceptable to exit from within helper functions on fatal validation errors rather than unwinding back to
main. - Maintain strong documentation and repository organization.
- Follow the provided echo/config structure.
- Office hours are available for assistance.
Git Practices and C Structs¶
- Keep repositories clean: do not commit
.ofiles or executables; usegit rmto remove tracked binaries and artifacts. - For struct definitions:
- Prefer explicit
structusage for clarity. - Use
typedefjudiciously (appropriate for complex types) but be aware it can obscure pointer semantics.
Project 1 Grading and Lab Updates¶
- Combine C files as needed; prefer stack allocation over
malloc. Dynamic allocation is discouraged to avoid memory issues in this course. - Grading for Project 1 will be offline (not interactive); feedback will be provided separately.
- Tomorrow’s lab will be interactive with tasks focused on assembly; students must bring laptops and submit work by the end of the lab period.
Assembly Language Programming Basics¶
- Demonstrated a simple C program alongside its assembly equivalent.
- Covered labels, instructions, registers, and directives.
- Showed how to compile and run assembly with GCC and explained the relationship among assembly, machine code, and the processor.
- Introduced return values in assembly and how they differ from C.
RISC‑V Assembly Language Overview¶
- Reviewed RISC‑V (“RISC 5”) instruction structure and strict formatting.
- Explained register usage, including the zero register, and the difference between
ADDIandADD. - Discussed register naming conventions and 32-bit vs. 64-bit operation:
- The machine uses 64-bit registers, but 32-bit values can be manipulated within them.
- Students should review the RISC guide before the next lab, where they will begin writing assembly code.