Garbage Collection System (GCS)

Thalamus - Input Filtering and Sensory Gatekeeping

Overview

The Garbage Collection System (GCS) filters input to only accept valid printable ASCII characters. It's mapped to the Thalamus in Chapp-E's brain architecture, which acts as a sensory relay station and gatekeeper.

✅ BRAIN MAPPING: The GCS corresponds to the Thalamus, which in the human brain filters and routes sensory information, acting as a gatekeeper that determines what information reaches the cortex.

Functionality

Input Filtering

The GCS filters input to only accept:

  • Printable ASCII: Characters from 0x20 (space) to 0x7E (~)
  • Valid Range: 0x20-0x7E (32-126 decimal)
  • Rejects: Control characters, extended ASCII, invalid bytes

Purpose

The GCS prevents invalid input from causing:

  • System crashes
  • Unexpected behavior
  • Buffer overflows
  • Memory corruption

API Reference

gcs_is_valid_char

Validates a single character.

; Check if character is valid
; Input: AL = character to validate
; Output: CF = 1 if valid, CF = 0 if invalid

mov al, 'A'
call gcs_is_valid_char
jc .valid_char    ; Character is valid
; Character is invalid

gcs_filter_string

Filters an entire string, removing invalid characters.

; Filter string
; Input: SI = source string pointer
;        DI = destination buffer pointer
;        CX = maximum length
; Output: Filtered string in destination buffer

mov si, input_string
mov di, filtered_buffer
mov cx, 128
call gcs_filter_string

gcs_filter_char_buffer

Filters a character buffer in-place.

; Filter buffer in-place
; Input: DI = buffer pointer
;        CX = buffer length
; Output: Buffer modified (invalid chars removed/ignored)

mov di, input_buffer
mov cx, 128
call gcs_filter_char_buffer

Valid Character Range

The GCS accepts the following character ranges:

Range Characters Description
0x20 Space Whitespace
0x21-0x2F ! " # $ % & ' ( ) * + , - . / Punctuation
0x30-0x39 0-9 Digits
0x3A-0x40 : ; < = > ? @ Punctuation
0x41-0x5A A-Z Uppercase letters
0x5B-0x60 [ \ ] ^ _ ` Punctuation
0x61-0x7A a-z Lowercase letters
0x7B-0x7E { | } ~ Punctuation

Brain Architecture

Thalamus Mapping

In the human brain, the Thalamus:

  • Filters sensory information - Like GCS filtering input characters
  • Acts as a gatekeeper - Like GCS preventing invalid input
  • Routes information to cortex - Like GCS routing valid input to FSM
  • Thalamocortical loops - Like GCS coordinating with other systems

System ID

The GCS is registered with Brain Controller as:

  • System ID: SYS_ID_GCS (0x03)
  • Brain Region: Thalamus (Diencephalon)

Integration

Input Flow

The GCS sits in the input pipeline:

I/O System → GCS (filter) → FSM (state) → Processing

Shell Integration

The shell uses GCS to:

  • Filter keyboard input before processing
  • Prevent invalid characters from entering the system
  • Ensure only printable ASCII reaches the FSM

Brain Controller Integration

The GCS communicates through the Brain Controller:

  • Receives input messages from I/O System
  • Filters and forwards valid input to FSM
  • Rejects invalid input silently

File Locations

  • 16-bit Implementation: neural/diencephalon/thalamus/gcs/gcs.asm
  • Brain Region: Thalamus (Diencephalon)

Related Documentation