Giter VIP home page Giter VIP logo

cpu-memory-simulation's Introduction

CPU-Memory-Simulation

The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory will be simulated by separate processes that communicate. Memory will contain one program that the CPU will execute and then the simulation will end.

TO RUN:

  1. Compile files: javac *.java

  2. Run class files: java CPU "sample program" "timer interrupt value" example: java CPU sample1.txt 30

Instruction set

1 = Load value              Load the value into the AC             
2 = Load addr               Load the value at the address into the AC
3 = LoadInd addr            Load the value from the address found in the given address into the AC
                            (for example, if LoadInd 500, and 500 contains 100, then load from 100).
4 = LoadIdxX addr           Load the value at (address+X) into the AC
                            (for example, if LoadIdxX 500, and X contains 10, then load from 510).
5 = LoadIdxY addr           Load the value at (address+Y) into the AC
6 = LoadSpX                 Load from (Sp+X) into the AC (if SP is 990, and X is 1, load from 991).
7 = Store addr              Store the value in the AC into the address
8 = Get                     Gets a random int from 1 to 100 into the AC
9 = Put port                If port=1, writes AC as an int to the screen
                            If port=2, writes AC as a char to the screen

10 = AddX Add the value in X to the AC 11 = AddY Add the value in Y to the AC 12 = SubX Subtract the value in X from the AC 13 = SubY Subtract the value in Y from the AC 14 = CopyToX Copy the value in the AC to X 15 = CopyFromX Copy the value in X to the AC 16 = CopyToY Copy the value in the AC to Y 17 = CopyFromY Copy the value in Y to the AC 18 = CopyToSp Copy the value in AC to the SP 19 = CopyFromSp Copy the value in SP to the AC 20 = Jump addr Jump to the address 21 = JumpIfEqual addr Jump to the address only if the value in the AC is zero 22 = JumpIfNotEqual addr Jump to the address only if the value in the AC is not zero 23 = Call addr Push return address onto stack, jump to the address 24 = Ret Pop return address from the stack, jump to the address 25 = IncX Increment the value in X 26 = DecX Decrement the value in X 27 = Push Push AC onto stack 28 = Pop Pop from stack into AC 29 = Int Perform system call 30 = IRet Return from system call 50 = End End execution

cpu-memory-simulation's People

Contributors

nomaanakhan avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.