Skip to content

Meeting Summary: CS 631-02 Systems Foundations

  • Date: Mar 03, 2026
  • Time: 02:48 PM Pacific Time (US and Canada)
  • Meeting ID: 882 2309 0019

Quick Recap

The session focused on assembly language concepts in the RISC-V architecture, particularly memory management and function calls. Greg covered: - Memory instructions, stack operations, and control structures (if-else and loops) - Array handling in assembly with both simple and complex function examples - A modified version of PICO Code (a mini cloud-code implementation) ported to Beagle machines - The importance of following ABI calling conventions and preserving registers across function calls

The session included live coding and discussions on register usage, stack allocation, and return addresses. Greg emphasized proper stack management and register preservation for writing efficient assembly code.

Next Steps

  • Greg: Post the modified PICO Code implementation so students can download and use it on Beagle machines.
  • Greg: Consider adding support for claw.md (or similar) to PICO Code so students can use quad.md or equivalent files.
  • Greg: Make a release of the latest PICO Code, post it to Campus Wire, and provide binaries for popular platforms.
  • Greg: Add /help (slash help) and Control+Enter functionality to PICO Code.
  • Greg: Add support for cloud.md (or equivalent) to PICO Code for use at the root of a project/Git repo.
  • Greg: Share complete notes for the full functions material before Thursday’s session.

Detailed Summary

RISC-V Memory and Function Calls

Greg outlined the day’s agenda: memory, stack operations, memory instructions, control structures, and preparing for full function calls by Thursday. He discussed porting a Rust implementation of PICO Code to the Beagle (which currently requires an API key) and plans to improve usability.

He clarified that “Lab 3” has been renamed to “Lab 3 New,” explaining the decision to create a new repository rather than updating the base template. He reviewed key RISC-V memory concepts: - Memory as an array of bytes - Byte addressing and its implications for loads/stores and alignment

Memory Addressing in Programming

Greg explained word addresses and their importance for load/store operations. He covered: - Variants of load and store instructions by data size (byte, halfword, word, doubleword) and signed vs. unsigned - Address calculation with base addresses and offsets - A C example illustrating address computation for array elements

Assembly Language Programming Basics

Greg discussed how data is loaded into registers and manipulated in memory. Key points: - Using offsets to access array/struct fields without modifying the base address - Avoiding unintended pointer modification when passing pointers to functions - The role of base+offset addressing for clean, maintainable assembly

Assembly Array Access Techniques

Greg demonstrated array access patterns in assembly: - Passing individual elements vs. passing entire arrays as pointers - Converting Rust array references to pointers and compiling down to C-style arrays - Two indexing strategies: - Explicit multiply-and-add for general element sizes - Using left shifts for power-of-two element sizes for efficiency

Rust Assembly Code and Memory Layout

Using a Rust function that sums an array, Greg discussed: - Translating loops and control flow into assembly - Starting with known patterns and filling in details during implementation - The OS memory layout: code, data, heap, and stack segments - Stack allocation for local variables and use of the stack pointer (sp) to manage memory

Assembly Language Register Management

Greg detailed stack usage for data allocation and register preservation under the ABI calling convention: - Saving/restoring caller- and callee-saved registers (e.g., t0, t1, ra) - Using sd to save ra due to its 8-byte size on RV64 - Branch instructions and the need for unsigned variants for certain comparisons

After a brief 10-minute break, Greg continued with more examples and noted he would share the PICO Code resources.

PICO Code: Assembly Function Basics

Greg demonstrated writing assembly functions in PICO Code that call each other, covering: - Calling conventions: argument registers, return registers, and stack space - Preserving required registers when calling other functions - Examples of functions that return values - A new PICO Code feature for writing plans to Markdown files

Emphasis remained on disciplined stack and register management to ensure correctness and performance.