• Stars
    star
    336
  • Rank 125,564 (Top 3 %)
  • Language
    C++
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Comp Mark I – Simple 4-bit virtual computer

Comp

Simple 4-bit/1 Hz virtual computer for learning purposes

screenshot

For quick start see HOW TO RUN.

Memory

instructions - 4 bits
  |  +-- addresses - 4 bits
  v  v
----***-  <- 0  ----
--*-**-*  <- 1  ---*
---***--  <- 2  --*-
---*****  <- 3  --**
----***-  <- 4  -*--
---***-*  <- 5  -*-*
----**--  <- 6  -**-
---****-  <- 7  -***
-***---*  <- 8  *---
-*--****  <- 9  *--*
--------  <- 10 *-*-
--------  <- 11 *-**
--------  <- 12 **--
-------*  <- 13 **-*
-------*  <- 14 ***-
<OUTPUT>  <- 15 ****
  • Execution starts at the first address (0).
  • Execution stops when program reaches last address (15).
  • Whatever gets written to the last address is sent to the printer.
  • When reading from the last address (15), we get a random byte value.
  • CPU has one 8 bit register.

Instruction set

  • READ ---- - Copies the value at the specified address into register.
  • WRITE ---* - Copies value of the register to the specified address.
  • ADD --*- - Adds value at the specified address to the value of the register, and writes result to the register. If the result is bigger than the maximum possible value (255 = ********) then 255 gets written.
  • SUBTRACT --** - Subtracts value at the speicfied address from the value of the register, and writes result to the register. If the result is smaller than 0 then 0 gets written.
  • JUMP -*-- - Changes the value of the program counter to the specified address, meaning that in the next cycle execution will continue at that address.
  • IF MAX -*-* - Jumps to the specified address if register has value 255 = ********.
  • IF MIN -**- - Jumps to the specified address if register has value 0 = --------.
  • SHIFT R -*** - Moves every bit of the register one spot to the right. This way rightmost bit gets lost, and a leftmost becomes '-'. This is the only instruction that doesn't use the address part, making the last four bits irrelevant.
  • Any instruction that is not defined above is interpreted as READ ---- instruction.

How to run on…

Windows

  • Install Tiny Core Linux on VirtualBox using this instructions.
  • Run the UNIX commands.

UNIX

$ git clone https://github.com/gto76/comp-cpp.git
$ cd comp-cpp
$ ./run

Other versions

  • Mark II, model with separate address space for code and data, and with more instructions. Programs can be saved and loaded and it can run without the interface (instead of a printer, it then uses stdout). Also input can be piped in.

screenshot

More Repositories

1

python-cheatsheet

Comprehensive Python Cheatsheet
Python
32,714
star
2

linux-cheatsheet

Comprehensive Linux Cheatsheet
Shell
654
star
3

comp-m2

Comp Mark II – Simple 4-bit virtual computer
C++
170
star
4

standard-aliases

Attempt at defining a standard extension to Linux in form of Bash functions
Shell
104
star
5

bets

Betting odds scraper for multiple bookies
HTML
35
star
6

my-linux-setup

My Linux configuration files and text-files with notes on Linux subjects
HTML
15
star
7

wfdl

Watch Face Description Language
Python
13
star
8

face-tracker

Face tracking using openCV
Java
10
star
9

gto76.github.io

Homepage
HTML
9
star
10

race

Terminal racing game
C
9
star
11

advent-of-code-2020

Solutions to Advent of Code 2020
HTML
9
star
12

ascii-git-graph-to-png

ASCII Git graph renderer
Shell
8
star
13

js-music-player

HTML5 + jQuery + D3.js
HTML
8
star
14

fun-photo-time

Image filtering fun for everyone!
Java
8
star
15

betbrain-scraper

HTML
8
star
16

online-go-games

Records of go games
7
star
17

advent-of-code-old

Python
5
star
18

from-singularity-to-morality

TeX
5
star
19

wolfram-cells

Wolfram random patterns generator
Scala
4
star
20

tanks

Two player game
C
4
star
21

albums

37 Greatest Albums of All Time
HTML
3
star
22

SolrJ-Utility-Stuff

Utility functions for SolrJ
Java
3
star
23

foto-scripts

Bash scripts for cropping and adding borders
Shell
3
star
24

odd-rules

Betting assistant that searches for correlations between stats and betting odds
D
3
star
25

genome

Bash Scripts For DNA Analysis
Shell
3
star
26

basket-stats

Basketball stats recorder
Java
3
star
27

history-of-popular-music

JavaScript
3
star
28

comp

Simple virtual computer with assembler
Scala
3
star
29

essence-of-singularity

HTML
2
star
30

best-songs

25 Greatest Songs of All Time
HTML
2
star
31

the-library-of-the-babel

Image of an Overpopulated Universe
HTML
2
star
32

bicikl-pp

Public bicycle availability Android app for Ljubljana
Java
1
star
33

race-go

Curses racing prototype in golang
Go
1
star
34

go-game-utils

Utility scripts for analysis of go games
C
1
star
35

church

Minecraft Pi project
1
star
36

fri

Poor man's wiki
HTML
1
star
37

photos

Six photographs I am not ashamed of :)
HTML
1
star
38

living-room

Blender project
1
star
39

bit8-compiler

Compiler for simple 8-bit assembler
Scala
1
star
40

n-in-the-row

N in the row AI
Python
1
star