Skip to main content
  1. Projects/

hackdavis-2025

·1454 words·7 mins
Jake Roggenbuck
Author
Jake Roggenbuck
Working at Capital One as a SWE Intern as well as Programming Language Research during the school year.

๐Ÿš€ Assemblr - HackDavis 2025 #

Assemblr

A revolutionary web-based IDE with a custom assembly-like language for robotics programming!

Built for HackDavis
Made with Next.js
Powered by Rust
TypeScript
Tailwind CSS

๐ŸŒŸ Overview #

Assemblr is a cutting-edge development environment that combines the power of modern web technologies with a custom-built compiler for robotics programming. Whether you’re a robotics enthusiast, student, or professional developer, our platform provides an intuitive interface for writing and executing robot control code.

Key Features #

  • ๐ŸŽฏ Real-time Compilation: Instant feedback on your code
  • ๐Ÿ”„ Live Preview: See your robot’s movements in a simulated environment
  • ๐Ÿ“ Intelligent Code Editor: Syntax highlighting and autocompletion
  • ๐Ÿงช Debugging Tools: Step-through execution and variable inspection
  • ๐Ÿ“ฑ Responsive Design: Works seamlessly on desktop and mobile
  • ๐ŸŒ Cloud Integration: Save and share your projects

๐Ÿ’ก Pro Tips & Tricks #

Code Organization #

  • Use meaningful labels and variable names
  • Group related code into functions
  • Add comments to explain complex logic
  • Keep functions small and focused

Performance Optimization #

  • Use variables for repeated values
  • Minimize wait times between movements
  • Optimize movement patterns
  • Use loops for repetitive actions

Debugging Techniques #

  • Add strategic mov wait commands to slow down execution
  • Use variables to track state
  • Print debug information to the terminal
  • Test functions in isolation

๐Ÿ“Š Architecture #

graph TD
    A[Frontend - Next.js] -->|HTTP POST| B[Backend Server - Rust]
    B -->|Library Call| C[Compiler - Rust]
    C -->|IR| D[Code Generation]
    C -->|C++| E[Arduino Code]
    
    subgraph Frontend
    A -->|Monaco Editor| F[Code Editor]
    A -->|XTerm.js| G[Terminal]
    A -->|Three.js| H[3D Preview]
    end
    
    subgraph Backend
    B -->|/api/compile| I[IR Compilation]
    B -->|/api/compile/arduino| J[Arduino Compilation]
    B -->|/api/simulate| K[Robot Simulation]
    end

๐Ÿ› ๏ธ Tech Stack #

Frontend Powerhouse #

  • โš›๏ธ Next.js 15 - React framework for production
  • ๐Ÿ“ TypeScript - Type-safe development
  • ๐ŸŽจ Tailwind CSS - Utility-first styling
  • ๐Ÿ“Š Monaco Editor - VS Code-like editing experience
  • ๐Ÿ–ฅ๏ธ XTerm.js - Terminal emulation
  • ๐ŸŽฏ React Icons - Beautiful iconography
  • ๐ŸŽฎ Three.js - 3D robot visualization
  • ๐Ÿ“ฑ Responsive Design - Mobile-first approach

Robust Backend #

  • ๐Ÿฆ€ Rust - Systems programming language
  • ๐Ÿ”ง Custom Compiler - Purpose-built for robotics
  • ๐ŸŒ Unicode Support - International character compatibility
  • ๐Ÿ“ฆ Module System - Organized code structure
  • ๐Ÿ”„ Async Runtime - High-performance concurrency
  • ๐Ÿงช Unit Testing - Comprehensive test coverage

๐Ÿ“ก API Documentation #

Compilation Endpoints #

1. Compile to IR #

POST /api/compile
Content-Type: application/json

{
    "code": "your assembly code here",
    "options": {
        "optimize": true,
        "debug": false
    }
}

Response:

{
    "output": {
        "ir": "compiled IR in JSON format",
        "metadata": {
            "executionTime": "0.123s",
            "optimizationLevel": "high",
            "warnings": []
        }
    }
}

Error Response:

{
    "error": {
        "message": "error message",
        "line": 42,
        "column": 10,
        "suggestion": "Did you mean 'forward' instead of 'foward'?"
    }
}

2. Compile to Arduino #

POST /api/compile/arduino
Content-Type: application/json

{
    "code": "your assembly code here",
    "board": "arduino_uno",
    "options": {
        "includeLibraries": ["Servo.h", "Wire.h"]
    }
}

Response:

{
    "output": {
        "code": "generated Arduino C++ code",
        "dependencies": ["Servo.h", "Wire.h"],
        "memoryUsage": {
            "flash": "1234 bytes",
            "sram": "567 bytes"
        }
    }
}

Assembly Language Syntax #

Basic Syntax #

# Comments start with #
# Labels end with :
# Instructions are lowercase
# Values can be decimal or hex (0x prefix)

# Example program - Simple Square Movement
square:
    mov forward, 10     # Move forward 10 units
    mov direction, 1    # Turn left 90 degrees
    mov forward, 10     # Move forward 10 units
    mov direction, 1    # Turn left 90 degrees
    mov forward, 10     # Move forward 10 units
    mov direction, 1    # Turn left 90 degrees
    mov forward, 10     # Move forward 10 units
    ret                # Return to caller

main:
    jal square         # Execute square movement
    mov wait, 1        # Wait 1 second
    jal square         # Repeat square movement

Advanced Features #

# Example: Complex Pattern with Variables and Loops
var speed = 5
var pattern_size = 4
var angle = 45

# Function to draw a pattern
draw_pattern:
    param size
    param angle
    var i = 0
    
    pattern_loop:
        mov forward, size
        mov direction, angle
        add i, 1
        blt i, pattern_size, pattern_loop
    ret

main:
    mov speed, speed           # Set movement speed
    jal draw_pattern           # Draw first pattern
    mov wait, 0.5             # Pause
    mov direction, 180        # Turn around
    jal draw_pattern           # Draw second pattern

More Examples #

1. Spiral Pattern #
# Draw a spiral pattern
spiral:
    var radius = 1
    var angle = 0
    
    spiral_loop:
        mov forward, radius
        mov direction, 1
        add radius, 1
        add angle, 1
        blt angle, 36, spiral_loop
    ret

main:
    jal spiral
2. Obstacle Avoidance #
# Simple obstacle avoidance routine
avoid_obstacle:
    mov backward, 5           # Back up
    mov direction, 1          # Turn left
    mov forward, 10           # Move forward
    mov direction, 2          # Turn right
    mov forward, 10           # Move forward
    ret

main:
    var obstacle_detected = 0
    
    loop:
        mov forward, 1
        # Simulate obstacle detection
        add obstacle_detected, 1
        beq obstacle_detected, 5, avoid
        j loop
    
    avoid:
        jal avoid_obstacle
        mov obstacle_detected, 0
        j loop
3. Zigzag Pattern #
# Create a zigzag pattern
zigzag:
    var steps = 5
    var i = 0
    
    zigzag_loop:
        mov forward, 10
        mov direction, 1
        mov forward, 10
        mov direction, 2
        add i, 1
        blt i, steps, zigzag_loop
    ret

main:
    jal zigzag

Available Commands #

CommandDescriptionExampleNotes
mov direction, NSet movement directionmov direction, 10=straight, 1=left, 2=right
mov forward, NMove forward N unitsmov forward, 4Units are in centimeters
mov backward, NMove backward N unitsmov backward, 2Negative values not allowed
mov wait, NWait N secondsmov wait, 1Supports decimal values
jal labelJump to labeljal circleSupports nested calls
retReturn from subroutineretMust be in function
var name = valueDeclare variablevar speed = 5Global scope
param nameFunction parameterparam distanceMust be in function
add var, valueAdd to variableadd counter, 1Supports variables
sub var, valueSubtract from variablesub counter, 1Supports variables
blt var, value, labelBranch if less thanblt i, 10, loopSupports variables
beq var, value, labelBranch if equalbeq x, 0, endSupports variables
j labelUnconditional jumpj loopDirect jump
print varPrint variable valueprint counterDebugging tool

๐Ÿš€ Getting Started #

Prerequisites #

  • Node.js 18+
  • Rust and Cargo
  • Git
  • Arduino IDE (optional, for hardware deployment)

Quick Start #

  1. Clone & Install

    git clone https://github.com/yourusername/hackdavis-2025.git
    cd hackdavis-2025
    
  2. Frontend Setup

    cd client
    npm install
    npm run dev
    
  3. Backend Setup

    cd server
    cargo run
    
  4. Compiler Setup

    cd compiler
    cargo build
    cargo test
    

Development Workflow #

  1. Writing Code

    • Open the IDE in your browser (default: http://localhost:3000)
    • Write your robot control code in the editor
    • Use the live preview to see the robot’s movements
  2. Testing

    • Run unit tests: cargo test
    • Check compiler output: cargo run -- compile examples/robot.asm
    • Test Arduino output: cargo run -- compile-arduino examples/robot.asm
  3. Deployment

    • Build production version: npm run build
    • Deploy to server: cargo build --release
    • Upload to Arduino: Use the generated .ino file

๐Ÿ“ Project Structure #

hackdavis-2025/
โ”œโ”€โ”€ client/                  # Frontend application
โ”‚   โ”œโ”€โ”€ app/                # Next.js app directory
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # React components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Editor/    # Code editor component
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Preview/   # 3D preview component
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Terminal/  # Terminal component
โ”‚   โ”‚   โ”œโ”€โ”€ lib/           # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx       # Main page
โ”‚   โ”‚   โ””โ”€โ”€ globals.css    # Global styles
โ”‚   โ””โ”€โ”€ package.json       # Frontend dependencies
โ”‚
โ”œโ”€โ”€ server/                 # HTTP backend
โ”‚   โ”œโ”€โ”€ src/               # Server source
โ”‚   โ”‚   โ”œโ”€โ”€ main.rs       # API endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ routes/       # Route handlers
โ”‚   โ”‚   โ””โ”€โ”€ models/       # Data models
โ”‚   โ””โ”€โ”€ Cargo.toml        # Server dependencies
โ”‚
โ”œโ”€โ”€ compiler/              # Rust compiler backend
โ”‚   โ”œโ”€โ”€ src/              # Source code
โ”‚   โ”‚   โ”œโ”€โ”€ lexer.rs     # Token analysis
โ”‚   โ”‚   โ”œโ”€โ”€ parser.rs    # AST generation
โ”‚   โ”‚   โ”œโ”€โ”€ codegen.rs   # Code generation
โ”‚   โ”‚   โ””โ”€โ”€ lib.rs       # Core functionality
โ”‚   โ”œโ”€โ”€ tests/           # Test cases
โ”‚   โ””โ”€โ”€ Cargo.toml       # Rust dependencies
โ”‚
โ””โ”€โ”€ README.md             # Project documentation

๐Ÿงช Testing #

Frontend Tests #

cd client
npm test

Backend Tests #

cd server
cargo test

Compiler Tests #

cd compiler
cargo test

๐Ÿค Contributing #

We welcome contributions! Here’s how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines #

  • Follow the Rust style guide for backend code
  • Use TypeScript for all frontend code
  • Write tests for new features
  • Update documentation as needed
  • Keep commits focused and atomic

๐Ÿ“ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments #

  • HackDavis 2025 organizers and mentors
  • The amazing Next.js and Rust communities
  • All contributors and supporters
  • The open-source community for their invaluable tools and libraries

Built with โค๏ธ at HackDavis 2025

Report Bug ยท Request Feature