#Command-line or C library implementation of a MIPS assembler?

1 messages · Page 1 of 1 (latest)

obsidian rivet
#

Not sure where it would be appropriate to ask this, so I'm asking here. I want a simple assembler (on Windows) that can take MIPS assembly language and output a simple binary file like you can with NASM. Bonus points if it can be linked to as a library so I can bring it into Odin. I tried looking myself of course, but my search engine is not being very helpful.

visual mantle
#

Maybe you can use Mips-GCC, psx-sdk(for mips3000), n64sdk(for mips4000), or maybe, also, write your own. Or write your own, instruction set seems very small. I bet few hundred of lines, without macro support nor fancy error messages.

obsidian rivet
#

I've been weighing my options. I found MARS but it's not really sufficient as it assumes a particular memory model that doesn't quite fit what I need. I think I will have to roll my own assembler, but I suck at writing parsers. All I can really do efficiently is write a tokeniser. The API when parsing always proves to be terrible.

visual mantle
#

If you don't need exceptional performances you can do it with regexes, line by line. Without a tokenizer. Just a thing "that works". I wrote a thing like that (in C) just to syntax highlight Z80 asm and it was very straightforward. When you (by regex) stripped the "all but code, labels, directives" you have a optimal starting point. Then you can subregex the items captured by the more loose parent regex. In that way you have the captures that contains the "real stuff". If you want to use expressions instead, maybe you need a syntax tree. Take a look to: https://craftinginterpreters.com/