Wilfried Klaas 6 лет назад
Родитель
Сommit
90adbac5eb

+ 1 - 1
.classpath

@@ -24,7 +24,7 @@
 			<attribute name="maven.pomderived" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
 		<attributes>
 			<attribute name="module" value="true"/>
 			<attribute name="maven.pomderived" value="true"/>

+ 3 - 3
.settings/org.eclipse.jdt.core.prefs

@@ -1,9 +1,9 @@
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
-org.eclipse.jdt.core.compiler.compliance=10
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
 org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=10
+org.eclipse.jdt.core.compiler.source=1.8

+ 9 - 3
SimpleServo.tps

@@ -1,15 +1,21 @@
 :loop
+DOUT #15
+WAIT 500ms
+DOUT #0
+WAIT 200ms
+RJMP :loop
+:loop
 ; Zeilen kommentar
 NOP
-PORT 5
+DOUT #5
 WAIT 200ms
 /*
 block Kommentar
 */
-PORT 0x0F
+DOUT #0x0F
 WAIT 200ms  ; inline Kommentar
 NOP
-LDI 0x04
+LDA 0x04
 MOV a, B
 DOUT
 DOUT 3

+ 153 - 0
dependency-reduced-pom.xml

@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>de.mcs.tools.sps</groupId>
+  <artifactId>SPSEmulator</artifactId>
+  <name>${project.groupId}:${project.artifactId}</name>
+  <version>0.0.1-SNAPSHOT</version>
+  <description>SPS Emulator wirtten in java.</description>
+  <url>http://www.wk-music.de</url>
+  <developers>
+    <developer>
+      <name>Wilfried Klaas</name>
+      <email>w.klaas@gmx.de</email>
+      <organization>MCS</organization>
+      <organizationUrl>http://www.wk-music.de</organizationUrl>
+    </developer>
+  </developers>
+  <licenses>
+    <license>
+      <name>The Apache License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+    </license>
+  </licenses>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.3</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.19.1</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-surefire-provider</artifactId>
+            <version>1.1.0</version>
+          </dependency>
+          <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>5.1.0</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.6</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>de.mcs.tools.sps.SPSAssembler</mainClass>
+              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+            </manifest>
+            <manifestEntries>
+              <Build-Time>${maven.build.timestamp}</Build-Time>
+              <Application-Name>SPSTools</Application-Name>
+              <Application-Update-Id>72</Application-Update-Id>
+              <Application-Update-Url>http\://wkla.no-ip.biz/downloader/version.php?ID\=73</Application-Update-Url>
+              <Application-Url>http\://wkla.no-ip.biz/</Application-Url>
+              <Implementation-Vendor>MCS, Media Computer Software</Implementation-Vendor>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.4.1</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>com.akathist.maven.plugins.launch4j</groupId>
+        <artifactId>launch4j-maven-plugin</artifactId>
+        <version>1.7.24</version>
+        <executions>
+          <execution>
+            <id>l4j-clui</id>
+            <phase>package</phase>
+            <goals>
+              <goal>launch4j</goal>
+            </goals>
+            <configuration>
+              <dontWrapJar>false</dontWrapJar>
+              <headerType>console</headerType>
+              <jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar>
+              <outfile>${project.build.directory}/MCSSPSTools.exe</outfile>
+              <downloadUrl>http://java.com/download</downloadUrl>
+              <icon>src\main\resources\MSA.ico</icon>
+              <jre>
+                <path>/jre</path>
+                <minVersion>1.8.0</minVersion>
+                <jdkPreference>jreOnly</jdkPreference>
+              </jre>
+              <versionInfo>
+                <fileVersion>1.0.0.0</fileVersion>
+                <txtFileVersion>${project.version}</txtFileVersion>
+                <fileDescription>${project.name}</fileDescription>
+                <copyright>2018 MCS</copyright>
+                <productVersion>1.0.0.0</productVersion>
+                <txtProductVersion>1.0.0.0</txtProductVersion>
+                <productName>${project.name}</productName>
+                <companyName>MCS</companyName>
+                <internalName>MCSSPSTools</internalName>
+                <originalFilename>MCSSPSTools.exe</originalFilename>
+              </versionInfo>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.1.0</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>apiguardian-api</artifactId>
+          <groupId>org.apiguardian</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>opentest4j</artifactId>
+          <groupId>org.opentest4j</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-platform-commons</artifactId>
+          <groupId>org.junit.platform</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  <properties>
+    <maven.build.timestamp.format>dd.mm.yyyy HH:mm</maven.build.timestamp.format>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <jackson.version>2.8.5</jackson.version>
+    <timestamp>${maven.build.timestamp}</timestamp>
+  </properties>
+</project>
+

+ 184 - 159
pom.xml

@@ -1,171 +1,196 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>de.mcs.tools.sps</groupId>
   <artifactId>SPSEmulator</artifactId>
   <version>0.0.1-SNAPSHOT</version>
-  <name>SPS_Emulator</name>
+  <name>${project.groupId}:${project.artifactId}</name>
   <url>http://www.wk-music.de</url>
   <description>SPS Emulator wirtten in java.</description>
-	<licenses>
-		<license>
-			<name>The Apache License, Version 2.0</name>
-			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-		</license>
-	</licenses>
+  <licenses>
+    <license>
+      <name>The Apache License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+    </license>
+  </licenses>
 
-	<developers>
-		<developer>
-			<name>Wilfried Klaas</name>
-			<email>w.klaas@gmx.de</email>
-			<organization>MCS</organization>
-			<organizationUrl>http://www.wk-music.de</organizationUrl>
-		</developer>
-	</developers>
+  <developers>
+    <developer>
+      <name>Wilfried Klaas</name>
+      <email>w.klaas@gmx.de</email>
+      <organization>MCS</organization>
+      <organizationUrl>http://www.wk-music.de</organizationUrl>
+    </developer>
+  </developers>
 
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<timestamp>${maven.build.timestamp}</timestamp>
-		<maven.build.timestamp.format>dd.mm.yyyy HH:mm</maven.build.timestamp.format>
-		<jackson.version>2.8.5</jackson.version>
-	</properties>
-	<build>
-		<plugins>
-			<plugin>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<version>3.3</version>
-				<configuration>
-					<source>1.8</source>
-					<target>1.8</target>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-jar-plugin</artifactId>
-				<version>2.6</version>
-				<configuration>
-					<archive>
-						<manifest>
-							<mainClass>de.mcs.tools.addsub.Main</mainClass>
-							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
-							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
-						</manifest>
-						<manifestEntries>
-							<Build-Time>${maven.build.timestamp}</Build-Time>
-							<Application-Name>MCSAddSub</Application-Name>
-							<Application-Update-Id>72</Application-Update-Id>
-							<Application-Update-Url>http\://wkla.no-ip.biz/downloader/version.php?ID\=72</Application-Update-Url>
-							<Application-Url>http\://wkla.no-ip.biz/</Application-Url>
-							<Implementation-Vendor>MCS, Media Computer Software</Implementation-Vendor>
-						</manifestEntries>
-					</archive>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-shade-plugin</artifactId>
-				<version>2.4.1</version>
-				<executions>
-					<execution>
-						<phase>package</phase>
-						<goals>
-							<goal>shade</goal>
-						</goals>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <timestamp>${maven.build.timestamp}</timestamp>
+    <maven.build.timestamp.format>dd.mm.yyyy HH:mm</maven.build.timestamp.format>
+    <jackson.version>2.8.5</jackson.version>
+  </properties>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.3</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.19.1</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-surefire-provider</artifactId>
+            <version>1.1.0</version>
+          </dependency>
+          <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>5.1.0</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.6</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>de.mcs.tools.sps.SPSAssembler</mainClass>
+              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+            </manifest>
+            <manifestEntries>
+              <Build-Time>${maven.build.timestamp}</Build-Time>
+              <Application-Name>SPSTools</Application-Name>
+              <Application-Update-Id>72</Application-Update-Id>
+              <Application-Update-Url>http\://wkla.no-ip.biz/downloader/version.php?ID\=73</Application-Update-Url>
+              <Application-Url>http\://wkla.no-ip.biz/</Application-Url>
+              <Implementation-Vendor>MCS, Media Computer Software</Implementation-Vendor>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.4.1</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
 						<!-- <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
 							<mainClass></mainClass> </transformer> </transformers> </configuration> -->
-					</execution>
-				</executions>
-			</plugin>
-			<plugin>
-				<groupId>com.akathist.maven.plugins.launch4j</groupId>
-				<artifactId>launch4j-maven-plugin</artifactId>
-				<version>1.7.8</version>
-				<executions>
-					<execution>
-						<id>l4j-clui</id>
-						<phase>package</phase>
-						<goals>
-							<goal>launch4j</goal>
-						</goals>
-						<configuration>
-							<dontWrapJar>false</dontWrapJar>
-							<headerType>console</headerType>
-							<jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar>
-							<outfile>${project.build.directory}/MCSAddSub.exe</outfile>
-							<downloadUrl>http://java.com/download</downloadUrl>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>com.akathist.maven.plugins.launch4j</groupId>
+        <artifactId>launch4j-maven-plugin</artifactId>
+        <version>1.7.24</version>
+        <executions>
+          <execution>
+            <id>l4j-clui</id>
+            <phase>package</phase>
+            <goals>
+              <goal>launch4j</goal>
+            </goals>
+            <configuration>
+              <dontWrapJar>false</dontWrapJar>
+              <headerType>console</headerType>
+              <jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar>
+              <outfile>${project.build.directory}/MCSSPSTools.exe</outfile>
+              <downloadUrl>http://java.com/download</downloadUrl>
 							<!-- <classPath> <mainClass>com.howtodoinjava.ApplicationMain</mainClass> <preCp>anything</preCp> </classPath> -->
-							<icon>src\main\resources\MSA.ico</icon>
-							<jre>
-								<minVersion>1.8.0</minVersion>
-								<jdkPreference>jreOnly</jdkPreference>
-							</jre>
-							<versionInfo>
-								<fileVersion>1.0.0.0</fileVersion>
-								<txtFileVersion>${project.version}</txtFileVersion>
-								<fileDescription>${project.name}</fileDescription>
-								<copyright>2018 MCS</copyright>
-								<productVersion>1.0.0.0</productVersion>
-								<txtProductVersion>1.0.0.0</txtProductVersion>
-								<productName>${project.name}</productName>
-								<companyName>MCS</companyName>
-								<internalName>MCSAddSub</internalName>
-								<originalFilename>MCSAddSub.exe</originalFilename>
-							</versionInfo>
-						</configuration>
-					</execution>
-				</executions>
-			</plugin>
-		</plugins>
-	</build>
-	<dependencies>
-		<dependency>
-			<groupId>net.sourceforge.jmeasurement2</groupId>
-			<artifactId>MCSUtils</artifactId>
-			<version>1.0.150</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-io</groupId>
-			<artifactId>commons-io</artifactId>
-			<version>2.5</version>
-		</dependency>
-		<dependency>
-			<groupId>net.sourceforge.jmeasurement2</groupId>
-			<artifactId>JMeasurement</artifactId>
-			<version>1.1.225</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-core</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-annotations</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-databind</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.dataformat</groupId>
-			<artifactId>jackson-dataformat-yaml</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<version>1.2.17</version>
-		</dependency>
-		<dependency>
-			<groupId>com.martiansoftware</groupId>
-			<artifactId>jsap</artifactId>
-			<version>2.1</version>
-		</dependency>
-		<dependency>
-		  <groupId>org.apache.commons</groupId>
-		  <artifactId>commons-lang3</artifactId>
-		  <version>3.4</version>
-		</dependency>
-	</dependencies>
+              <icon>src\main\resources\MSA.ico</icon>
+              <jre>
+              <path>/jre</path>
+                <minVersion>1.8.0</minVersion>
+                <jdkPreference>jreOnly</jdkPreference>
+              </jre>
+              <versionInfo>
+                <fileVersion>1.0.0.0</fileVersion>
+                <txtFileVersion>${project.version}</txtFileVersion>
+                <fileDescription>${project.name}</fileDescription>
+                <copyright>2018 MCS</copyright>
+                <productVersion>1.0.0.0</productVersion>
+                <txtProductVersion>1.0.0.0</txtProductVersion>
+                <productName>${project.name}</productName>
+                <companyName>MCS</companyName>
+                <internalName>MCSSPSTools</internalName>
+                <originalFilename>MCSSPSTools.exe</originalFilename>
+              </versionInfo>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>net.sourceforge.jmeasurement2</groupId>
+      <artifactId>MCSUtils</artifactId>
+      <version>1.0.150</version>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>2.5</version>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.jmeasurement2</groupId>
+      <artifactId>JMeasurement</artifactId>
+      <version>1.1.225</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-annotations</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.dataformat</groupId>
+      <artifactId>jackson-dataformat-yaml</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.17</version>
+    </dependency>
+    <dependency>
+      <groupId>com.martiansoftware</groupId>
+      <artifactId>jsap</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.4</version>
+    </dependency>
+  </dependencies>
 </project>

+ 6 - 2
src/main/java/de/mcs/tools/sps/SPSAssembler.java

@@ -90,7 +90,7 @@ public class SPSAssembler {
       List<String> sourceFile = Files.readAllLines(source.toPath(), Charset.forName("UTF-8"));
       for (String line : sourceFile) {
         srcLineNumber++;
-        parseLine(line);
+        parseLine(srcLineNumber, line);
       }
 
     } catch (SyntaxError e) {
@@ -131,9 +131,13 @@ public class SPSAssembler {
     output.close();
   }
 
-  private static void parseLine(String line) throws SyntaxError {
+  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);

+ 70 - 6
src/main/java/de/mcs/tools/sps/mnemonic/LDA.java

@@ -37,9 +37,16 @@ public class LDA extends AbstractMnemonic implements Mnemonic {
 
   byte value;
 
+  enum INPUTSOURCE {
+    DIRECT, DIGITAL, ANALOG, RC
+  };
+
+  INPUTSOURCE inputSource;
+
   public LDA(String line) throws SyntaxError {
     super(line);
     value = 0;
+    inputSource = INPUTSOURCE.DIRECT;
   }
 
   @Override
@@ -48,17 +55,74 @@ public class LDA extends AbstractMnemonic implements Mnemonic {
       throw new SyntaxError(getLineNumber(),
           String.format("missing argument for %s.", this.getClass().getSimpleName()));
     }
-    int myValue = getArgumentAsNumber();
-    if ((myValue < 0) || (myValue > 15)) {
-      throw new IllegalArgument(getLineNumber(),
-          String.format("argument %s is not in range 0..15 for %s.", getArgument(), this.getClass().getSimpleName()));
+    if (!getArgument().startsWith("#")) {
+      String inputString = getArgument().toUpperCase();
+      if (inputString.startsWith("DIN")) {
+        inputSource = INPUTSOURCE.DIGITAL;
+        if ("DIN".equalsIgnoreCase(inputString)) {
+          value = 0;
+        } else {
+          int myValue = Integer.parseInt(inputString.substring(3));
+          if ((myValue < 1) || (myValue > 4)) {
+            throw new IllegalArgument(getLineNumber(), String.format("argument %s is not in range DIN1..4 for %s.",
+                getArgument(), this.getClass().getSimpleName()));
+          }
+          value = (byte) (myValue & 0xFF);
+        }
+      } else if (inputString.startsWith("ADC")) {
+        inputSource = INPUTSOURCE.ANALOG;
+        int myValue = 0;
+        try {
+          myValue = Integer.parseInt(inputString.substring(3));
+        } catch (NumberFormatException e) {
+        }
+        if ((myValue < 1) || (myValue > 2)) {
+          throw new IllegalArgument(getLineNumber(), String.format("argument %s is not in range ADC1..4 for %s.",
+              getArgument(), this.getClass().getSimpleName()));
+        }
+        value = (byte) ((myValue - 1) & 0xFF);
+      } else if (inputString.startsWith("RC")) {
+        inputSource = INPUTSOURCE.RC;
+        int myValue = 0;
+        try {
+          myValue = Integer.parseInt(inputString.substring(2));
+        } catch (NumberFormatException e) {
+        }
+        if ((myValue < 1) || (myValue > 2)) {
+          throw new IllegalArgument(getLineNumber(), String.format("argument %s is not in range RC1..4 for %s.",
+              getArgument(), this.getClass().getSimpleName()));
+        }
+        value = (byte) ((myValue - 1) & 0xFF);
+      } else {
+        throw new IllegalArgument(getLineNumber(),
+            String.format("argument %s sould start with \"#\".", getArgument(), this.getClass().getSimpleName()));
+      }
+    } else {
+      String argument = getArgument();
+      argument = argument.substring(1);
+      int myValue = getArgumentAsNumber(argument);
+      if ((myValue < 0) || (myValue > 15)) {
+        throw new IllegalArgument(getLineNumber(),
+            String.format("argument %s is not in range 0..15 for %s.", getArgument(), this.getClass().getSimpleName()));
+      }
+      value = (byte) (myValue & 0xFF);
     }
-    value = (byte) (myValue & 0xFF);
   }
 
   @Override
   public int getByte() {
-    return 0x40 + value;
+    switch (inputSource) {
+    case DIRECT:
+      return 0x40 + value;
+    case DIGITAL:
+      return 0x64 + value;
+    case ANALOG:
+      return 0x69 + value;
+    case RC:
+      return 0x6b + value;
+    default:
+      return 0x40 + value;
+    }
   }
 
   @Override

+ 0 - 73
src/main/java/de/mcs/tools/sps/mnemonic/PORT.java

@@ -1,73 +0,0 @@
-/**
- * MCS Media Computer Software
- * Copyright 2018 by Wilfried Klaas
- * Project: SPSEmulator
- * File: Not.java
- * EMail: W.Klaas@gmx.de
- * Created: 25.11.2018 wklaa_000
- * 
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>
- */
-package de.mcs.tools.sps.mnemonic;
-
-import org.apache.commons.lang3.StringUtils;
-
-import de.mcs.tools.sps.exceptions.IllegalArgument;
-import de.mcs.tools.sps.exceptions.SyntaxError;
-
-/**
- * PORT: output to the digital port. Argument should be in range 0..15.
- * 
- * @author wklaa_000
- *
- */
-public class PORT extends AbstractMnemonic implements Mnemonic {
-
-  byte output;
-
-  public PORT(String line) throws SyntaxError {
-    super(line);
-    output = 0;
-  }
-
-  @Override
-  public void checkArgument() throws SyntaxError {
-    if (StringUtils.isEmpty(getArgument())) {
-      throw new SyntaxError(getLineNumber(),
-          String.format("missing argument for %s.", this.getClass().getSimpleName()));
-    }
-    int value = getArgumentAsNumber();
-    if ((value < 0) || (value > 15)) {
-      throw new IllegalArgument(getLineNumber(),
-          String.format("argument %s is not in range 0..15 for %s.", getArgument(), this.getClass().getSimpleName()));
-    }
-    output = (byte) (value & 0xFF);
-  }
-
-  @Override
-  public int getByte() {
-    return 0x10 + output;
-  }
-
-  @Override
-  public boolean isUsingPage() {
-    return false;
-  }
-
-  @Override
-  public boolean hasArgument() {
-    return true;
-  }
-
-}

BIN
src/main/resources/MSA.ico


+ 109 - 9
src/test/java/de/mcs/tools/sps/mnemonic/TestLDA.java

@@ -1,7 +1,7 @@
 package de.mcs.tools.sps.mnemonic;
 
-import static org.junit.Assert.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Assertions;
@@ -13,21 +13,24 @@ import de.mcs.tools.sps.exceptions.SyntaxError;
 class TestLDA {
 
   private static final int BYTE_VALUE = 0x40;
+  private static final int BYTE_VALUE_DIN = 0x64;
+  private static final int BYTE_VALUE_ADC = 0x69;
+  private static final int BYTE_VALUE_RC = 0x6B;
   private final String MNEMONIC = "LDA";
 
   @Test
   void testMnemonic() throws SyntaxError {
-    LDA mnemonic = new LDA(MNEMONIC + " 0x00");
+    LDA mnemonic = new LDA(MNEMONIC + " #0x00");
     mnemonic.checkArgument();
     assertEquals(BYTE_VALUE, mnemonic.getByte());
     assertTrue(mnemonic.hasArgument());
     assertFalse(mnemonic.isUsingPage());
 
-    mnemonic = new LDA(MNEMONIC + " 0x01");
+    mnemonic = new LDA(MNEMONIC + " #0x01");
     mnemonic.checkArgument();
     assertEquals(BYTE_VALUE + 0x01, mnemonic.getByte());
 
-    mnemonic = new LDA(MNEMONIC + " 0x0f");
+    mnemonic = new LDA(MNEMONIC + " #0x0f");
     mnemonic.checkArgument();
     assertEquals(BYTE_VALUE + 0x0f, mnemonic.getByte());
 
@@ -37,27 +40,124 @@ class TestLDA {
     });
 
     Assertions.assertThrows(IllegalArgument.class, () -> {
-      LDA mnemonic1 = new LDA(MNEMONIC + " 0x10");
+      LDA mnemonic1 = new LDA(MNEMONIC + " 0x01");
+      mnemonic1.checkArgument();
+    });
+
+    Assertions.assertThrows(IllegalArgument.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " #0x10");
+      mnemonic1.checkArgument();
+    });
+  }
+
+  @Test
+  void testMnemonicDigital() throws SyntaxError {
+    LDA mnemonic = new LDA(MNEMONIC + " DIN");
+    mnemonic.checkArgument();
+    assertEquals(BYTE_VALUE_DIN, mnemonic.getByte());
+    assertTrue(mnemonic.hasArgument());
+    assertFalse(mnemonic.isUsingPage());
+
+    mnemonic = new LDA(MNEMONIC + " DIN1");
+    mnemonic.checkArgument();
+    assertEquals(BYTE_VALUE_DIN + 0x01, mnemonic.getByte());
+
+    mnemonic = new LDA(MNEMONIC + " DIN4");
+    mnemonic.checkArgument();
+    assertEquals(BYTE_VALUE_DIN + 0x04, mnemonic.getByte());
+
+    Assertions.assertThrows(SyntaxError.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " DOUT");
+      mnemonic1.checkArgument();
+    });
+
+    Assertions.assertThrows(IllegalArgument.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " DIN5");
+      mnemonic1.checkArgument();
+    });
+  }
+
+  @Test
+  void testMnemonicAnalog() throws SyntaxError {
+    LDA mnemonic = new LDA(MNEMONIC + " ADC1");
+    mnemonic.checkArgument();
+    assertEquals(BYTE_VALUE_ADC, mnemonic.getByte());
+    assertTrue(mnemonic.hasArgument());
+    assertFalse(mnemonic.isUsingPage());
+
+    mnemonic = new LDA(MNEMONIC + " ADC2");
+    mnemonic.checkArgument();
+    assertEquals(BYTE_VALUE_ADC + 0x01, mnemonic.getByte());
+
+    Assertions.assertThrows(SyntaxError.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " ADC");
+      mnemonic1.checkArgument();
+    });
+
+    Assertions.assertThrows(SyntaxError.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " ADC0");
+      mnemonic1.checkArgument();
+    });
+
+    Assertions.assertThrows(SyntaxError.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " ADC3");
+      mnemonic1.checkArgument();
+    });
+  }
+
+  @Test
+  void testMnemonicReceiver() throws SyntaxError {
+    LDA mnemonic = new LDA(MNEMONIC + " RC1");
+    mnemonic.checkArgument();
+    assertEquals(BYTE_VALUE_RC, mnemonic.getByte());
+    assertTrue(mnemonic.hasArgument());
+    assertFalse(mnemonic.isUsingPage());
+
+    mnemonic = new LDA(MNEMONIC + " RC2");
+    mnemonic.checkArgument();
+    assertEquals(BYTE_VALUE_RC + 0x01, mnemonic.getByte());
+
+    Assertions.assertThrows(SyntaxError.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " RC");
+      mnemonic1.checkArgument();
+    });
+
+    Assertions.assertThrows(SyntaxError.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " RC0");
+      mnemonic1.checkArgument();
+    });
+
+    Assertions.assertThrows(SyntaxError.class, () -> {
+      LDA mnemonic1 = new LDA(MNEMONIC + " RC3");
       mnemonic1.checkArgument();
     });
   }
 
   @Test
   void testMnemonicFactory() throws SyntaxError {
-    Mnemonic mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0x00", 0);
+    Mnemonic mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " #0x00", 0);
+    assertEquals(LDA.class, mnemonic.getClass());
+
+    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " DIN", 0);
+    assertEquals(LDA.class, mnemonic.getClass());
+
+    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " ADC1", 0);
+    assertEquals(LDA.class, mnemonic.getClass());
+
+    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " RC2", 0);
     assertEquals(LDA.class, mnemonic.getClass());
 
     Assertions.assertThrows(SyntaxError.class, () -> {
       MnemonicFactory.getMnemonic(MNEMONIC, 0);
     });
 
-    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0x02", 0);
+    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " #0x02", 0);
     assertEquals(BYTE_VALUE + 0x02, mnemonic.getByte());
 
-    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 12", 0);
+    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " #12", 0);
     assertEquals(BYTE_VALUE + 12, mnemonic.getByte());
 
-    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0b00001010", 0);
+    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " #0b00001010", 0);
     assertEquals(BYTE_VALUE + 10, mnemonic.getByte());
 
   }

+ 0 - 65
src/test/java/de/mcs/tools/sps/mnemonic/TestPORT.java

@@ -1,65 +0,0 @@
-package de.mcs.tools.sps.mnemonic;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import de.mcs.tools.sps.exceptions.IllegalArgument;
-import de.mcs.tools.sps.exceptions.SyntaxError;
-
-class TestPORT {
-
-  private static final int BYTE_VALUE = 0x10;
-  private final String MNEMONIC = "PORT";
-
-  @Test
-  void testMnemonic() throws SyntaxError {
-    PORT mnemonic = new PORT(MNEMONIC + " 0x00");
-    mnemonic.checkArgument();
-    assertEquals(BYTE_VALUE, mnemonic.getByte());
-    assertTrue(mnemonic.hasArgument());
-    assertFalse(mnemonic.isUsingPage());
-
-    mnemonic = new PORT(MNEMONIC + " 0x01");
-    mnemonic.checkArgument();
-    assertEquals(BYTE_VALUE + 1, mnemonic.getByte());
-
-    mnemonic = new PORT(MNEMONIC + " 0x0f");
-    mnemonic.checkArgument();
-    assertEquals(BYTE_VALUE + 0x0f, mnemonic.getByte());
-
-    Assertions.assertThrows(SyntaxError.class, () -> {
-      PORT mno1 = new PORT(MNEMONIC);
-      mno1.checkArgument();
-    });
-
-    Assertions.assertThrows(IllegalArgument.class, () -> {
-      PORT mno1 = new PORT(MNEMONIC + " 0x10");
-      mno1.checkArgument();
-    });
-  }
-
-  @Test
-  void testMnemonicFactory() throws SyntaxError {
-    Mnemonic mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0x00", 0);
-    assertEquals(PORT.class, mnemonic.getClass());
-
-    Assertions.assertThrows(SyntaxError.class, () -> {
-      MnemonicFactory.getMnemonic(MNEMONIC, 0);
-    });
-
-    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0x02", 0);
-    assertEquals(BYTE_VALUE + 0x02, mnemonic.getByte());
-
-    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 12", 0);
-    assertEquals(BYTE_VALUE + 12, mnemonic.getByte());
-
-    mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0b00001010", 0);
-    assertEquals(BYTE_VALUE + 10, mnemonic.getByte());
-
-  }
-
-}