Used to access a memory locationrelative to the current top of the stack.
; Decrement the stack pointer by 8 (allocate 8 bytes on the stack)sub $sp, 8; Move the value at the memory location (sp + 4) into the eax registermov 4($sp), %eax
Frame Pointer
Maintains a reference point within the current Stack Frame
At the beginning of a function (prologue), the Frame Pointer is typically set to the current value of the Stack Pointer, establishing the base of the current stack frame
Throughout the function: The FP remains relatively unchanged, offering a stable reference point
Control & Status Registers (CSRs)
There are multiple such registers in the CPU, the main purpose is storing information about the current state of the processor or device
CSRs are typically used to control various aspects of the processor’s operation, such as interrupt handling, memory management, and power management etc
This means that the register can be accessed using the same Instruction and addressing modes as memory.
Often used to control hardware devices, such as IO Device (Like the UART in XV6) and memory controllers
XV6-RISCV Memory Mapped Registers
memlayout.h
// XV6-RISCV Kernel Codes, memlayout.h// Physical memory layout// qemu -machine virt is set up like this,// based on qemu's hw/riscv/virt.c://// 00001000 -- boot ROM, provided by qemu// 02000000 -- CLINT// 0C000000 -- PLIC// 10000000 -- uart0 // 10001000 -- virtio disk // 80000000 -- boot ROM jumps here in machine mode// -kernel loads the kernel here// unused RAM after 80000000.// the kernel uses physical memory thus:// 80000000 -- entry.S, then kernel text and data// end -- start of kernel page allocation area// PHYSTOP -- end RAM used by the kernel// qemu puts UART registers here in physical memory.#define UART0 0x10000000L#define UART0_IRQ 10