Skip to content

Meeting Summary: CS 631-02 Systems Foundations

  • Date: Feb 17, 2026
  • Time: 02:43 PM Pacific (US and Canada)
  • Meeting ID: 882 2309 0019

Quick Recap

The session focused on binary representation, bitwise operations, and two’s complement, framed around the development of a teaching language called NT-Lang. Greg covered:

  • Base conversions, sign extension, and bitwise operators in C and Rust
  • String-to-integer and integer-to-string conversion strategies
  • Handling signed values and performing arithmetic shifts
  • Practical examples of bitwise operations and their relevance to computer architecture
  • Differences between Rust’s strict type system and C’s behavior
  • Preview of upcoming topics: expression evaluation and extending NT-Lang to support variables and assignments

Next Steps

  • All students:
  • Submit Lab 2 by tonight and verify it runs on the Beagle boards (“beagles”)
  • Complete the CampusWire form with GitHub IDs/usernames
  • Attend Thursday’s class for discussion of expression evaluation, extended grammar syntax, and environment assignments for Project 1
  • Greg:
  • Send reminders to students missing GitHub IDs by tomorrow morning
  • Release Project 1 specification this evening
  • Release the full NT-Lang specification

Detailed Summary

NT-Lang and Women in Tech Hackathon

  • Announcement: Women in Tech hackathon focused on environmental tech.
  • NT-Lang roadmap:
  • Support for base conversions, variable assignment, and a simple CLI
  • Extension to include basic constructs such as variables and print functions
  • Rationale: Mastery of binary representation and two’s complement is foundational for upcoming discussions on RISC-V assembly and machine code.

Binary Values and Data Conversion

  • Bit widths define value ranges, especially for signed integers, and map directly to hardware.
  • Conversion approach:
  • Use division/modulus to convert decimal to binary
  • Normalize through a common form (UINT32) in NT-Lang before converting to other bases (e.g., hexadecimal)
  • Hexadecimal is emphasized for its density and straightforward mapping to binary, making it practical in architecture work.

Two’s Complement: Concepts and Benefits

  • Contrast with sign magnitude:
  • Sign magnitude suffers from a redundant representation of zero and complicates addition.
  • Two’s complement advantages:
  • One additional negative value than positive
  • Simple conversion via bit inversion and adding one
  • Enables grade-school-style addition to work uniformly for signed and unsigned arithmetic in hardware
  • Efficient sign extension when increasing bit width
  • NT-Lang will allow displaying values as either signed or unsigned for clarity.

Bitwise Operators and Binary Manipulation

  • Core operators: AND, OR, XOR, NOT
  • Use cases: masking, constructing/deconstructing values, comparisons
  • Shifts are an exception to single-bit-at-a-time manipulation:
  • Affect the entire value
  • Logical shifts treat values as unsigned

Shift Operations and System Limits

  • Left shift by 1 ≈ multiply by 2; right shift by 1 ≈ divide by 2
  • Arithmetic vs. logical shifts:
  • Arithmetic shifts preserve sign; logical shifts do not
  • Historical note: Compilers often optimize division by powers of two into shifts
  • NT-Lang introduces an explicit arithmetic shift right operator (unlike C, which has only << and >>)
  • 32-bit system limitation: maximum addressable memory is 4 GB, impacting very large file handling

Custom Conversion Algorithm Development

  • Purpose: Build conversion algorithms without libraries to gain hands-on experience in C and Rust
  • Generalized strategies:
  • Robust string-to-integer parsing (accounting for multi-byte Unicode)
  • Integer-to-string conversion via remainder accumulation
  • Width argument to interpret values at smaller bit widths
  • Sign extension via masking
  • Use of C’s stdint.h for fixed-size integer types is encouraged.

Bitwise vs. Logical Operators in C and Rust

  • Importance of operator precedence and type coercion in both languages
  • Sign extension techniques demonstrated in C and Rust
  • Rust advantages:
  • Strict type checking
  • Safer error handling via Option and related types
  • Preparation for next session: evaluation of extended grammar and running NT-Lang scripts in Project 1

Upcoming Topics

  • Expression evaluation in NT-Lang
  • Extended grammar syntax
  • Environment and assignment semantics for Project 1
  • Practical scripting and execution flow in NT-Lang