GithubHelp home page GithubHelp logo

simplecpu's Introduction

This is a just a small realisation of the computer described in Computer Science: An overview (Sixth Edition) by by J.G. Brookshear.

It is very buggy and fragile but it will run the example programs/exercises described in the book, in the form of ROMS assembled by the small assembler included in this package

Notes

I used this as an educational exercise to give me a refresher on how basic computers work. This is by no means a correct implementation, just my initial interpretation of what is described in the book.

Usage

./machine roms/add.rom
  • The -p flag will pause the machine after each CPU cycle
  • The -d flag will dump the state of the machine after each CPU cycle

Example

The following program will add two numbers together and store the result in memory

LDV 102
LDV 203
ADD 312
STO	3FF
HLT 000

assembler/assembler -i add.s -o add.rom
./machine add.rom

Specification

  • 256 bytes of memory
  • 16 general purpose registers (each one byte in size)
  • 1 instruction register (two bytes in size)
  • 1 program counter (one byte in size)
  • Memory addressing is simple.
  • CPU has no clock to regulate it
  • No floating point implementation
  • No support for overflow/carry flags
  • ROMs are loaded and stored at memory address 0x00
  • Basic instruction set
Table: The small instruction set for our machine language
Op-code Operand Description
1 R X Y LOAD the register R with the data found in memory cell with address XY
2 R X Y LOAD the register R with the value XY
3 R X Y STORE the value in register R in the memory cell with address XY
4 0 R S MOVE the value in register R to the register S
5 R S T ADD the values in registers S and T and store the result in register R
7 R S T OR the values in registers S and T in store the result in register R
8 R S T AND the values in registers S and T in store the result in register R
9 R S T XOR the values in registers S and T in store the result in register R
B R X Y JUMP to the instruction located in the memory cell XY if the value in register R is equal to the value in register 0
C 0 0 0 HALT execution

License

Do what you want

simplecpu's People

Contributors

djhworld avatar

Stargazers

LEO D PEN avatar  avatar  avatar Duaa Elsayed avatar Kirill Karpenok avatar  avatar

Watchers

 avatar  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.