Skip to content

Commit

Permalink
the instructioinparser is tested
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmounir committed Nov 3, 2016
1 parent e4f6f60 commit a8748e4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/assembler/Assembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,27 @@ private short getCode(String nameInText) throws AssemblyException {
}

}
public static void main(String[] args) {
Assembler assembler = new Assembler();
try {
ArrayList<Short> result = assembler.parse("test.asm");
for(int i = 0;i<result.size();i++){
Short line = result.get(i);
System.out.println(line);
String binary =Integer.toBinaryString(line);
if(binary.length()>16){
binary =binary.substring(binary.length()-16);
}else{
while(binary.length()<16){
binary="0"+binary;
}
}
System.out.println(binary);
}
} catch (IOException | AssemblyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

0 comments on commit a8748e4

Please sign in to comment.