1

i'd like to study assembly code from lua code. for the moment , i can get byte code with command :

luac filename.lua

I work on linux platform, how to compile it ? Should i compile it in order to study his assembly code ? how to disassemble it ?

laticoda
  • 100
  • 14
  • Do any LUA interpreters even JIT compile to native machine code at all? If they just interpret, then the only code running on the CPU is the ahead-of-time-compiled interpreter itself. (Which you can of course disasemble and/or profile with `perf record`, or just look at its source code). – Peter Cordes Mar 28 '20 at 00:55
  • 2
    You can view list of bytecode instructions: `luac -l -l -p filename.lua` or `luac -l -l -p filename.luac` There is [luac file viewer](https://lua-bytecode.github.io/) which shows a short description for every bytecode instruction. – Egor Skriptunoff Mar 28 '20 at 07:06
  • There is a [Lua compiler](http://www.chunkbake.luaforge.net/) to convert sequence of bytecode instructions to luac file. – Egor Skriptunoff Mar 28 '20 at 07:14
  • You can view the bytecode instructions through this website too: https://www.luac.nl/, with short descriptions. – Ethicist May 27 '21 at 20:20

1 Answers1

2

Stock Lua does not compile the bytecode into assembly code, it has a bytecode execution engine, the Lua virtual machine. So

Marc Balmer
  • 1,780
  • 1
  • 11
  • 18