Giter Club home page Giter Club logo

pymips's Introduction

MIPS-Simulator

Code quality_ Travis-CI_ GitHub_release_ PyPI_ Downloads

Introduction

MIPS-Simulator runs MIPS32 programs. Unlike real simulator, which assembles the instructions into machine code and executes them, MIPS-Simulator just parse the instructions and runs them using python code. In other words, MIPS-simulator actually interprets mips instructions.

image

Note

  • This project is a toy, which means some functions are not supported.
  • If you just need an IDE for MIPS Programming, I personally recommend MARS by Softpedia Lab, Missouri State University.
  • If you also want to play with this toy, feel free to do want ever you want but don't forget about the CI tests.

Install

  • With pip : pip3 install fengyong
  • With src : Clone or fork this project, then build it with python3 setup.py install

Usage

Shell

After install, you can run a mips shell with mips-shell command.

Assemble

from fengyong import Assembler

instructions = """
j 10000
add $s0,$a1,$t7
sw $s1,10($s2)"""

machine_code = Assembler.encode(instructions)
print(machine_code.bin)
print(machine_code.value_base(16))

DisAssemble

from fengyong import DisAssembler
from fengyong import RegData

machine_code = RegData("0x8002710af820ae51000a")
instructions = DisAssembler.decode(machine_code)
print(instructions)

Simulate - RUN!

from fengyong import Simulator


# Run mips instruction in line
Simulator.run_line("addi $s0, $s1, 10")

# Run asm file
Simulator.run_file("../test/drings.asm")

Simulate - Debug

from fengyong import Registers
from fengyong import RegData


# Set the register data
Registers.reg_set("$s0",RegData(100))

# Get the register data
res = Registers.reg_get("$s0")

# print all the "s" registers
Registers.print("s")

# print all registers
Registers.print()

Example

Contributing

Read CONTRIBUTING for more information.

pymips's People

Contributors

0xseanll avatar charles-hu avatar loopyme avatar musenming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pymips's Issues

Currently unsupported instructions

Problem Instructions
Unsigned not supported not supportedaddiu addu sltiu sltu subu multu divu
LO/HI not supported
Link not supported bgezal bltzal jal
Jump not supported jr
Byte not supported lb sb
Arithmetic shift not supported sra
Other syscall

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.