Overview

The ASM Browser is a pure assembly-language browser engine that runs at the kernel level, designed to serve and execute Node.js applications. It provides a machine-level interface for web-like functionality without requiring a traditional web browser.

Design Principles

  • Pure Assembly: All core functionality in x86_64 assembly
  • Kernel-Level: Runs in kernel space with direct hardware access
  • Node.js Integration: Serves and executes Node.js applications
  • Minimal Dependencies: No external browser engine (no Chromium, no WebKit)
  • Native Rendering: Direct framebuffer rendering, no HTML/CSS parsing

Architecture Components

1. Browser Engine Core

File: kernel/browser/engine.asm

Purpose: Core browser engine that manages rendering, execution, and resource loading.

Components:

  • Document Object Model (DOM) - Simplified
    • Tree structure for UI elements
    • Element properties (position, size, style)
    • Event handling
  • Rendering Engine
    • Direct framebuffer rendering
    • Rectangle, line, text rendering
    • Image rendering (PNG, ICO support)
    • Font rendering (bitmap fonts)
  • JavaScript Runtime Bridge
    • V8 engine integration
    • Node.js module loading
    • API bridge to kernel services
  • Resource Loader
    • File system access
    • Network requests (future)
    • Caching mechanism

2. Node.js Integration Layer

File: kernel/browser/nodejs.asm

Purpose: Bridge between ASM browser and Node.js runtime.

Components:

  • Node.js Process Management
    • Spawn Node.js processes
    • IPC communication
    • Process lifecycle management
  • Module Loading
    • Load Node.js modules from filesystem
    • Resolve module dependencies
    • Execute module code
  • API Bridge
    • Kernel syscalls → Node.js APIs
    • Node.js requests → Kernel services
    • Event system integration

3. Rendering System

File: kernel/browser/render.asm

Purpose: Low-level rendering primitives for UI elements.

Components:

  • Framebuffer Management
    • Direct memory access to VESA framebuffer
    • Double buffering
    • Dirty region tracking
  • Graphics Primitives
    • Rectangle fill/draw
    • Line drawing (Bresenham)
    • Circle/ellipse drawing
    • Text rendering (bitmap fonts)
  • Image Rendering
    • PNG decoding (simplified)
    • ICO decoding
    • Image scaling
  • Compositing
    • Alpha blending
    • Layer management
    • Clipping regions

File Structure

kernel/browser/
├── engine.asm          # Core browser engine
├── nodejs.asm         # Node.js integration
├── render.asm          # Rendering system
├── events.asm          # Event system
├── network.asm         # Network stack
├── storage.asm        # Storage system
├── dom.asm            # DOM implementation
├── fonts.asm          # Font rendering
├── images.asm         # Image decoding
└── api.asm            # Browser APIs

API Design

Browser Engine API

; Initialize browser engine
browser_init:
    ; Initialize all subsystems
    ; Returns: success/error code

; Load Node.js application
browser_load_app path, callback:
    ; Load Node.js app from path
    ; Execute and register callback

; Render frame
browser_render:
    ; Render current DOM to framebuffer
    ; Handle dirty regions

; Handle input
browser_handle_input event:
    ; Process input event
    ; Distribute to handlers

Node.js Bridge API

; Spawn Node.js process
nodejs_spawn path, args, env:
    ; Create Node.js process
    ; Returns: process ID

; Execute Node.js code
nodejs_execute code, context:
    ; Execute JavaScript code
    ; Returns: result

; Load Node.js module
nodejs_load_module path:
    ; Load and execute module
    ; Returns: module exports

Integration with Existing Systems

  • Kernel Integration:
    • Uses existing VESA framebuffer driver
    • Uses existing filesystem driver
    • Uses existing process management
    • Uses existing syscall interface
  • Node.js Integration:
    • Loads Node.js from /usr/lib/nodejs/bin/node
    • Uses existing IPC mechanisms
    • Integrates with window manager
    • Uses existing event system
  • GUI System Integration:
    • Works with fwcompositor
    • Integrates with window manager
    • Uses existing input system
    • Shares rendering primitives

Implementation Phases

  1. Phase 1: Core Engine
    • Basic DOM structure
    • Simple rendering (rectangles, text)
    • Event system foundation
    • Node.js process spawning
  2. Phase 2: Rendering
    • Complete graphics primitives
    • Image rendering
    • Font rendering
    • Compositing
  3. Phase 3: Node.js Integration
    • Module loading
    • API bridge
    • Event integration
    • IPC communication
  4. Phase 4: Network & Storage
    • HTTP client
    • Resource loading
    • Local storage
    • Session storage
  5. Phase 5: Complete Browser
    • Full DOM implementation
    • Complete API set
    • Performance optimization
    • Testing and debugging