Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void literalObjectCode(Instruction ins){
- if(ins.isLiteral){
- String op = ins.getOpcode();
- op = Integer.toBinaryString(Integer.parseInt(op,16));
- while(op.length()!=6){
- op = '0'+op;
- }
- int add = ins.literalAddress;
- if(ins.getFormat()==3){
- op = op+"110000";
- String displacement = Integer.toBinaryString(add);
- while(displacement.length()!=12){
- displacement ='0'+ displacement;
- }
- op = op+displacement;
- int Code =Integer.parseInt(op,2);
- op =Integer.toHexString(Code);
- while(op.length()!=6){
- op = '0'+op;
- }
- ins.setObc(op);
- }else if(ins.getFormat() ==4){
- op = op+"110001";
- String displacement = Integer.toBinaryString(add);
- while(displacement.length()!=20){
- displacement ='0'+ displacement;
- }
- op = op+displacement;
- int Code =Integer.parseInt(op,2);
- op =Integer.toHexString(Code);
- while(op.length()!=8){
- op = '0'+op;
- }
- ins.setObc(op);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement