Compare commits
	
		
			2 commits
		
	
	
		
			9f3b5f17b9
			...
			273628c41a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						273628c41a | ||
| 
							 | 
						39d04244cf | 
					 1 changed files with 96 additions and 9 deletions
				
			
		
							
								
								
									
										105
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										105
									
								
								README.md
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -15,6 +15,7 @@ classDiagram
 | 
			
		|||
        + abstract void write(Address address, Word data)
 | 
			
		||||
        + abstract void dump()
 | 
			
		||||
    }
 | 
			
		||||
    class Program
 | 
			
		||||
    class ProgramCounter {
 | 
			
		||||
        - int PC
 | 
			
		||||
        - int SysTick
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +29,6 @@ classDiagram
 | 
			
		|||
        + boolean halted()
 | 
			
		||||
        + void halt()
 | 
			
		||||
    }
 | 
			
		||||
    class Program
 | 
			
		||||
    class Instruction {
 | 
			
		||||
        + abstract void execute(Memory memory, ProgramCounter pc)
 | 
			
		||||
        # abstract String opcode()
 | 
			
		||||
| 
						 | 
				
			
			@ -62,14 +62,67 @@ classDiagram
 | 
			
		|||
        + String toString()
 | 
			
		||||
        + boolean equals(Object other)
 | 
			
		||||
    }
 | 
			
		||||
    class LongMemory {
 | 
			
		||||
        - long[] memory
 | 
			
		||||
        + LongMemory()
 | 
			
		||||
        + LongMemory(int size)
 | 
			
		||||
        + Word read(Address address)
 | 
			
		||||
        + int size()
 | 
			
		||||
        + void write(Address address, Word data)
 | 
			
		||||
        + void dump()
 | 
			
		||||
    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()
 | 
			
		||||
        + 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
 | 
			
		||||
| 
						 | 
				
			
			@ -79,4 +132,38 @@ classDiagram
 | 
			
		|||
    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
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```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
 | 
			
		||||
```
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue