Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case 0x0:
- print_store("sb", instruction);
- break;
- case 0x1:
- print_store("sh", instruction);
- break;
- case 0x2:
- print_store("sw", instruction);
- break;
- default:
- handle_invalid_instruction(instruction);
- break;
- }
- }
- void write_branch(Instruction instruction) {
- switch (instruction.sbtype.funct3) {
- case 0x0:
- print_branch("beq", instruction);
- break;
- case 0x1:
- print_branch("bne", instruction);
- break;
- default:
- handle_invalid_instruction(instruction);
- break;
- }
- }
- void print_lui(Instruction instruction) {
- printf(LUI_FORMAT,instruction.utype.rd, instruction.utype.imm);
- }
- void print_jal(Instruction instruction) {
- printf(JAL_FORMAT,instruction.ujtype.rd, get_jump_offset(instruction)*2);
- }
- void print_ecall(Instruction instruction) {
- printf(ECALL_FORMAT);
- }
- void print_rtype(char *name, Instruction instruction) {
- printf(RTYPE_FORMAT, name, instruction.rtype.rd, instruction.rtype.rs1, instruction.rtype.rs2);
- }
- void print_itype_except_load(char *name, Instruction instruction, int imm) {
- printf(ITYPE_FORMAT, name, instruction.itype.rd, instruction.itype.rs1, sign_extend_number(imm,12));
- }
- void print_load(char *name, Instruction instruction) {
- printf(MEM_FORMAT,name, instruction.itype.rd,instruction.itype.imm,instruction.itype.rs1);
- }
- void print_store(char *name, Instruction instruction) {
- printf(MEM_FORMAT,name,instruction.stype.rs2, get_store_offset(instruction), instruction.stype.rs1);
- }
- void print_branch(char *name, Instruction instruction) {
- printf(BRANCH_FORMAT, name, instruction.sbtype.rs1, instruction.sbtype.rs2, get_branch_offset(instruction)*2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement