mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
running program image on ram with arg passing
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
if (exec_args[1] === undefined) {
|
||||
println("Usage: jmp pointer_in_hexadecimal")
|
||||
println(" This will execute the binary image stored on the Core Memory at the given pointer.")
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
const ptr = parseInt(exec_args[1], 16)
|
||||
const magic = sys.peek(ptr)
|
||||
|
||||
if (magic != 0xA5) return 1
|
||||
|
||||
eval(sys.toObjectCode(ptr))
|
||||
@@ -26,7 +26,7 @@ if (3 == intent) {
|
||||
if (!_G.SO)
|
||||
_G.SO = {}
|
||||
|
||||
let libname = exec_args[1].split("\\").last().substringBeforeLast(".")
|
||||
let libname = infile.path.split("\\").last().substringBeforeLast(".")
|
||||
_G.SO[libname] = addrToLoad
|
||||
}
|
||||
|
||||
|
||||
18
assets/disk0/home/hdk/run.js
Normal file
18
assets/disk0/home/hdk/run.js
Normal file
@@ -0,0 +1,18 @@
|
||||
if (exec_args[1] === undefined) {
|
||||
println("Usage: run pointer_in_hexadecimal <optional args>")
|
||||
println(" This will execute the binary image stored on the Core Memory at the given pointer.")
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
const ptr = parseInt(exec_args[1], 16)
|
||||
const magic = sys.peek(ptr)
|
||||
|
||||
if (magic != 0xA5) return 1
|
||||
|
||||
|
||||
const source = sys.toObjectCode(ptr)
|
||||
const wrapper = new Function("exec_args", `const g={exec_args};with(g){${source}}`);
|
||||
const newArgs = ["@ptr:"+ptr].concat(exec_args.slice(2))
|
||||
|
||||
wrapper(newArgs)
|
||||
Reference in New Issue
Block a user