I am attempting to create a program that will simulate the Manchester Baby (SSEM) in C++. Since I'm not very advanced with either language I'm finding it hard to even begin writing the code.
The simulation should take as input a text file containing a binary computer program written in the machine code language of the Baby (essentially 32 lines each of 32 bits of binary data corresponding to the store).
When the simulation is running, it should step through each line of the input program, simulating the fetch-decode-execute cycle. For example, after fetching an instruction, it should work out what that instruction is (which operation it corresponds to), what its operand is, then simulate the execution of that operation by moving data around the simulated hardware.
- JMP - Copy content of the specified line into the CI
- JRP - Add the content of the specified line into the CI
- LDN - Copy the content of the specified line, negated, into the accumulator
- STO - Copy the content of the accumulator to the specified store line
- SUB - Subtract the content of the specified line from the accumulator
- CMP - If the accumulator is less than 0 increment the CI
- STP - Halt the Baby and light the “stop lamp”
The "store" in the program contains 32 individually addressable lines where each line can store 32 bits of data. I was thinking of implementing each line as an array and the store as an array of those individual arrays but feel this is quite an inefficent way to do this? If anyone has a better suggestion I would appreciate it greatly.
I can't figure out how I am meant to save the instruction set in order for the program to be able to compare the input to it and carry out the operation.
I really need a kick start in the right direction. Any help at all would be wonderful.