gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl - start from the proper address
[mjc2wsl.git] / src / mjc2wsl.java
index ee36c51..917978c 100644 (file)
@@ -270,12 +270,17 @@ public class mjc2wsl{
 
        public void convertStream(InputStream ins) throws Exception{
                mainIn = ins;
-               //skip start TODO make better
-               for (int i = 0; i < 14; i++)
-                       get();
+               //process start 
+               byte m = (byte) get();
+               byte j = (byte) get();
+               if (m!='M' || j !='J') 
+                               throw new Exception("Wrong start of bytecode file");
+               int codesize = get4();
+               int numberOfWords = get4();
+               int mainAdr = get4();
                
                prl(getStandardStart());
-               prl("SKIP;\n ACTIONS A_S_start:\n A_S_start == CALL a14 END");
+               prl("SKIP;\n ACTIONS A_S_start:\n A_S_start == CALL a"+(14+mainAdr)+" END");
                int op = get();
                while (op >= 0) {
                        if (originalInComments)
@@ -408,6 +413,11 @@ public class mjc2wsl{
                        }
 
                        //TODO read, print
+                       case read: {
+                               prl("tempa := @String_To_Num(@Read_Line(Standard_Input_Port));");
+                               prl(cmdToEStack("tempa"));
+                               break;
+                       }
 
                        // the prints
                        case bprint: {
@@ -421,15 +431,22 @@ public class mjc2wsl{
                                prl("PRINT(tempb);");
                                break;
                        }
+
+                       case trap: {
+                               // TODO finish trap
+                               prl(createComment("trap not fully procesed yet"));
+                               message("trap not fully procesed yet", M_WAR);
+                               get();
+                               break;
+                       }
+                       
+       
                        default:
                                prl(createComment("unknown op error: " + op, C_ERR));
                                message("unknown op error: "+ op, M_ERR);
                                break;
                        }
 
-                       //TODO trap
-
-
                        op = get();
                        if (op >= 0)
                                prl("CALL a" + counter + " END");
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner