Advertisement
Guest User

Untitled

a guest
May 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public static void literalObjectCode(Instruction ins){
  2. if(ins.isLiteral){
  3. String op = ins.getOpcode();
  4. op = Integer.toBinaryString(Integer.parseInt(op,16));
  5. while(op.length()!=6){
  6. op = '0'+op;
  7. }
  8. int add = ins.literalAddress;
  9. if(ins.getFormat()==3){
  10. op = op+"110000";
  11. String displacement = Integer.toBinaryString(add);
  12. while(displacement.length()!=12){
  13. displacement ='0'+ displacement;
  14. }
  15. op = op+displacement;
  16. int Code =Integer.parseInt(op,2);
  17. op =Integer.toHexString(Code);
  18. while(op.length()!=6){
  19. op = '0'+op;
  20. }
  21. ins.setObc(op);
  22. }else if(ins.getFormat() ==4){
  23. op = op+"110001";
  24. String displacement = Integer.toBinaryString(add);
  25. while(displacement.length()!=20){
  26. displacement ='0'+ displacement;
  27. }
  28. op = op+displacement;
  29. int Code =Integer.parseInt(op,2);
  30. op =Integer.toHexString(Code);
  31. while(op.length()!=8){
  32. op = '0'+op;
  33. }
  34. ins.setObc(op);
  35.  
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement