|
@@ -12,9 +12,11 @@ import javax.ws.rs.Produces;
|
|
import javax.ws.rs.WebApplicationException;
|
|
import javax.ws.rs.WebApplicationException;
|
|
import javax.ws.rs.core.MediaType;
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+
|
|
import com.codahale.metrics.annotation.Timed;
|
|
import com.codahale.metrics.annotation.Timed;
|
|
|
|
|
|
-import de.mcs.tools.sps.IntelHEXOutputter;
|
|
|
|
|
|
+import de.mcs.tools.sps.OutputFactory;
|
|
import de.mcs.tools.sps.Outputter;
|
|
import de.mcs.tools.sps.Outputter;
|
|
import de.mcs.tools.sps.SPSAssembler;
|
|
import de.mcs.tools.sps.SPSAssembler;
|
|
import de.mcs.tools.sps.exceptions.HardwareException;
|
|
import de.mcs.tools.sps.exceptions.HardwareException;
|
|
@@ -35,7 +37,9 @@ public class AsmResource {
|
|
public AsmModel assemble(AsmModel model) throws HardwareException {
|
|
public AsmModel assemble(AsmModel model) throws HardwareException {
|
|
try {
|
|
try {
|
|
HARDWARE destination = HARDWARE.HOLTEK;
|
|
HARDWARE destination = HARDWARE.HOLTEK;
|
|
-
|
|
|
|
|
|
+ if (StringUtils.isEmpty(model.getOutputformat())) {
|
|
|
|
+ model.setOutputformat("INTELHEX");
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
destination = HARDWARE.valueOf((model.getHardware().toUpperCase()));
|
|
destination = HARDWARE.valueOf((model.getHardware().toUpperCase()));
|
|
} catch (IllegalArgumentException e) {
|
|
} catch (IllegalArgumentException e) {
|
|
@@ -49,10 +53,12 @@ public class AsmResource {
|
|
List<Mnemonic> mnemonics = spsAssembler.getMnemonics();
|
|
List<Mnemonic> mnemonics = spsAssembler.getMnemonics();
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
|
|
|
- Outputter outputter = new IntelHEXOutputter();
|
|
|
|
|
|
+ Outputter outputter = OutputFactory.getOutputter(model.getOutputformat());
|
|
outputter.output(mnemonics, output);
|
|
outputter.output(mnemonics, output);
|
|
|
|
|
|
model.setHexfile(new String(output.toByteArray()));
|
|
model.setHexfile(new String(output.toByteArray()));
|
|
|
|
+ model.setMimetype(outputter.getMimeType());
|
|
|
|
+ model.setExtension(outputter.getDefaultExtension());
|
|
|
|
|
|
return model;
|
|
return model;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|