Giter Club home page Giter Club logo

mvm's Introduction

MVM CPU

Registers

An MVM CPU has 16*32 bit registers

Index Description Read/Write Reset Value Layout
0 General Purpose Register RW 0b0000 0000 0000 0000 N/A
1 General Purpose Register RW 0b0000 0000 0000 0000 N/A
2 General Purpose Register RW 0b0000 0000 0000 0000 N/A
3 General Purpose Register RW 0b0000 0000 0000 0000 N/A
4 General Purpose Register RW 0b0000 0000 0000 0000 N/A
5 General Purpose Register RW 0b0000 0000 0000 0000 N/A
6 General Purpose Register RW 0b0000 0000 0000 0000 N/A
7 General Purpose Register RW 0b0000 0000 0000 0000 N/A
8 General Purpose Register RW 0b0000 0000 0000 0000 N/A
9 General Purpose Register RW 0b0000 0000 0000 0000 N/A
10 General Purpose Register RW 0b0000 0000 0000 0000 N/A
11 General Purpose Register RW 0b0000 0000 0000 0000 N/A
12 Status Register RO 0b0000 0000 0000 0000 equal[1] negative[1] carry[1] overflow[1] reserved[20] failureCode[8]
13 Stack Pointer RW 0b0000 0000 0000 0000 todo[32]
14 Link Register RW 0b0000 0000 0000 0000 todo[32]
15 Program Counter RW 0b0000 0000 0000 0000 todo[32]

Instruction Set

Index Instruction OPCODE Encoding Pseudocode
4 bit ops
0 AddConstant(Rx, Constant) 0b0000 OPCODE[4] Rx[4] Constant[8] Rx += Constant
1 Add(Rx, Ry, Rz) 0b0001 OPCODE[4] Rx[4] Ry[4] Rz[4] Rx = Ry + Rz
2 SubtractConstant(Rx, Constant) 0b0010 OPCODE[4] Rx[4] Constant[8] Rx -= Constant
3 Subtract(Rx, Ry, Rz) 0b0011 OPCODE[4] Rx[4] Ry[4] Rz[4] Rx = Ry - Rz
4 WriteConstant(Rx, Constant) 0b0100 OPCODE[4] Rx[4] Constant[8] Rx = Constant
5 ShiftLeft(Rx, Ry, Rz) 0b0101 OPCODE[4] Rx[4] Ry[4] Rz[4] Rx = Ry << Rz
6 ShiftRight(Rx, Ry, Rz) 0b0110 OPCODE[4] Rx[4] Ry[4] Rz[4] Rx = Ry >> Rz
7 Or(Rx, Ry, Rz) 0b0111 OPCODE[4] Rx[4] Ry[4] Rz[4] Rx = Ry | Rz
8 And(Rx, Ry, Rz) 0b1000 OPCODE[4] Rx[4] Ry[4] Rz[4] Rx = Ry & Rz
9 Flip(Rx, Ry) 0b1001 OPCODE[4] Rx[4] Ry[4] _[4] Rx = ~Ry
10 Xor(Rx, Ry, Rz) 0b1010 OPCODE[4] Rx[4] Ry[4] Rz[4] Rx = Ry^Rz
8 bit ops
11 CopyRegister(Rx, Ry) 0b1110 0000 OPCODE[8] Rx[4] Ry[4] Rx = Ry
12 CopyFromAddress(Rx, Ry) 0b1110 0001 OPCODE[8] Rx[4] Ry[4] Rx = *Ry
13 CopyToAddress(Rx, Ry) 0b1110 0010 OPCODE[8] Rx[4] Ry[4] *Ry = Rx
14 CopyHalfWordFromAddress(Rx, Ry) 0b1110 0011 OPCODE[8] Rx[4] Ry[4] Rx = (*Ry & 0xFFFF)
15 CoyHalfWordToAddress(Rx, Ry) 0b1110 0100 OPCODE[8] Rx[4] Ry[4] *Ry = (Rx & 0xFFFF)
16 CoyByteFromAddress(Rx, Ry) 0b1110 0101 OPCODE[8] Rx[4] Ry[4] *Ry = (*Rx & 0xFF)
17 CoyByteToAddress(Rx, Ry) 0b1110 0110 OPCODE[8] Rx[4] Ry[4] *Ry = (Rx & 0xFF)
18 Compare(Rx, Ry) 0b1110 0111 OPCODE[8] Rx[4] Ry[4] Rx - Ry
10 bit ops
19 BranchAlways(BranchConfig, Rx) 0b1111 00 0000 OPCODE[10] BranchConfig[2] Rx[4]
20 BranchEqual(BranchConfig, Rx) 0b1111 00 0001 OPCODE[10] BranchConfig[2] Rx[4]
21 BranchNotEqual(BranchConfig, Rx) 0b1111 00 0010 OPCODE[10] BranchConfig[2] Rx[4]
22 BranchGreaterThan(BranchConfig, Rx) 0b1111 00 0011 OPCODE[10] BranchConfig[2] Rx[4]
23 BranchGreaterThanEqual(BranchConfig, Rx) 0b1111 00 0100 OPCODE[10] BranchConfig[2] Rx[4]
24 BranchLessThan(BranchConfig, Rx) 0b1111 00 0101 OPCODE[10] BranchConfig[2] Rx[4]
25 BranchLessThanEqual(BranchConfig, Rx) 0b1111 00 0110 OPCODE[10] BranchConfig[2] Rx[4]

Args

Rx/Ry/Rz are 4 bit unsigned integers representing the register to update.

Constant is an 8 bit unsigned integer value.

BranchConfig Layout:

Bit 0 1
Purpose Reserved UpdateLinkRegister

Notes

  • MVM CPU's are little endian, this is only important when carrying out load and store op's

mvm's People

Contributors

mini-ninja-64 avatar

Stargazers

 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.