-
-
Save Borgaard/2849ae6cd3d5eb30fa9c7e9bc3dca31f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Memory { | |
data: number[]; | |
constructor(data: number[]) { | |
} | |
set_location(location: number, value: number): Memory { | |
} | |
get_location(location: number): number { | |
} | |
copy(): Memory { | |
} | |
} | |
class Processor { | |
program_counter: number; | |
registerA: number; | |
registerB: number; | |
registerC: number; | |
stack_pointer: number; | |
memory: Memory; | |
constructor(program_counter, registerAdefault, registerBdefault, registerCdefault, stack_pointer, memory) { | |
this.program_counter = program_counter | |
this.registerA = registerAdefault | |
///... | |
} | |
copy(): Processor { | |
} | |
} | |
//copy the processor and increment the program_counter by adding 4 | |
function AdvanceProgramCounter(cpu: Processor): Processor { | |
} | |
//copy the processor and set the named register to the value specified | |
function loadRegister(cpu: Processor, registerName: string, value: number): Processor { | |
} | |
// copy the processor and lookup value in memory and set the value of named register | |
function loadRegisterFromMemory(cpu: Processor, registerName: string, location: number) { | |
//cpu.memory.get_location(location); | |
} | |
var startingMemory = new Memory([3,1,4,1,5,8,2,6,5,3,5]); | |
var startingCpu = new Processor(0, 0, 0, 0, startingMemory.data.length, startingMemory); | |
var nextStepCpu = loadRegister(startingCpu, "registerA", 1); | |
var memoryStepCPu = loadRegisterFromMemory(nextStepCpu, "RegisterB", 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment