Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Lua Bytecode viewer

dave1707dave1707 Mod
edited January 2017 in General Posts: 7,546

Have you ever wondered what your code looks like once it's converted to Bytecode before it's executed. Here a program I wrote that allows you to view the Bytecode hex file and also view the opcode/instructions of that code. Just copy the code you want converted into the function convertToByteCode(). I have some example code already in the function to try. Once you execute the program you'll see a hex dump of the Bytecode file. If the file is longer than the screen, you can use your finger and scroll the info around. To view the opcode/instructions, slide the parameter switch for showOps to the right. If you want to print the hex file or opcode file, slide the paramete prnt to the right. Tapping either print file will copy it to the pasteboard where it can be pasted into another file. I'm not sure if I have everything correct because there wasn't much info to refer to. Near the bottom of the hex file is a comment File not formatted beyond this point, which means exactly what it says. I didn't break the file into meaningful chunks, but all the info is there. If you have a function in the code that your converting, you'll see the Bytecode information for that function in that area. It also won't appear in the opcode/instruction file. If you want to see the info for that function, you can comment out the function line and also the end line for that function. If you want to see more info on Bytecodes, see the link below that I used. It's for Lua 5.2 so it's not exactly a match for Lua 5.3 . You can use this if you ever wonder if some Lua code creates more instructions than some other similar code.

Link to Bytecode explanation.
Link to program.
Sign In or Register to comment.