see our project here: https://github.com/PianoPanda/HackUMASSXI
Inspiration
Our team was extremely interested in being able to run a terminal in the browser. We've previously seen examples where people had fully implemented consoles for different operating systems, but we wanted to make our own.
What it does
Decompile and run RISC-V binaries. Runs machine code on the web.
How we built it
We used a combination of javascript and python packages to implement the different steps of this process. For example, we have different processes for dissembling, decoding, executing, encoding, and loading. We also used bun, instead of npm, to run the program since it is significantly faster.
Challenges we ran into
Our original idea was to run linux in a browser. However, this soon proved to be much harder than imagined. We also ran into some issues when writing some of the code, like figuring out exactly how to parse and perform each operation for every single type (R, I, S, B, U, J, Other).
We designed our registers to store unsigned 32-bit integers. Since Javascript has limited support for arithmetic on 32-bit integers, in some cases we needed to convert register content from unsigned to signed for some operations while type casting to BitInt for other operations like multiplication.
Another issue we ran into is that the Google Cloud Virtual Machine instances sometimes take a long time to spin up/get ready and the permissions associated with the VM are not too intuitive.
Accomplishments that we're proud of
Being able to have an emulated RISC-V processor capable of processing RV32 images deployed on the web for the public, enabling many to learn the power nature of open-source architectures like RISC-V, raising awareness for the spirit of open-source.
We are proud to have “translated” a total of 64 instructions (base instructions + extension instructions) in Javascript to aid our emulation process.
We are also proud to conjure up a swift deployment to Google Cloud to have this emulation service hosted and accessible to anyone interested in viewing the project even after HackUMassXI ends.
This product can be used to dissemble binaries for assembly analysis, a key component for ensuring no security vulnerabilities were created between the compilation of C to Machines Code.
What we learned
We learned to utilize a new emerging technology: bun, a javascript runtime, to speed up compiling and testing our project since bun is engineered to be faster than node.js. We learned to emulate a processor following all base instructions as well as some modular, add-on instructions for a 32-bit RISC-V CPU. Through this project, we explored how memory works behind the scenes, how registers store values and interact with one another, how an emulated BIOS kick starts the emulation, how to deal with memory overflow and the intricate signed and unsigned arithmetic operations using integers and floating points, how app deployment works with Google Cloud and express.js working in conjunction.
What's next for RISC-V-js
We would like to continue implementing more instructions and upgrade our processor from 32-bit to 64-bit with all the modular instructions. We would like our emulated processor to eventually be able to run Linux.
Built With
- bun
- express.js
- gcloud
- html5
- javascript
- node.js
Log in or sign up for Devpost to join the conversation.