Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. case 0x0:
  2. print_store("sb", instruction);
  3. break;
  4. case 0x1:
  5. print_store("sh", instruction);
  6. break;
  7. case 0x2:
  8. print_store("sw", instruction);
  9. break;
  10. default:
  11. handle_invalid_instruction(instruction);
  12. break;
  13. }
  14. }
  15.  
  16. void write_branch(Instruction instruction) {
  17. switch (instruction.sbtype.funct3) {
  18. case 0x0:
  19. print_branch("beq", instruction);
  20. break;
  21. case 0x1:
  22. print_branch("bne", instruction);
  23. break;
  24. default:
  25. handle_invalid_instruction(instruction);
  26. break;
  27. }
  28. }
  29.  
  30. void print_lui(Instruction instruction) {
  31. printf(LUI_FORMAT,instruction.utype.rd, instruction.utype.imm);
  32. }
  33.  
  34. void print_jal(Instruction instruction) {
  35. printf(JAL_FORMAT,instruction.ujtype.rd, get_jump_offset(instruction)*2);
  36. }
  37.  
  38. void print_ecall(Instruction instruction) {
  39. printf(ECALL_FORMAT);
  40. }
  41.  
  42. void print_rtype(char *name, Instruction instruction) {
  43. printf(RTYPE_FORMAT, name, instruction.rtype.rd, instruction.rtype.rs1, instruction.rtype.rs2);
  44. }
  45.  
  46. void print_itype_except_load(char *name, Instruction instruction, int imm) {
  47. printf(ITYPE_FORMAT, name, instruction.itype.rd, instruction.itype.rs1, sign_extend_number(imm,12));
  48. }
  49.  
  50. void print_load(char *name, Instruction instruction) {
  51. printf(MEM_FORMAT,name, instruction.itype.rd,instruction.itype.imm,instruction.itype.rs1);
  52. }
  53.  
  54. void print_store(char *name, Instruction instruction) {
  55. printf(MEM_FORMAT,name,instruction.stype.rs2, get_store_offset(instruction), instruction.stype.rs1);
  56. }
  57.  
  58. void print_branch(char *name, Instruction instruction) {
  59. printf(BRANCH_FORMAT, name, instruction.sbtype.rs1, instruction.sbtype.rs2, get_branch_offset(instruction)*2);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement