Skip to main content

CPU AS A SERVICE

Project description

⚙️ CAAP (CPU As A Program)

🧠 A simple virtual CPU that executes custom assembly-like instructions inside Python.

CAAP is a lightweight interpreter that simulates a basic CPU.
It lets you run simple text-based instructions like SET and MOV to manipulate variables, just like a minimal processor.


🚀 Features

  • 🧠 Simple CPU-like instruction system
  • ⚡ Fast and lightweight (pure Python)
  • 📦 No external dependencies
  • 🧪 Easy to extend with new commands
  • 🎮 Great for learning interpreters and CPU concepts

📥 Installation

pip install caap

🧑‍💻 Basic Usage

from caap import CPU

cpu = CPU()
def function(a,b):
    cpu.varb[a] = b
def func(a,b):
    cpu.varb[b] = cpu.varb[a]
cpu.scommand("SET",function)
cpu.scommand("MOV",func)
code = """
SET A, 10
SET B, 20
MOV C, A
"""

result = cpu.run(code)

print(cpu.varb)

📊 Output

{'A': 10, 'B': 20, 'C': 10}

⚙️ Supported Instructions

Instruction Description
SET A, value Assign a value to a variable
MOV A, B Copy value from variable B into A

🧠 How It Works

CAAP reads each line of text, splits it into commands, and executes it using an internal memory system (like CPU registers).

Each variable acts like a register inside a virtual CPU.


🔥 More Examples

📌 Example 1: Simple Math Storage

SET X, 5
SET Y, 15
MOV Z, X

Output:

{'X': 5, 'Y': 15, 'Z': 5}

📌 Example 2: Overwriting Values

SET A, 100
SET B, 50
MOV A, B

Output:

{'A': 50, 'B': 50}

🎮 Projects You Can Build With CAAP

🧮 1. Mini Calculator Engine

Use CAAP to simulate calculations step by step.

🧠 2. Simple AI Decision System

Use variables like memory states for decisions.

🎮 3. Text-Based Game Engine

Build HP systems, inventory, and battle logic.

⚙️ 4. CPU Simulation Learning Tool

Teach how CPUs work (registers, memory, execution).

🧪 5. Custom Language Experiments

Use CAAP as base for your own scripting language.


🧩 Roadmap

  • [✔️] ADD support (A + B)
  • [✔️] PRINT instruction
  • [✔️] IF conditions
  • [✔️] LOOP / JMP support
  • [✔️] Error handling improvements
  • [✔️] Debug mode (step-by-step execution)

🤝 Contributing

Feel free to:

  • Add new instructions
  • Improve execution engine
  • Suggest optimizations

📄 License

This project is licensed under Apache License 2.0


🧠 Author

Built with ⚙️ and creativity by tamimdevlopment


🔥 Final Note

CAAP is not just a tool —
it’s a virtual CPU inside Python 🧠⚡

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caap-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caap-0.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file caap-0.0.2.tar.gz.

File metadata

  • Download URL: caap-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for caap-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c757b9c1b85b1cfafc861768b98a614dcaa1f19910f8f9502c76ec9808cd976e
MD5 7a9fbe6041df724d45ba3d0dc52963a3
BLAKE2b-256 596589c5ea55d3ba9ffd20e4987f938a564b8da62870aa99d37ff9c2411cabc6

See more details on using hashes here.

File details

Details for the file caap-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: caap-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for caap-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bcae7dbfba765f3006b378b625ef6b3e0162f97dccbd66f9ba2a8eb8740dd317
MD5 68b3a4bfa537935bf33c590fb5554d47
BLAKE2b-256 f8c5e5e0ebdca35b179e4d499ef977fc4e275b2df9857915fddaa1e10986feb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page