Re: Adding assembler code to Lua programs

  • From: Sean Conner <sean@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 4 Mar 2014 14:34:59 -0500

It was thus said that the Great Konstantin Olkhovskiy once stated:
> 
> In order to overcome this limitation, you can require dynasm.lua, make it
> produce a string with C code, add required bits and pieces and use TinyCC
> [2] to compile the resulting code on the fly. TinyCC does not do any
> sophisticated optimizations, but it does compile really fast and is tiny,
> which fits this task.

  I do have Lua bindings for TCC:

        https://github.com/spc476/lua-conmanorg

  specifically:

        https://github.com/spc476/lua-conmanorg/blob/master/src/tcc.c
        https://github.com/spc476/lua-conmanorg/blob/master/lua/cc.lua

> I have not tried this approach, but it might work and not be too ugly :) It
> could be
> even wrapped into some inline dynassembly library.
> 
> [1] https://github.com/Lupus/dynasm-example
> [2] http://bellard.org/tcc/

  -spc


Other related posts: