diff --git a/README.md b/README.md index eefd222..d97f036 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,11 @@ classDiagram + void run() } class Memory { - + abstract Word read(Address address) - + abstract int size() - + abstract void write(Address address, Word data) - + abstract void dump() + + Word read(Address address) + + int size() + + void write(Address address, Word data) + + void dump() } - class Program class ProgramCounter { - int PC - int SysTick @@ -29,32 +28,10 @@ classDiagram + boolean halted() + void halt() } - class Instruction { - + abstract void execute(Memory memory, ProgramCounter pc) - # abstract String opcode() - # abstract Object[] operands() - + abstract String toString() - } + class Program class ArrayList class Word { - + abstract T getValue() - + abstract Word add(Word other) - + abstract Word subtract(Word other) - + abstract Word multiply(Word other) - + abstract Word divide(Word other) - + abstract String toString() - + abstract boolean equals(Object other) - } - class Address { - - int address - + Address(int address) - + int getAddress() - + String toString() - } - class LongWord { - - Long value - + LongWord(Long value) - + Long getValue() + + T getValue() + Word add(Word other) + Word subtract(Word other) + Word multiply(Word other) @@ -62,88 +39,49 @@ classDiagram + String toString() + boolean equals(Object other) } - class Add { - - Address src - - Word imm - - Address dest - + Add(Address src, Word imm, Address dest) - + void execute(Memory memory, ProgramCounter PC) - + String opcode() - + Object[] operands() + class Address { + - int address + + Address(int address) + + int getAddress() + String toString() } - class Copy { - - Word imm - - Address dest - + Copy(Word imm, Address dest) - + void execute(Memory memory, ProgramCounter PC) - + String opcode() - + Object[] operands() - + String toString() - } - class Halt { - + Halt() - + void execute(Memory memory, ProgramCounter PC) - + String opcode() - + Object[] operands() - + String toString() - } - class Jump { - - int index - + Jump(int index) - + void execute(Memory memory, ProgramCounter PC) - + String opcode() - + Object[] operands() - + String toString() - } - class JumpEq { - - int index - - Address src - - Word imm - + JumpEq(int index, Address src, Word imm) - + void execute(Memory memory, ProgramCounter PC) - + String opcode() - + Object[] operands() - + String toString() - } - class Mul { - - Address src1 - - Address src2 - - Address dest - + Mul(Address src1, Address src2, Address dest) - + void execute(Memory memory, ProgramCounter PC) - + String opcode() - + Object[] operands() - + String toString() - } - class Print { - - Address address - + Print(Address address) - + void execute(Memory memory, ProgramCounter PC) - + String opcode() - + Object[] operands() - + String toString() - } - Memory <|-- LongMemory - Word <|-- LongWord - Program <-- ArrayList - Program --|> Instruction - Program : +toString() + class LongMemory + class LongWord Computer --> Memory Computer --> Program Computer --> ProgramCounter - ProgramCounter --> Program - ProgramCounter --> Instruction - ProgramCounter : +toString() - Instruction : +toString() - Instruction <|-- Add - Instruction <|-- Copy - Instruction <|-- Halt - Instruction <|-- Jump - Instruction <|-- JumpEq - Instruction <|-- Mul - Instruction <|-- Print - Add --> Address + 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