| 
					
				 | 
			
			
				@@ -59,257 +59,264 @@ import de.mcs.utils.jsap.SwitchOption; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Command(help = "SPS Assembler \r\n usage java -jar SPSEmulator-x.x.x.jar <options>")
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class SPSAssembler {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static File source;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static HARDWARE destination;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static int lineNumber;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static int srcLineNumber;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static Map<String, Integer> labels = new HashMap<>();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static boolean inBlockComment;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static List<Mnemonic> mnemonics = new ArrayList<>();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static File destinationFile;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static FORMAT outputFormat;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static File source;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static HARDWARE destination;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static int lineNumber;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static int srcLineNumber;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static Map<String, Integer> labels = new HashMap<>();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static boolean inBlockComment;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static List<Mnemonic> mnemonics = new ArrayList<>();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static File destinationFile;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static FORMAT outputFormat;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/**
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public SPSAssembler() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// TODO Auto-generated constructor stub
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  /**
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public SPSAssembler() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // TODO Auto-generated constructor stub
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@SwitchOption(shortKey = 'h', longKey = "help", name = "help", help = "show this help page", required = false, defaultValue = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public static void doHelp(boolean value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			CommandlineProcessor.showHelp();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			System.exit(0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  @SwitchOption(shortKey = 'h', longKey = "help", name = "help", help = "show this help page", required = false, defaultValue = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public static void doHelp(boolean value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      CommandlineProcessor.showHelp();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      System.exit(0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@StringOption(shortKey = 'f', longKey = "format", name = "format", defaultValue = "HEX", help = "the output format. HEX: IntelHEX, TPSTXT: TPS programming text", required = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public static void setOutputFormat(String value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		outputFormat = FORMAT.valueOf((value.toUpperCase()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  @StringOption(shortKey = 'f', longKey = "format", name = "format", defaultValue = "HEX", help = "the output format. HEX: IntelHEX, TPSTXT: TPS programming text", required = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public static void setOutputFormat(String value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    outputFormat = FORMAT.valueOf((value.toUpperCase()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@StringOption(shortKey = 'd', longKey = "hardware", name = "hardware system", defaultValue = "HOLTEK", help = "the hardware system to compile to. Passible options are: HOLTEK, ATMEGA8, ARDUINOSPS, TINYSPS", required = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public static void setDestinationSystem(String value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		destination = HARDWARE.valueOf((value.toUpperCase()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  @StringOption(shortKey = 'd', longKey = "hardware", name = "hardware system", defaultValue = "HOLTEK", help = "the hardware system to compile to. Passible options are: HOLTEK, ATMEGA8, ARDUINOSPS, TINYSPS", required = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public static void setDestinationSystem(String value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    destination = HARDWARE.valueOf((value.toUpperCase()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@FileOption(index = 1, name = "source file", help = "source file to compile", required = true, mustExists = true)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public static void setSourceFile(File file) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		source = file;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  @FileOption(index = 1, name = "source file", help = "source file to compile", required = true, mustExists = true)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public static void setSourceFile(File file) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if ((file != null) && !file.getName().equals("")) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      source = file;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@FileOption(index = 2, name = "destination file", help = "destination file to compile to", required = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public static void setDestinationFile(File file) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if ((file != null) && !file.getName().equals("")) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			destinationFile = file;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  @FileOption(index = 2, name = "destination file", help = "destination file to compile to", required = false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public static void setDestinationFile(File file) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if ((file != null) && !file.getName().equals("")) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      destinationFile = file;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/**
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * @param args
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * @throws IOException
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public static void main(String[] args) throws IOException, SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		destination = HARDWARE.HOLTEK;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  /**
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * @param args
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * @throws IOException
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public static void main(String[] args) throws IOException, SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    destination = HARDWARE.HOLTEK;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		CommandlineProcessor.processCommandline(SPSAssembler.class, args);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    CommandlineProcessor.processCommandline(SPSAssembler.class, args);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if ((source == null) || (!source.exists())) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      CommandlineProcessor.showHelp(
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          String.format("source file null or not found. %s", (source == null) ? "" : source.getAbsolutePath()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      System.exit(-1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.printf("source file: %s \r\n", source.getName());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (destinationFile == null) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      String name = source.getName();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      name = name.substring(0, source.getName().lastIndexOf("."));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      String ext = ".hex";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (outputFormat.equals(FORMAT.TPSTXT)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ext = ".txt";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      destinationFile = new File(source.getParentFile(), name + ext);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.printf("destination file: %s \r\n", destinationFile.getName());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.println();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (!source.exists()) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new FileNotFoundException(String.format("source file not found. %s", source.getAbsolutePath()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.printf("source file: %s \r\n", source.getName());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (destinationFile == null) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			String name = source.getName();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			name = name.substring(0, source.getName().lastIndexOf("."));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			String ext = ".hex";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (outputFormat.equals(FORMAT.TPSTXT)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				ext = ".txt";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			destinationFile = new File(source.getParentFile(), name + ext);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.printf("destination file: %s \r\n", destinationFile.getName());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.println();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    try {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      List<String> sourceFile = Files.readAllLines(source.toPath(), Charset.forName("UTF-8"));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      for (String line : sourceFile) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        srcLineNumber++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        parseLine(srcLineNumber, line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		try {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			List<String> sourceFile = Files.readAllLines(source.toPath(), Charset.forName("UTF-8"));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			for (String line : sourceFile) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				srcLineNumber++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				parseLine(srcLineNumber, line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } catch (SyntaxError e) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      System.err.println(e.getMessage());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      System.exit(-1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Checking destination
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (Iterator<Mnemonic> iterator = mnemonics.iterator(); iterator.hasNext();) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      Mnemonic mnemonic = iterator.next();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (!mnemonic.allowedHardware().contains(destination)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        throw new SyntaxError(mnemonic.getLineNumber(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String.format("the mnemonic \"%s\" with the argument \"%s\" is not availble on the choosen hardware \"%s\"",
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mnemonic.getName(), mnemonic.getArgument(), destination.name()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} catch (SyntaxError e) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			System.err.println(e.getMessage());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			System.exit(-1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// Checking destination
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for (Iterator<Mnemonic> iterator = mnemonics.iterator(); iterator.hasNext();) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Mnemonic mnemonic = iterator.next();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (!mnemonic.allowedHardware().contains(destination)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				throw new SyntaxError(mnemonic.getLineNumber(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						String.format("the mnemonic \"%s\" with the argument \"%s\" is not availble on the choosen hardware \"%s\"", mnemonic.getName(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								mnemonic.getArgument(), destination.name()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.println("parsing line numbers");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int address = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (Iterator<Mnemonic> iterator = mnemonics.iterator(); iterator.hasNext();) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      Mnemonic mnemonic = iterator.next();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (mnemonic instanceof JMP) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (mnemonic.isLabel()) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          processJMP(mnemonic);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (mnemonic instanceof RJMP) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (mnemonic.isLabel()) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          processRJMP(address, mnemonic);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      address++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.println("parsing line numbers");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		int address = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for (Iterator<Mnemonic> iterator = mnemonics.iterator(); iterator.hasNext();) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Mnemonic mnemonic = iterator.next();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (mnemonic instanceof JMP) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (mnemonic.isLabel()) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					processJMP(mnemonic);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (mnemonic instanceof RJMP) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (mnemonic.isLabel()) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					processRJMP(address, mnemonic);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			address++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.println("Mnemonics");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int pos = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (Iterator<Mnemonic> iterator = mnemonics.iterator(); iterator.hasNext();) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      Mnemonic mnemonic = iterator.next();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      System.out.printf("0x%03x: %s\r\n", pos, mnemonic.toString());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      pos++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.println("Mnemonics");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		int pos = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for (Iterator<Mnemonic> iterator = mnemonics.iterator(); iterator.hasNext();) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Mnemonic mnemonic = iterator.next();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			System.out.printf("0x%03x: %s\r\n", pos, mnemonic.toString());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			pos++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.println();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.println("labels");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (Entry<String, Integer> entry : labels.entrySet()) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      System.out.printf("%s: 0x%03x\r\n", entry.getKey(), entry.getValue());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.println();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.println("labels");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for (Entry<String, Integer> entry : labels.entrySet()) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			System.out.printf("%s: 0x%03x\r\n", entry.getKey(), entry.getValue());
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (outputFormat.equals(FORMAT.HEX)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      outputHEX();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (outputFormat.equals(FORMAT.TPSTXT)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      outputTPSTXT();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (outputFormat.equals(FORMAT.HEX)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			outputHEX();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (outputFormat.equals(FORMAT.TPSTXT)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			outputTPSTXT();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static void outputTPSTXT() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    try (Writer writer = new BufferedWriter(new FileWriter(destinationFile))) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      writer.write("Addr   BD   Befehl   Daten     Kommentar\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      int address = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      for (Mnemonic mnemonic : mnemonics) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        byte lowNibble = (byte) (mnemonic.getByte() & 0x0f);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        byte highNibble = (byte) ((mnemonic.getByte() >> 4) & 0x0f);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        writer.write(String.format("0x%03x  %02x   %4s     %4s      %s %s\r\n", address, mnemonic.getByte(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            nibbleToString(highNibble), nibbleToString(lowNibble), mnemonic.getName(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            StringUtils.isEmpty(mnemonic.getArgument()) ? "" : mnemonic.getArgument()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mnemonic.getByte();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        address++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } catch (IOException e) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      e.printStackTrace();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } finally {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static void outputTPSTXT() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		try (Writer writer = new BufferedWriter(new FileWriter(destinationFile))) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			writer.write("Addr   BD   Befehl   Daten     Kommentar\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			int address = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			for (Mnemonic mnemonic : mnemonics) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				byte lowNibble = (byte) (mnemonic.getByte() & 0x0f);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				byte highNibble = (byte) ((mnemonic.getByte() >> 4) & 0x0f);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				writer.write(String.format("0x%03x  %02x   %4s     %4s      %s %s\r\n", address, mnemonic.getByte(), nibbleToString(highNibble),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						nibbleToString(lowNibble), mnemonic.getName(), StringUtils.isEmpty(mnemonic.getArgument()) ? "" : mnemonic.getArgument()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				mnemonic.getByte();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				address++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} catch (IOException e) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			e.printStackTrace();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} finally {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static String nibbleToString(byte lowNibble) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    StringBuilder b = new StringBuilder();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    b.append((lowNibble & 0x08) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    b.append((lowNibble & 0x04) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    b.append((lowNibble & 0x02) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    b.append((lowNibble & 0x01) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return b.toString();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static String nibbleToString(byte lowNibble) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		StringBuilder b = new StringBuilder();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		b.append((lowNibble & 0x08) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		b.append((lowNibble & 0x04) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		b.append((lowNibble & 0x02) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		b.append((lowNibble & 0x01) > 0 ? "X" : "0");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return b.toString();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static void outputHEX() throws FileNotFoundException, IOException {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    IntelHex intelHex = new IntelHex();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    byte[] data = new byte[mnemonics.size()];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int i = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (Mnemonic mnemonic : mnemonics) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      data[i] = (byte) mnemonic.getByte();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      i++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    FileOutputStream output = new FileOutputStream(destinationFile);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    intelHex.writeHexStream(output, data);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    output.close();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static void outputHEX() throws FileNotFoundException, IOException {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		IntelHex intelHex = new IntelHex();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		byte[] data = new byte[mnemonics.size()];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		int i = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for (Mnemonic mnemonic : mnemonics) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			data[i] = (byte) mnemonic.getByte();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			i++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		FileOutputStream output = new FileOutputStream(destinationFile);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		intelHex.writeHexStream(output, data);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		output.close();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static void processJMP(Mnemonic mnemonic) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    String label = mnemonic.getArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (!labels.containsKey(label)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      throw new SyntaxError(mnemonic.getLineNumber(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          String.format("used label %s on mnemonic \"%s\" is not defined.", label, mnemonic.getName()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int lineNumber = (Integer) labels.get(label);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int page = lineNumber / 16;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    lineNumber = lineNumber % 16;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    mnemonic.setArgument(Integer.toString(lineNumber));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    mnemonic.checkArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static void processJMP(Mnemonic mnemonic) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		String label = mnemonic.getArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (!labels.containsKey(label)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new SyntaxError(mnemonic.getLineNumber(), String.format("used label %s on mnemonic \"%s\" is not defined.", label, mnemonic.getName()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		int lineNumber = (Integer) labels.get(label);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		int page = lineNumber / 16;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		lineNumber = lineNumber % 16;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		mnemonic.setArgument(Integer.toString(lineNumber));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		mnemonic.checkArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static void processRJMP(int address, Mnemonic mnemonic) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    String label = mnemonic.getArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (!labels.containsKey(label)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      throw new SyntaxError(mnemonic.getLineNumber(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          String.format("used label %s on mnemonic \"%s\" is not defined.", label, mnemonic.getName()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int lineNumber = (Integer) labels.get(label);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    lineNumber = address - lineNumber;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (lineNumber < 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      throw new SyntaxError(mnemonic.getLineNumber(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          String.format("label %s defined after mnemonic \"%s\". JMP can only step back!", label, mnemonic.getName()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    mnemonic.setArgument(Integer.toString(lineNumber));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    mnemonic.checkArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static void processRJMP(int address, Mnemonic mnemonic) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		String label = mnemonic.getArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (!labels.containsKey(label)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new SyntaxError(mnemonic.getLineNumber(), String.format("used label %s on mnemonic \"%s\" is not defined.", label, mnemonic.getName()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		int lineNumber = (Integer) labels.get(label);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		lineNumber = address - lineNumber;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (lineNumber < 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new SyntaxError(mnemonic.getLineNumber(),
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					String.format("label %s defined after mnemonic \"%s\". JMP can only step back!", label, mnemonic.getName()));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		mnemonic.setArgument(Integer.toString(lineNumber));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		mnemonic.checkArgument();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static void parseLine(int srcLineNumber, String line) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (line.startsWith(":")) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      String label = getLabel(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (labels.containsKey(label)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        throw new SyntaxError(srcLineNumber,
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String.format("Label \"%s\" already definied in line %d.", label, labels.get(label)));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      labels.put(label, lineNumber);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      Mnemonic mnemonic = getMnemonic(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (mnemonic != null) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        lineNumber++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mnemonics.add(mnemonic);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static void parseLine(int srcLineNumber, String line) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (line.startsWith(":")) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			String label = getLabel(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (labels.containsKey(label)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				throw new SyntaxError(srcLineNumber, String.format("Label \"%s\" already definied in line %d.", label, labels.get(label)));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			labels.put(label, lineNumber);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Mnemonic mnemonic = getMnemonic(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (mnemonic != null) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				lineNumber++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				mnemonics.add(mnemonic);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static Mnemonic getMnemonic(String line) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    String newLine = stripComments(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (StringUtils.isNotEmpty(newLine)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      Mnemonic mnemonic = MnemonicFactory.getMnemonic(newLine, srcLineNumber);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return mnemonic;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static Mnemonic getMnemonic(String line) throws SyntaxError {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		String newLine = stripComments(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (StringUtils.isNotEmpty(newLine)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Mnemonic mnemonic = MnemonicFactory.getMnemonic(newLine, srcLineNumber);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return mnemonic;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static String stripComments(String line) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (line.indexOf("*/") >= 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      inBlockComment = false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (inBlockComment) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (line.indexOf(";") >= 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      line = line.substring(0, line.indexOf(";")).trim();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return line;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (line.startsWith("/*")) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      inBlockComment = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return line.trim();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static String stripComments(String line) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (line.indexOf("*/") >= 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inBlockComment = false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (inBlockComment) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (line.indexOf(";") >= 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			line = line.substring(0, line.indexOf(";")).trim();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return line;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (line.startsWith("/*")) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inBlockComment = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return null;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return line.trim();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static String getLabel(String line) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    line = stripComments(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return line;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static String getLabel(String line) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		line = stripComments(line);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return line;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private static void showHelp() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.out.println("usage SPSAssembler <sorucefile> [<destination>]");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		System.exit(0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private static void showHelp() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.out.println("usage SPSAssembler <sorucefile> [<destination>]");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    System.exit(0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }
 
			 |