-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cag-uconn
committed
Aug 29, 2023
1 parent
89c8759
commit b124ca3
Showing
4 changed files
with
517 additions
and
636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,52 @@ | ||
Mips Assembler | ||
RISC-V Assembler | ||
============== | ||
|
||
An assembler for a subset of the MIPS like instruction set architecture | ||
An assembler for a subset of the RISC-V instruction set architecture | ||
|
||
# How to use | ||
The assembler will take a file written in assembly language as input on the command line and will produce an output file containing the MIPS machine code. The input file should be in ASCII text. Each line in the input assembly file contains either a mnemonic, a section header (such as .data) or a label (jump or branch target. The maximum length of a line is 4 bytes. Section headers such as .data and .text should be in a line by themselves with no other assembly mnemonic. Similarly, branch targets such as loop: will be on a line by themselves with no other assembly mnemonic. The input assembly file should only contain one data section and one text section. The first section in the file will be the .text section, followed by the .data section. | ||
The assembler will take a file written in assembly language as an input on the command line, and will produce an output file containing the RISC-V machine code. The input file should be in ASCII text. Each line in the input assembly file contains either a mnemonic, a section header (such as .data) or a label (jump or branch target). The maximum length of a line is 4 bytes. Section headers such as .data and .text should be in a line by themselves with no other assembly mnemonic. Similarly, branch targets such as loop: will be on a line by themselves with no other assembly mnemonic. The input assembly file should only contain one data section and one text section. The first section in the file will be the .text section, followed by the .data section. | ||
|
||
The assembler supports the following instruction set: | ||
|
||
R-Type | ||
- add | ||
- sub | ||
- and | ||
- or | ||
- sll | ||
- slt | ||
- sll | ||
- srl | ||
- jr | ||
- and | ||
- or | ||
- xor | ||
|
||
I-Type | ||
- lw | ||
- sw | ||
- andi | ||
- jalr | ||
- addi | ||
- slti | ||
- andi | ||
- ori | ||
- lui | ||
- xori | ||
- slli | ||
- srli | ||
- lw | ||
|
||
S-Type | ||
- sw | ||
|
||
B-Type | ||
- beq | ||
- bne | ||
- blt | ||
- bge | ||
|
||
J-Type | ||
- j | ||
- jal | ||
|
||
U-Type | ||
- lui | ||
|
||
# Run | ||
to compile the assembler | ||
$ ./make | ||
$ make | ||
|
||
to run the assembler on a nop.asm assembly file to write machine code in nop.out | ||
$ ./assembler nop.asm nop.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.