Skip to content

Commit

Permalink
Build the first stage of the Hack Assembler which assemble symbol-les…
Browse files Browse the repository at this point in the history
…s version of .asm program.
  • Loading branch information
codecyang committed Jul 8, 2020
1 parent 1dc12c5 commit cbc3654
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions assembler/src/java/Assembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public static void main(String[] args) throws IOException{
String line = "";
parser.advance();
if(parser.commandType() == Parser.CommandType.A_COMMAND
|| parser.commandType() == Parser.CommandType.L_COMMAND)
line = parser.symbol();
else if(parser.commandType() == Parser.CommandType.C_COMMAND){
|| parser.commandType() == Parser.CommandType.L_COMMAND){
int i = Integer.valueOf(parser.symbol()) & 0xffff;
line = "0" + String.format("%15s", Integer.toBinaryString(i)).replaceAll("\\s", "0");
}else if(parser.commandType() == Parser.CommandType.C_COMMAND){
String c = parser.comp();
String d = parser.dest();
String j = parser.jump();
Expand Down

0 comments on commit cbc3654

Please sign in to comment.