^C status wont spill into the next round|memvwr

This commit is contained in:
minjaesong
2020-06-17 09:36:34 +09:00
parent 8b9a16bbd1
commit fe6475d322
8 changed files with 177 additions and 24 deletions

View File

@@ -39,6 +39,11 @@ con.hiteof = function() { // ^D
sys.poke(-40, 1);
return (sys.peek(-41) == 32 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
};
con.resetkeybuf = function() {
sys.poke(-40, 0);
sys.poke(-41, 0); sys.poke(-42, 0); sys.poke(-43, 0); sys.poke(-44, 0);
sys.poke(-45, 0); sys.poke(-46, 0); sys.poke(-47, 0); sys.poke(-48, 0);
};
con.color_fore = function(n) { // 0..7; -1 for transparent
if (n < 0)
print(String.fromCharCode(27,91)+"38;5;255m");

View File

@@ -1 +1,31 @@
con.move(1,1);
println("TERRAN Megatrends inc.");
//println("Main RAM:"+(system.maxmem() >> 10)+" KBytes");
var memptr = 0;
var memtestptn = [0xAA,0x55,0xAA,0x55 , 0x00,0xFF,0x00,0xFF , 0x01,0x02,0x04,0x08 , 0x10,0x20,0x40,0x80];
try {
while (memptr < (8 << 20)) {
// just print a number
con.move(2,1);
print(memptr >> 10);
// perform memory test
memtestptn.forEach(function(v,i,arr) {
sys.poke(memptr + i, v);
if (v != sys.peek(memptr + i)) throw "Memory Error";
});
memptr += memtestptn.length;
}
}
catch (e) {
if (e == "Memory Error") {
println(" Memory Error");
}
else {
println(" KB OK");
}
}
con.move(4,1);

View File

@@ -18,14 +18,14 @@ var prompt = "Ok";
var lang = {};
lang.badNumberFormat = "Illegal number format";
lang.badOperatorFormat = "Illegal number format";
lang.badOperatorFormat = "Illegal operator format";
lang.badFunctionCallFormat = "Illegal function call";
lang.unmatchedBrackets = "Unmatched brackets";
lang.syntaxfehler = function(line, reason) {
return "Syntax error" + ((line !== undefined) ? (" in "+line) : "") + (reason !== undefined) ? (": "+reason) : "";
return "Syntax error" + ((line !== undefined) ? (" in "+line) : "") + ((reason !== undefined) ? (": "+reason) : "");
};
lang.illegalType = function(line) { return "Type mismatch" + (line !== undefined) ? (" in "+line) : ""; };
lang.refError = function(line) { return "Unresolved reference" + (line !== undefined) ? (" in "+line) : ""; };
lang.illegalType = function(line) { return "Type mismatch" + ((line !== undefined) ? (" in "+line) : ""); };
lang.refError = function(line) { return "Unresolved reference" + ((line !== undefined) ? (" in "+line) : ""); };
Object.freeze(lang);
function getUsedMemSize() {
@@ -145,6 +145,16 @@ basicInterpreterStatus.builtin = {
basicInterpreterStatus.variables[parsed.name] = new BasicVar(rh, (parsed.type === undefined) ? "float" : parsed.type);
},
"==" : function(lnum, args) {
if (args.length != 2) throw lang.syntaxfehler(lnum);
var lh = resolve(args[0]);
var rh = resolve(args[1]);
if (lh === undefined || rh === undefined) throw lang.refError(lnum);
return (lh == rh);
},
"UNARYMINUS" : function(lnum, args) {
if (args.length != 1) throw lang.syntaxfehler(lnum);
@@ -1074,13 +1084,18 @@ basicFunctions._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
serial.println(recWedge+"fn call args: "+(args.map(function(it) { return it.type+" "+it.value; })).join(", "));
}
var funcCallResult = func(lnum, args);
try {
var funcCallResult = func(lnum, args);
return new SyntaxTreeReturnObj(
JStoBASICtype(funcCallResult),
funcCallResult,
(basicFunctions._gotoCmds[funcName] !== undefined) ? funcCallResult : lnum + 1
);
return new SyntaxTreeReturnObj(
JStoBASICtype(funcCallResult),
funcCallResult,
(basicFunctions._gotoCmds[funcName] !== undefined) ? funcCallResult : lnum + 1
);
}
catch (_) {
throw lang.syntaxfehler(lnum, funcName + " is not defined");
}
}
else if (syntaxTree.type == "number") {
if (_debugExec) serial.println(recWedge+"number");
@@ -1205,6 +1220,7 @@ basicFunctions.run = function(args) { // RUN function
break;
}
} while (linenumber < cmdbuf.length)
con.resetkeybuf();
};
Object.freeze(basicFunctions);
while (!tbasexit) {
@@ -1229,4 +1245,4 @@ while (!tbasexit) {
}
println(prompt);
}
}
}