1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package Export;
- import API.ExportInterface;
- import API.Utils;
- import common.Block;
- import common.Code;
- import common.Instruction;
- import java.util.Map;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import targets.mips.Gen;
- import tools.mips.MipsSettings;
- /**
- *
- * @author EUGENIO CARVALHO
- */
- public class Simulation implements ExportInterface {
- protected MipsSettings settings;
- public Simulation(tools.mips.MipsSettings settings) {
- this.settings = settings;
- }
- @Override
- public void Exec(Code IR, Code Target) throws Exception {
- // Integer index;
- // System.out.println(Target.GData());
- String tmp, out = "";
- for (Map.Entry<String, Block> x : Target.stmts.entrySet()) {
- // System.out.println(x.getValue().Data());
- // index = 0;
- for (Instruction instr : x.getValue().Instructions()) {
- tmp = instr.G("inst.dec");
- if (tmp.equals("")) {
- continue;
- }
- out = out.concat(tmp + "\n");
- // .concat(Integer.toHexString(index))
- // .concat(":")
- // .concat(String.format("%X\n", tmp.trim()) + "\n");
- // index++;
- }
- }
- // Utils.WriteFile("\\src\\tools\\mips\\memory\\mi.memory", out);
- try {
- // Grava resutlado no arquivo de memoria do simulador
- Utils.WriteFile(settings.G("memory.instruction"), out);
- new tools.mips.MipsProcessor(settings)
- .Run()
- .Persist();
- } catch (Exception ex) {
- Logger.getLogger(Gen.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
|