/MIPS

Primary LanguageC++

MIPS Assembler

Usage

  • convert .hex to .asm

    MIPS -x $pathToHex$ [-o $pathToAsm$] #--translate
  • convert .asm to .bin

    MIPS -a $pathToAsm$ [-o $pathToBin$] #--assemble
  • convert .bin to .coe

    MIPS -c $pathToBin$ [-o $pathToCoe$] #--coe
  • convert .coe to .asm

    MIPS -d $pathToCoe$ [-o $pathToAsm$] #--disassemble
  • check version and help

    MIPS -v ##--version
    MIPS -h ##--help

NOTICE:

  1. Input files can have arbitrary name, they are not required to be in format of *.asm or whatever. But in this document, I will use specific name to represent files of specific format.

  2. Check the format of your file content.

    For .hex, please align instructions code in 8 hexes line by line as follows:

    #content of *.hex
    08000008,
    00000020,
    00000020,
    ......
    #`,` can be ignored

    For .coe, please start with the specific header shown below and then layout code line by line in the same format with .hex

    memory_initialization_radix=16;
    memory_initialization_vector=
    08000008,
    .....
    08000008;
  3. a.out will be the output if you do not specify the name of output by -o/--out.

support instructions

38 instructions in total:

  • [symbol] reg, reg, reg

    "add",	"addu",	"sub", "subu", 
    "and",	"or",	"xor", "nor", 
    "sllv",	"srlv",	"srav","slt",
    "sltu"
  • [symbol] reg, reg, shamt(5 bits wide)

    "sll",	"srl",	"sra"
  • [symbol] reg, reg, immediate(16 bit wide)

    "addi", "ori",	"addiu",
    "andi",	"xori", "slti",	"sltiu"
  • [symbol] reg, immediate(16 bit wide)

    "lui"
  • [symbol] reg, offset([reg]), $offset$ of 32 bit wide

    "lw",	"lb",	"lbu",	"lh",
    "lhu",	"sw",	"sh",	"sb"
  • [symbol] reg

    "jr"
  • [symbol] reg, reg, label/immediate(16 bit wide)

    "beq", "bne"
  • [symbol] label/address(26 bit wide)

    "j", "jal"