Coder Social home page Coder Social logo

mips-assembler's Introduction

Mips Assembler

---by Author

写在前面的话: 因为汇编器功能还不完善,所以要特别注意输入输出格式...然后程序如果崩了就再开一次

.EXE文件下载

Content

  • 支持的指令
  • 功能
  • 输入输出格式(Attention)
  • 代码示例
  • 其他相关

####1. 支持的指令 本汇编器支持附录里的如下55条指令/伪指令

  • lw
  • lb
  • lbu
  • lh
  • lhu
  • sw
  • sb
  • sh
  • add
  • addu
  • sub
  • subu
  • slt
  • sltu
  • and
  • or
  • xor
  • nor
  • sll
  • srl
  • sra
  • mult
  • multu
  • div
  • divu
  • addi
  • addiu
  • ori
  • xori
  • lui
  • slti
  • sltiu
  • beq
  • bne
  • blez
  • bgtz
  • bltz
  • bgez
  • j
  • jal
  • jalr
  • jr
  • mfhi
  • mflo
  • mthi
  • mtlo
  • eret
  • mfco
  • mtco
  • break
  • syscall
  • la
  • move
  • li

####2. 功能

图形界面支持

pic

  • 新建文件(Ctrl + N)
  • 打开文件(Ctrl + O)
  • 保存文件(Ctrl + S)
  • 另存为文件(Ctrl + Shift + S)
  • 退出(Ctrl + E)
  • 复制(Ctrl + C), 粘贴(Ctrl + V), 撤销(Ctrl + Z)
  • 汇编将文件转为.bin(F9)
  • 汇编将文件转为.coe(F10)
  • 反汇编将文件转为.asm(F11)
  • 支持部分汇编代码高亮

####3. 输入输出格式

因为程序有一些潜伏bug,所以输入输出最好跟要求的一样:
  • 大小写敏感
  • 汇编文件首行一定要注明 #baseAddre: (注意冒号!)
  • 数据块开始首地址格式: #dataAddre:
  • 字节定义: .byte (8-bits)
  • 双字节定义: .half (16-bits)
  • 字定义: .word (32-bits)
  • bin文件为二进制输入及输出,每32-bits为1行
  • coe 文件输入时添加:“memory_initialization_radix = 16; memory_initialization_vector =” (注意空格)
  • 最好不要输错指令格式,因为这个版本debug功能很弱。

####4. 其他相关

  • 本次所做的汇编器是默认有延时槽的,及比如beq和jal等指令转换为2进制后会添加一行32-bits的0
  • 反汇编没有添加辨认data区的功能
  • 如果要拷贝browser上的结果,最好用右键点击copy
  • 还存在一些暂未发现的bug,如果你找到了,请联系我:[email protected]

####5. 代码示例

asm:

#baseAddre: 0000
start:                          // [0000] 100011 00000 011010000000000001110 : 0x8C0D000E
    lw $t5,14($zero);
start_A:                        // [0004] 000000 01101 00000 01001 00000 100000 : 0x01A04820
    add $t1,$t5,$zero;
    addi $t1, $t5, -1;          // [0008] 001000 01101 01001 1111111111111111 : 0x21A9FFFF
    jr $t2;                     // [0012] 000000 01010 00000 00000 00000 001000: 0x01400008
                                // [0016]: 0x00000000
    srl $t2, $t1, 0x03;         // [0020] 00000 00000 01001 01010 00011 000010: 0x000950C2
    jalr $t2,$t1;               // [0024] 000000 01001 00000 01010 00000 001001: 0x01205009
                                // [0028]: 0x00000000
    lui  $t1, 0x02;             // [0032]: 001111 00000 01001 000000000000010: 0x3C090002
    bgez $t2, start_A;          // [0036]: 000001 01010 00001 11111111111110111: 0x0541FFF7
                                // [0040]: 0x00000000 
    beq $t2,$t5, 0x02;          // [0044]: 0000100 01010 01101 0000000000000010: 0x114D0002
                                // [0048]: 0x00000000
JUM_P1:                         // [0052]
    j   start; 
                                // [0056]: 00000000
loop:   nor $t1, $t0, $t0;      // [0060]
        slt $t2, $t0, $t1;      // [0064]
      // 000000 01000 01001 01010 00000 101010
        add $t3, $t2, $t2;      // [0068]
        add $t4, $t3, $t3;      // [0072]
        add $t5, $t4, $t2;      // [0076]
        add $t6, $t5, $t5;      // [0080]
        nor $t7, $t5, $t5;      // [0084]
        sub $s0, $t7, $t4;      // [0088]
      // 000000 01111 01100 10000 00000 100010
        and $s1, $s0, $t5;      // [0092]
        and $s2, $s0, $t6;      // [0096]
        or  $s3, $t5, $t6;      // [0100]
      // 000000 01101 01110 10011 00000 100101
        or  $s4, $s3, $t7;      // [0104]
        slt $s5, $t5, $t7;      // [0108]
JUMP:                          
        j loop;                 // [0112]
        jal start;              // [0116]
        eret ;                  // [0120]
        syscall;                // [0124]
        break;             // [0128]
#dataAddre: 200;               
Data1:
.byte  0x12, 0x34, 0x56, 0x78;     // 200 - 203        
.half  0x1234, 0x4567;             // 204 - 207
.word  0x12345678, 0x87654321;     // 208 - 215                                    
#dataAddre: 300;
Data2:
.byte  0x33, 0x22, 0x11, 0x00;     //4000
.half  0x45, 0x5432;               //4002
.word  0xbbbbbbbb, 0xaaaaaaaa;     //4006

bin:

10001100000011010000000000001110
00000001101000000100100000100000
00100001101010011111111111111111
00000001010000000000000000001000
00000000000000000000000000000000
00000000000010010101000011000010
00000001001000000101000000001001
00000000000000000000000000000000
00111100000010010000000000000010
00000101010000011111111111110111
00000000000000000000000000000000
00010001010011010000000000000010
00000000000000000000000000000000
00001000000000000000000000000000
00000000000000000000000000000000
00000001000010000100100000100111
00000001000010010101000000101010
00000001010010100101100000100000
00000001011010110110000000100000
00000001100010100110100000100000
00000001101011010111000000100000
00000001101011010111100000100111
00000001111011001000000000100010
00000010000011011000100000100100
00000010000011101001000000100100
00000001101011101001100000100101
00000010011011111010000000100101
00000001101011111010100000101010
00001000000000000000000000001111
00000000000000000000000000000000
00001100000000000000000000000000
00000000000000000000000000000000
01000000000000000000000000011000
00000000000000000000000000001100
00000000000000000000000000001101
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00010010001101000101011001111000
00010010001101000100010101100111
00010010001101000101011001111000
10000111011001010100001100100001
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00110011001000100001000100000000
01000101000000000101010000110010
10111011101110111011101110111011
10101010101010101010101010101010

coe:

memory_initialization_radix = 16;
memory_initialization_vector =
8C0D000E, 01A04820, 21A9FFFF, 01400008, 00000000, 000950C2, 01205009, 00000000, 
3C090002, 0541FFF7, 00000000, 114D0002, 00000000, 08000000, 00000000, 01084827, 
0109502A, 014A5820, 016B6020, 018A6820, 01AD7020, 01AD7827, 01EC8022, 020D8824, 
020E9024, 01AE9825, 026FA025, 01AFA82A, 0800000F, 00000000, 0C000000, 00000000, 
40000018, 0000000C, 0000000D, 00000000, 00000000, 00000000, 00000000, 00000000, 
00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 
00000000, 00000000, 12345678, 12344567, 12345678, 87654321, 00000000, 00000000, 
00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 
00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 
00000000, 00000000, 00000000, 33221100, 45005432, BBBBBBBB, AAAAAAAA;

mips-assembler's People

Contributors

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