Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
cse4302/assembler/README.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
52 lines (41 sloc)
1.27 KB
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
RISC-V Assembler | |
============== | |
An assembler for a subset of the RISC-V like 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 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 | |
- xor | |
- slt | |
- sll | |
- srl | |
I-Type | |
- lw | |
- jalr | |
- addi | |
- andi | |
- ori | |
- xori | |
- slti | |
- slli | |
- srli | |
S-Type | |
- sw | |
B-Type | |
- beq | |
- bne | |
- blt | |
- bge | |
U-Type | |
- lui | |
J-Type | |
- jal | |
# Run | |
to compile the assembler | |
$ ./make | |
to run the assembler on a nop.asm assembly file to write machine code in nop.out | |
$ ./assembler nop.asm nop.out |