DEV Community

Ashton Scott Snapp
Ashton Scott Snapp

Posted on

Writing an Assembler in Rust, and How I Got the Build to Pass

Wassup! I got the thing to compile, and I've added more stuff! Also, Github repository link go go go! (edit: apparently it's displaying the wrong GH-Actions badge here, but it displays correctly on github. Caching issue, maybe?)

GitHub logo AshtonSnapp / chasm

The Official Cellia Cross-Assembler for Modern Computers


Rust Build & Test

The Official Cellia Cross-Assembler for Modern Computers

Building chasm

Clone this repository to your local machine, cd into the chasm directory, and run cargo build. Simple!

So, I got the lexer to work. Finally. It compiles. I've done a few things since last post to 1) get the thing to compile, and 2) whittle down on the number of compiler warnings. First off, the error from last time was fixed by actually passing strings into the lexer. I did that by making a function which takes a file and verbose flag and makes a lines iterator over the file, which feeds each line into the lexer. Then it checks for errors. Hopefully someday this assembler will have errors that are as helpful as rustc's, but for now they're just "hey there's an error on this line and it has this byte span. what, you want the character span? Good luck, Unicode is strange." I also had to implement all of the callback functions, and then it finally compiled.

But I still got compiler warnings to deal with. First, some warnings said that certain enum variants were never constructed. Simple fix, just implement (derive) the serde::Serialize and serde::Deserialize traits on everything that isn't a function inside the file. I probably did some other stuff to get rid of other warnings, but I'm not perfect and neither is my memory

What I do know is that I have two warnings left to get rid of, and they're confusing. Apparently, certian callback functions are apparently never used, those being instruction_large and instruction_xlarge. Only those two. I have no idea why it's just those two functions, and I have no idea why they aren't being used. It's a mystery.

Well, besides those two remaining warnings, the lexer is finished. Including the two warnings, I've still got some work to do before I can move on to the parser. Nevertheless, I hope all of you have an awesome day!

Discussion (0)