CO Lab Manual
Course Page
  • Course Information
    • Welcome
    • Introduction
    • Your Contributions
    • Lab Sessions and Etiquette
    • Team Setup
    • Assumed Prior Knowledge
  • Setup Guides
    • GitHub Repository Setup
    • Technical Setup
      • Windows
      • Linux
      • macOS
    • GitHub SSH Setup
    • Framework Setup
  • Reference Documentation
    • Introduction to the Documentation
    • A Brief History Lesson
    • Syntax (Intel vs. AT&T)
      • Section Exercises
    • Memory
      • Memory Management
      • Section Exercises
    • Registers
      • Section Exercises
    • Instructions
    • Subroutines
      • Calling Subroutines
      • Writing Subroutines
      • Section Exercises
    • Input/Output
      • Printing to the Terminal
      • Reading from the Terminal
      • Section Exercises
    • Programming Constructs
    • Assembler Directives
    • C/C++ vs Assembly
    • Building and Running Programs
    • Address Sanitization
    • A0: A Running Example
  • Assignments
    • Introduction to the Assignments
    • Mandatory Assignments
      • A1: Subroutines and I/O
      • A2: Recursion
    • Extra Assignments
      • A3-a: Fibonacci Calculator
      • A3-b: Fibonacci REPL
      • A4: Diff
      • A5: Printf
      • A6: HPC
      • A7: Bitmap
      • A8: Game
  • Appendix
    • Acknowledgments
    • Rules and Regulations
    • Frequently Asked Questions
    • How to use a Debugger
Powered by GitBook
On this page
  1. Reference Documentation

Memory

PreviousSection ExercisesNextMemory Management

Last updated 4 months ago

The memory of a running process is typically grouped into sections as shown below:

  • The Text segment holds the program instructions as well as any read-only data (e.g., strings).

  • The Data segment holds initialized data, so initialized global and static variables. Contrary to the text segment, this segment is not read-only, as the contents may be changed during execution.

  • The BSS segment holds uninitialized data. The segment is initialized to zero before the program starts executing. It typically holds global or static variables that are either uninitialized or initialized to zero.

  • The Heap memory is dynamically allocated program memory. It is managed through the brk and sbrk system calls, or, more commonly, through the suite of malloc library functions. Memory in this segment can be allocated and released at runtime. You will need to work with heap memory in .

  • The Stack is a LIFO structure, growing from higher to lower addresses. It is used, among others, for local variables, return addresses, and temporary storage. The rsp register keeps track of the top of the stack, while the rbp register denotes the bottom of the current stack frame. You will actively work with the stack starting from .

Assignment 3-b
Assignment
1