Discussion:
[ANN] DynASM with Lua mode
Cosmin Apreutesei
2014-06-28 23:19:39 UTC
Permalink
Hi everyone,

This is a modified version of DynASM that allows generating,
compiling, and running x86 and x86-64 assembly code directly from Lua.
It also exposes the DynASM translator and linker to be used as Lua
modules.

Works with Windows, Linux and OSX, x86 and x64.

Homepage:
http://luapower.com/dynasm

Code:
https://github.com/luapower/dynasm

Changes from DynASM:
https://github.com/luapower/dynasm/compare/7d7e130...master


Enjoy!
Manoel Teixeira
2014-06-28 23:28:17 UTC
Permalink
Great!


On Sat, Jun 28, 2014 at 8:19 PM, Cosmin Apreutesei <
Post by Cosmin Apreutesei
Hi everyone,
This is a modified version of DynASM that allows generating,
compiling, and running x86 and x86-64 assembly code directly from Lua.
It also exposes the DynASM translator and linker to be used as Lua
modules.
Works with Windows, Linux and OSX, x86 and x64.
http://luapower.com/dynasm
https://github.com/luapower/dynasm
https://github.com/luapower/dynasm/compare/7d7e130...master
Enjoy!
Paulo Matias
2014-06-29 13:14:38 UTC
Permalink
This is a very interesting project and I think it will be useful for
many people, thanks for doing and sharing it!

On Sat, Jun 28, 2014 at 8:19 PM, Cosmin Apreutesei
Post by Cosmin Apreutesei
and running x86 and x86-64 assembly code directly from Lua.
What would be needed to port it to other architectures supported by
DynASM, e.g. ARM? Would following the usage of luamode in dasm_x86.lua
be enough? Maybe some of the language-dependent (C vs Lua) code output
stuff could be refactored into a separate Lua file to ease porting.
Cosmin Apreutesei
2014-06-29 20:54:24 UTC
Permalink
Post by Paulo Matias
This is a very interesting project and I think it will be useful for
many people, thanks for doing and sharing it!
Appreciated. Also, this wouldn't had been possible if DynASM itself
wouldn't had been easy to understand, thanks to Mike for that. And
thanks to Peter Cawley for the DynASM doc.

What would be needed to port it to other architectures supported by
Post by Paulo Matias
DynASM, e.g. ARM? Would following the usage of luamode in dasm_x86.lua
be enough? Maybe some of the language-dependent (C vs Lua) code output
stuff could be refactored into a separate Lua file to ease porting.
Follow this link:

https://github.com/luapower/dynasm/compare/7d7e130...master

and look at the diff for dynasm_x86.lua. IMHO the changes are small
and fairly easy to do. I don't have other platforms to test, but I'd
be glad to help someone else with questions, code review, etc.

The changes to the code need to solve two problems:
1) output Lua code (search for `luamode`)
2) reset module global state so it can be reused for multiple runs.

If you are only interested in one-shot cmdline-driven operation you
don't even have to bother with the 2nd problem, and the 1st one is
easy.
Luke Gorrie
2014-06-29 13:38:46 UTC
Permalink
I have had fantasies of exactly this :-) THANK YOU!
Post by Cosmin Apreutesei
Hi everyone,
This is a modified version of DynASM that allows generating,
compiling, and running x86 and x86-64 assembly code directly from Lua.
It also exposes the DynASM translator and linker to be used as Lua
modules.
Works with Windows, Linux and OSX, x86 and x64.
http://luapower.com/dynasm
https://github.com/luapower/dynasm
https://github.com/luapower/dynasm/compare/7d7e130...master
Enjoy!
Duncan Cross
2014-06-29 14:26:54 UTC
Permalink
On Sun, Jun 29, 2014 at 12:19 AM, Cosmin Apreutesei
Post by Cosmin Apreutesei
Hi everyone,
This is a modified version of DynASM that allows generating,
compiling, and running x86 and x86-64 assembly code directly from Lua.
Nice! What a great idea...
Post by Cosmin Apreutesei
http://luapower.com/dynasm
I noticed a (probable?) mistake at the end of the code snippet for
"funcs_x86.dasl" - there's a "]]" on its own, without any matching
"[[" earlier on.

-Duncan
Cosmin Apreutesei
2014-06-29 20:58:27 UTC
Permalink
Post by Duncan Cross
Nice! What a great idea...
Thanks.
Post by Duncan Cross
I noticed a (probable?) mistake at the end of the code snippet for
"funcs_x86.dasl" - there's a "]]" on its own, without any matching
"[[" earlier on.
Removed, thanks for spotting. Since the feedback's been great I'll add
more tutorial stuff, stay tuned.

Loading...