private Error processWordDirective(String str, String sourceLineNo) { Error err = new Error(); str = MyLibrary.removeBeginningAndEndingSpace(str); Memory var10000; String[] A; int noOfWords; int i; if (str.indexOf(58) != -1) { A = str.split("[ ]*:[ ]*"); if (A.length != 2) { err = new Error("Syntax Error @ line " + sourceLineNo, 1); return err; } if (!MyLibrary.isValidNumber(A[0]) || !MyLibrary.isValidNumber(A[0])) { err = new Error("Invalid Numaric Constant in Line : " + sourceLineNo, 1); return err; } noOfWords = MyLibrary.fromStringToInt(A[0]); i = MyLibrary.fromStringToInt(A[1]); if (i * 4 > Memory.currentStackAddress - Memory.currentDynamicDataAddress) { err = new Error("Segmentation Fault ! Unable To Allocate " + i + " Words !", 1); return err; } for (int i1 = 0; i1 < i; ++i1) { var10000 = this.Mem; Memory.addWordInDynamicMemory(noOfWords); } } else if (str.indexOf(44) != -1) { A = str.split("[ ]*,[ ]*"); noOfWords = A.length; if (noOfWords * 4 > Memory.currentStackAddress - Memory.currentDynamicDataAddress) { err = new Error("Segmentation Fault ! Unable To Allocate " + noOfWords + " Words !", 1); return err; } for (i = 0; i < A.length; ++i) { if (!MyLibrary.isValidNumber(A[i])) { err = new Error("Invalid Numaric Constant in Line : " + sourceLineNo, 1); return err; } var10000 = this.Mem; Memory.addWordInDynamicMemory(MyLibrary.fromStringToInt(A[i])); } } else { if (!MyLibrary.isValidNumber(str)) { err = new Error("Invalid Numaric Constant in Line : " + sourceLineNo, 1); return err; } var10000 = this.Mem; Memory.addWordInDynamicMemory(MyLibrary.fromStringToInt(str)); } return err; }
private Error storeAllChars(String str) { Error err = new Error(); int len = str.length(); for (int i = 1; i < len - 1; ++i) { if (str.charAt(i) == 92) { ++i; if (str.charAt(i) == 98) { Memory.addByteInDynamicMemory(8); } else if (str.charAt(i) == 116) { Memory.addByteInDynamicMemory(9); } else if (str.charAt(i) == 110) { Memory.addByteInDynamicMemory(10); } else if (str.charAt(i) == 102) { Memory.addByteInDynamicMemory(12); } else if (str.charAt(i) == 114) { Memory.addByteInDynamicMemory(13); } else if (str.charAt(i) == 34) { Memory.addByteInDynamicMemory(34); } else if (str.charAt(i) == 39) { Memory.addByteInDynamicMemory(39); } else if (str.charAt(i) == 92) { Memory.addByteInDynamicMemory(92); } } else { Memory.addByteInDynamicMemory(str.charAt(i)); } } return err; }
private Error processAsciizDirective(String str, String sourceLineNo) { new Error(); str = MyLibrary.removeBeginningAndEndingSpace(str); Error err; if (!this.isValidString(str)) { err = new Error("Invalid String Constant in line no " + sourceLineNo + " !", 1); return err; } else { err = this.storeAllChars(str); Memory.addByteInDynamicMemory(10); return err; } }
private Error processSpaceDirective(String str, String sourceLineNo) { Error err = new Error(); str = MyLibrary.removeBeginningAndEndingSpace(str); if (!MyLibrary.isValidNumber(str)) { err = new Error("Invalid Numaric Constant in Line : " + sourceLineNo, 1); return err; } else { int numBytes = MyLibrary.fromStringToInt(str); if (numBytes > Memory.currentStackAddress - Memory.currentDynamicDataAddress) { err = new Error("Segmentation Fault ! Unable To Allocate " + numBytes + " Bytes !", 1); return err; } else { for (int i = 0; i < numBytes; ++i) { Memory var10000 = this.Mem; Memory.addByteInDynamicMemory(0); } return err; } } }
private Error processDataSection() { Error err = new Error(); for (int i = 0; i < this.sourceOfDataSection.size(); ++i) { String str = (String) this.sourceOfDataSection.get(i); if (this.doesStartWithLevel(str)) { String levelName = this.getLevelName(str); Memory var10000 = this.Mem; Memory.setBeginingAddressOfWord(levelName); err = this.processDirectives(str.substring(levelName.length() + 1), "\n\t" + str); } else { err = this.processDirectives(str, "\n\t" + str); } if (!err.isOk()) { break; } } return err; }