A Python-based assembler for the Simple RISC instruction set architecture with a modern GUI interface.
- Modern graphical user interface with syntax highlighting
- Real-time assembly and error reporting
- Multiple output formats (binary and hexadecimal)
- Support for labels and comments
- Comprehensive error checking and validation
Ensure you have Python 3.6+ installed on your system.
Run the following command to install the required Python libraries:
pip install tkinterExecute the following command in your terminal or command prompt:
python GUI.py- Create a new file
- Open an existing assembly file
- Save the current file
- Assemble the code
The repository consists of the following key files:
GUI.py- Implements the graphical user interface using Tkinter.final.py- Contains the assembler logic for parsing and converting S-RISC-21 assembly into binary/hexadecimal.
- Single-line comments start with
@or# - Multi-line comments are enclosed in
/* */
- Must start with a letter or underscore
- Can contain letters, numbers, and underscores
- End with a colon (
:)
Example:
loop:
add r1, r2, r3- General-purpose registers:
r0tor15 - Special registers:
sp(stack pointer),ra(return address)
add rd, rs1, rs2
sub rd, rs1, rs2
mul rd, rs1, rs2
div rd, rs1, rs2
mod rd, rs1, rs2
and rd, rs1, rs2
or rd, rs1, rs2
lsl rd, rs1, rs2
lsr rd, rs1, rs2
asr rd, rs1, rs2cmp rs1, rs2
not rd, rs1
mov rd, immnop
ret
beq label
bgt label
b label
call labelld rd, imm[rs1]
st rs2, imm[rs1]- Signed immediate range:
-32768 to 32767 - Unsigned immediate range:
0 to 65535 - Memory offset range:
-32768 to 32767
The assembler provides detailed error messages for:
- Invalid register numbers
- Out-of-range immediate values
- Invalid memory offsets
- Undefined labels
- Syntax errors
- Invalid instruction formats
- Shows memory address and 32-bit binary instruction
- Format:
address: binary_instruction
- Shows assembled instructions in hexadecimal format
- One instruction per line
- Clone this repository:
git clone <repository_url> cd <repository_directory>
- Install dependencies:
pip install tkinter
- Run the GUI interface:
python GUI.py
- Write your assembly code in the editor.
- Click Assemble to generate the binary and hexadecimal output.
- View the assembled output in the provided tabs.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.