Skip to content

🏭 Assembler to emulate and execute programs written in MIPS assembly language independent of hardware.

Notifications You must be signed in to change notification settings

godcrampy/mips-assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIPS Assembler

Assembler to emulate and execute programs written in MIPS assembly language. The assembler will emulate a 1KB RAM Space and 32 bit registers without actually using up system registers directly. This allows it to run on any processor maching with a C++14 compiler.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

C++14 compiler preferrably GCC.

Installing

  1. Clone this repo to local machine

$ git clone https://github.com/godcrampy/mips-assembler.git

  1. cd into the cloned repo $ cd mips-assembler

  2. Build the program using make: (Assumes G++ installed, edit the Makefile for other options) $ make

OR

  1. Build using compiler $g++ src/main.cpp src/file-io/file-io.cpp src/parser/parser.cpp src/register-module/register-module.cpp src/ram-module/ram-module.cpp src/cpu-module/cpu.cpp -o build/mips

Executing MIPS

The assembler program will be built in the build directory. To run MIPS code, you need 3 files:

  • .mips: This is the file in which you'll write the mips program
  • .ram: This is the file in which you'll give ram configuration
  • .reg: This is the file in which you'll give register configuration

Example MIPS Code

test.mips

lw	$t0, 0($s1)
addi $t1, $zero, 6
while: log loop 0 $t0
addi $t0, $t0, 1
bne $t0, $t1, while

register.reg

$s1: 120

memory.ram

120: 1

Execution: $ ./mips ./test.mips ./register.reg ./memory.ram Output:

loop 1
loop 2
loop 3
loop 4
loop 5

Current Status

Currently the following instructions are supported:

  • add
  • addi
  • sub
  • and
  • andi
  • or
  • ori
  • srl
  • sll
  • lw
  • sw
  • log

Note: log is not a mips instruction. It has been provided to print register data to the teminal. It's syntax is: log message add register. This will print message followed by the data in the register with add value added to it.

About

🏭 Assembler to emulate and execute programs written in MIPS assembly language independent of hardware.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published