Giter VIP home page Giter VIP logo

super16's Introduction

super16

A strange little 16bit ISA/Architecture.

Installing

Run git clone https://github.com/l3gacyb3ta/super16.git && cd super16, then run whatever command you like! Examples are bellow in the example commands section.

How to run with emulator

As I have not yet learned how to build an actual sim in logisim or similar software (so many sim-s!), I have implemented this ISA in python. After running assembler.py with a valid asembly file as an argument, a pickle file named rom.pic will appear. In order to run it, simply execute cpu.py for normal use, and slowpu.py for debugging.

Binary compiling

In order to compile to a binary that would run on a theoretical S16 cpu, simply invoke binaryassembler.py with the asembley file as a parameter.

Examples

A set of example programs are provided in the tests/ directory. This is a great place to begin programming for S16. I have also included a script test.sh to run a test file. To do that, simply run test.sh and type the name (without .asm) of the file you want to run, and it should run.

Example commands

  • Running an assembly file:
$ python assembler.py tests/scrn.asm
$ python cpu.py
  • Compiling to a binary:
$ python binaryassembler.py tests/scrn.asm

Theory

One instruction is composed of 32 bits, making up 3 catagories; Opcode, Register and data. The opcode is two hexadecimal digits, the register is another two, and the data is a 4-digit hexadecimal number split into two two-digit numbers. Here is an example instruction loading 0xf988 into r5:

Opcode Register Data 1 Data 2
0x20 0x05 0xf9 0x88

The full list of opcodes, as well as an example, the instruction & explaination are as follows:

Opcode Instruction
0x10 store store reg reg2
Copy value from one reg to another
0x20 load load reg val
Load a value into a reg
0x30 add add reg val
Add value to reg
0x31 addr addr reg reg2
Adds reg2 to reg
0x40 sub sub reg val
Subtracts val from reg
0x41 subr subr reg reg2
Subtracts reg2 from reg
0x50 mul mul reg val
Multipy register by value
0x51 mulr mul reg reg2
Multiply reg by reg 2
0x60 div div reg val
Intiger divides the register by the value
0x61 divr div reg reg2
Initger devides reg by rg2
0xff prt prt 0x0000 0x0000
Print ascii value in p0 reg
0x0f scrn scrn 0x0000 val
Set pixel in x8 and y9 regs to the value (0: black) (1: white)
0xdd drw drw 0x0000 0x0000
Draw screen buffer
0xf0 cmp cmp reg reg2
Set cm reg to 0x0001 if bigger, 0x0000 if smaller, and 0xffff if their equal
0xb0 branch branch val label
Branch to loop if cm is val
0xb1 nbranch nbranch val label
Branch to loop if cm is not val
0xbb jump jump 0x0000 label
Jump to label
0x00 noop noop 0x000 0x000
Literally does nothing
0xfe halt halt 0x0000 0x0000
Halts the cpu

super16's People

Contributors

l3gacyb3ta avatar

Stargazers

 avatar  avatar  avatar

Watchers

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