Very angry virtual machine
Find a file
2024-04-22 00:41:04 +02:00
app Rename 2024-04-21 22:12:21 +02:00
gradle/wrapper Initial 2024-04-16 06:14:37 +02:00
.gitattributes Initial 2024-04-16 06:14:37 +02:00
.gitignore Ignore 2024-04-22 00:41:04 +02:00
gradlew Initial 2024-04-16 06:14:37 +02:00
gradlew.bat Initial 2024-04-16 06:14:37 +02:00
makefile Makefile for convenience 2024-04-16 06:14:45 +02:00
README.md Splitting instructions into their own mermaid figure 2024-04-21 21:07:44 +02:00
settings.gradle.kts Initial 2024-04-16 06:14:37 +02:00

HateLace - A Simple Computer

classDiagram
    class Computer {
        - Memory memory
        - Program program
        + Computer(Memory Memory)
        + void load(Program program)
        + void run()
    }
    class Memory {
        + Word read(Address address)
        + int size()
        + void write(Address address, Word data)
        + void dump()
    }
    class ProgramCounter {
        - int PC
        - int SysTick
        - boolean haltFlag
        + ProgramCounter()
        + ProgramCounter(int PC)
        + int getPC()
        + int getSysTicks()
        + int incPC()
        + int setPC(int PC)
        + boolean halted()
        + void halt()
    }
    class Program
    class ArrayList
    class Word {
        + <T> T getValue()
        + Word add(Word other)
        + Word subtract(Word other)
        + Word multiply(Word other)
        + Word divide(Word other)
        + String toString()
        + boolean equals(Object other)
    }
    class Address {
        - int address
        + Address(int address)
        + int getAddress()
        + String toString()
    }
    class LongMemory
    class LongWord
    Computer --> Memory
    Computer --> Program
    Computer --> ProgramCounter
    Program <-- ArrayList
    Program : +toString()
    Memory <|-- LongMemory
    Word <|-- LongWord


classDiagram
    class Instruction {
        + void execute(Memory memory, ProgramCounter pc)
        # String opcode()
        # Object[] operands()
        + String toString()
    }
    class Add
    class Copy
    class Halt
    class Jump
    class JumpEq
    class Mul
    class Print
    Instruction --|> Word
    Instruction --|> Address
    Add --|> Instruction
    Copy --|> Instruction
    Halt --|> Instruction
    Jump --|> Instruction
    JumpEq --|> Instruction
    Mul --|> Instruction
    Print --|> Instruction
sequenceDiagram
participant Computer
participant Program
participant Memory
participant ProgramCounter
participant Instruction

Computer -> Program: load(program)
loop Program Execution
    Program -> Computer: run()
    loop Instructions Execution
        Computer -> ProgramCounter: incPC()
        ProgramCounter -> Program: getPC()
        Program -> Program: executeInstruction()
        Program -> Instruction: execute(memory, PC)
        Instruction -> Memory: read/write(address)
        Program -> ProgramCounter: incPC()
    end
end