Buffer System
Command Input Buffering and State Management
Overview
The Buffer System handles command input buffering and state management. It prevents the prompt from repeating after each character and manages the command input lifecycle.
Memory Layout
The Buffer System uses memory at address 0x0500:
| Address | Size | Description |
|---|---|---|
0x0500 |
2 bytes | Buffer position (current input length) |
0x0502 |
1 byte | Buffer state (0 = ready, 1 = typing) |
0x0503 |
128 bytes | Buffer data (command storage) |
Buffer Constants
| Constant | Value | Description |
|---|---|---|
BUFFER_SIZE |
128 |
Maximum buffer size (reduced to fit in boot sector) |
API Reference
buffer_init
Initializes the buffer system.
; Initialize buffer
call buffer_init
; Sets:
; - Position to 0
; - State to 0 (ready)
; - Clears buffer data
buffer_start_command
Starts a new command (resets buffer, sets state to typing).
; Start new command
call buffer_start_command
; Sets:
; - Position to 0
; - State to 1 (typing)
; - Clears buffer
Integration
FSM Integration
The Buffer System works closely with the FSM:
- Buffer state tracks typing status
- FSM manages overall input state
- Both coordinate to prevent prompt repetition
Shell Integration
The shell uses the Buffer System to:
- Accumulate user input
- Manage command input lifecycle
- Prevent prompt from repeating
File Locations
- 16-bit Implementation:
neural/networks/consciousness/cerebral_cortex/frontal/prefrontal/working_memory/buffer.asm - Brain Region: Prefrontal Cortex (Working Memory)
Related Documentation
- FSM System - State management
- Shell System - Uses buffer for input
- Memory Systems - Working memory