Splitting instructions into their own mermaid figure

This commit is contained in:
Imbus 2024-04-21 21:07:44 +02:00
parent 273628c41a
commit 99c8de87b1

150
README.md
View file

@ -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> 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> 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