# HateLace - A Simple Computer ```mermaid 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 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 ``` ```mermaid 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 ``` ```mermaid 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 ```