|
string | convert_to_binary (char num) |
| This function converts given character to its Binary format.
|
|
int | binary_to_decimal (int token, string binary) |
| Converts the given Binary value to Decimal value.
|
|
string | sub_string (string parent, int start, int end) |
| This function is used extract substring from string.
|
|
string | R_format (const string &stringBinary) |
| If the given machine code represents RISC-V R-format instruction this function generates RISC-V instruction from the machine code.
|
|
string | I_format_immediate (const string &stringBinary) |
| If the given machine code represents RISC-V I-format instruction this function generates RISC-V instruction from the machine code.
|
|
string | I_format_load (const string &stringBinary) |
| If the given machine code represents RISC-V I-format load instruction type this function generates RISC-V instruction from the machine code.
|
|
string | S_format (const string &stringBinary) |
| If the given machine code represents RISC-V S-format this function generates RISC-V instruction from the machine code.
|
|
string | B_format (string stringBinary, int inst_no, int total_instructions) |
| If the given machine code represents RISC-V B-format this function generates RISC-V instruction from the machine code.
|
|
string | jal (string stringBinary, int inst_no, int total_instructions) |
| If the given machine code represents RISC-V jal format this function generates RISC-V instruction from the machine code.
|
|
string | jalr (const string &stringBinary) |
| If the given machine code represents RISC-V jalr format this function generates RISC-V instruction from the machine code.
|
|
string | lui (const string &stringBinary) |
| If the given machine code represents RISC-V lui format this function generates RISC-V instruction from the machine code.
|
|
string | disassembler (int total_instructions, string instruction, int inst_no) |
| This function conversion of given machine code to binary value is done and based on opcode the corresponding instruction type is found and is processed accordingly.
|
|
void | program () |
| This function reads machine code and each machine code is sent to disassembler() for further processing.
|
|
int | main () |
| Main function where program execution starts.
|
|
This file contains the code for Disassembler of RISC-V machine code
- Author
- Anudeep Rao Perala
string B_format |
( |
string |
stringBinary, |
|
|
int |
inst_no, |
|
|
int |
total_instructions |
|
) |
| |
If the given machine code represents RISC-V B-format this function generates RISC-V instruction from the machine code.
B-format instructions are: beq, bne, blt, bge, bltu, bgeu
- Parameters
-
stringBinary | RISC-V instruction machine code from which the RISCV instruction is generated |
- Returns
- RISC-V instruction
string I_format_immediate |
( |
const string & |
stringBinary | ) |
|
If the given machine code represents RISC-V I-format instruction this function generates RISC-V instruction from the machine code.
I-format instructions are: addi, xori, ori, andi, slli, srli, srai
- Parameters
-
stringBinary | RISC-V instruction machine code from which the RISCV instruction is generated |
- Returns
- RISC-V instruction
string I_format_load |
( |
const string & |
stringBinary | ) |
|
If the given machine code represents RISC-V I-format load instruction type this function generates RISC-V instruction from the machine code.
I-format load instructions are: ld, lh, lw, lbu, lhu, lwu
- Parameters
-
stringBinary | RISC-V instruction machine code from which the RISCV instruction is generated |
- Returns
- RISC-V instruction
string R_format |
( |
const string & |
stringBinary | ) |
|
If the given machine code represents RISC-V R-format instruction this function generates RISC-V instruction from the machine code.
R-format instructions are: add, sub, xor, or, and, sll, srl, sra
- Parameters
-
stringBinary | RISC-V instruction machine code from which the RISCV instruction is generated |
- Returns
- RISC-V instruction