Skip to content

Latest commit

 

History

History
95 lines (65 loc) · 2.8 KB

README.MD

File metadata and controls

95 lines (65 loc) · 2.8 KB

MiniSysAssembler

一个简单的 MiniSy-1(A) 汇编器

支持语句

R型:ADD ADDU SUB SUBU MULT MULTU DIV DIVU MFHI MFLO MTHI MTLO MFC0 MTC0 AND OR XOR NOR SIT SITU SLL SRL SRA SLLV SLAV SRAV JR JALR BREAK SYSCALL ERET

I型:ADDI ADDIU ANDI ORI XORI LUI LB LBU LH LHU LW SB SH SW BEQ BNE BGEZ BGTZ BLEZ BLTZ BGEZAL BLTZAL SLTI SLTIU

J型:J JAL

同时亦支持标号的解析。废话,手算偏移量是会死人的。

自带宏语句

MOV

MOV Register, Register/Memory/Immediate
MOV Memory, Register

例子

MOV $1, $2
MOV $1, 65535
MOV $1, 0xFFFFFFFF
MOV $1, ARRAY($0)
MOV ARRAY($0), $1

PUSH

PUSH Register

例子

PUSH $1

POP

POP Register

例子

POP $1

NOP

NOP

宏语句细节
宏语句 展开为
MOV Register1, Register2 OR Register1, $0, Register2
MOV Register, Memory
(MOV Register, Offset(Register))
LW Register, Offset(Register)
MOV Memory, Register
(MOV Offset(Register), Register)
SW Register, Offset(Register)
MOV Register, Immediate
(Immediate < 0x10000)
ORI Register, $0, Immediate
MOV Register, Immediate
(Immediate >= 0x10000)
LUI Register, Immediate >> 16
ORI Register, $0, Immediate & 0xffff
PUSH Register ADDI $SP, $SP, -4
SW Register, 0($SP)
POP Register ADDI $SP, $SP, 4
LW Register, 0($SP)
NOP SLL $0, $0, 0

用法

MiniSysAssembler.exe [选项] 输入文件路径 [输出文件夹路径]

如:

# 输出至当前文件夹
MiniSysAssembler.exe C:\mycode.asm
# 输出至D:\
MiniSysAssembler.exe C:\mycode.asm D:\
# 输出至D:\同时生成用于调试的细节信息
MiniSysAssembler.exe --show-details C:\mycode.asm D:\

然后程序会生成dmem32.coe和prgmip32.coe。

Known Issue

  1. 目前不支持在数据段内写汇编指令,也不支持在代码段内定义数据。
  2. 数据类型仅支持.byte.half.word

TODO

  1. 更多的宏语句.