Skip to content

Latest commit

 

History

History
74 lines (63 loc) · 1.34 KB

README.md

File metadata and controls

74 lines (63 loc) · 1.34 KB

Soft Machine

Python custom virtual machine.

Features

  • Registers
    • Basic registers
    • Flags
      • Zero flag
  • Stack
    • LIFO
    • Max size
    • Stackframes
  • Heap
    • Max size
  • Instructions
    • add reg, val
    • add reg, reg
    • sub reg, val
    • sub reg, reg
    • cmp reg, val
    • cmp reg, reg
    • mov reg, val
    • mov reg, reg
    • push val
    • push reg
    • pop reg
    • jmp addr
    • jmp label
    • call func
    • exit
  • Preprocessor
    • Strip labels from code
  • Assemble code
    • From file
    • From stdin
    • Parser
  • Disassemble code
    • From file
    • From stdin
    • Invert parser
  • Exec instructions
    • From file
    • From stdin

Install

# Get sources
git clone ...
cd Soft-Machine

# Use a virtual environment
python3 -m venv my-venv
source my-venv/bin/activate

# Install via pip
pip install -e .

Use

soft-machine exec -s "0x31034567;0x30001000;0x33100000;0x02110000;0x03000000;0x41120000;0x80000000"
soft-machine assemble --stdin "mov a, 11; mov b, 0x45; exit"
soft-machine disassemble --file code.bin

Stress test on push/pop:

time softmachine stresstest -n 100000