0 Members and 2 Guests are viewing this topic.
loadstring("\27\76\117\97\81\0\1\4\4\4\8\0\56\0\0\0\64\67\58\47\85\115\101\114\115\47\74\97\115\111\110\47\68\111\99\117\109\101\110\116\115\47\80\114\111\103\114\97\109\109\105\110\103\47\76\117\97\47\77\79\68\83\47\116\101\115\116\46\108\117\97\0\13\0\0\0\13\0\0\0\0\0\0\2\1\0\0\0\30\0\128\0\0\0\0\0\0\0\0\0\1\0\0\0\13\0\0\0\0\0\0\0\0\0\0\0")();
local mods = require("MODS.Current.main"); local bytecode = mods.Assemble([[; Hello_World.lasm.options 0, 0, 0, 2 ; a directive, which sets some properties, the '2' meaning MaxStackSizegetglobal 0, <'print'> ; <> denotes a constant, i've yet to bother with a directive for doing constantsloadk 1, <'Hello World!'> ; The LuaVM is register based, we put the function in one register, then arguments above itcall 0, 2, 1 ; now we call register 0, with (2-1) parameters, accepting (1-1) values backreturn 0, 0 ; and now we return]]);loadstring(bytecode)() -- turns the bytecode into a function, then we call that function>Hello World!
I am a proud cynic.
Hmm Interesting. I unfortunately no longer am into programming but I'M glad to see more programming tools coming out. For which platforms will this be?
Looks real nice. So that means another programming language for the NSpire? (And maybe anything that runs Lua?) Cool.
.options 0, 0, 0, 200 ; yay for large stacks!.macro print(s, msg){ getglobal s, <'print'> loadk s + 1, msg call s, 2, 1}print 0, <"Omnimaga :)"> ; this line will be replaced with everything in the print macro (this is good for inlining functions and stuff)return 0, 0>Omnimaga :)
How exactly would we include this stuff in the actual script, though?
local mods = require("current");local code = mods.Assemble([[; put cool Lua ASM code here]]);print(code:gsub(".", function(a) return "\\" .. a:byte() end)) -- turn the code into an escape sequence
local code = "" -- copy and paste the output of the previous script herelocal func = loadstring(code);func()
Really nice indeed.Looking forward to be able to test that project in more complex situations, once I understand how to program in this asm-looking language
require("MODS.Current.main");