running program image on ram with arg passing

This commit is contained in:
minjaesong
2025-04-20 13:29:43 +09:00
parent 111c196e7c
commit 13061bc8fa
3 changed files with 19 additions and 14 deletions

View 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)