From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:LuaJIT bytecode" |
|---|
| claim | "LuaJIT instruction word: a 32-bit value; in memory it is in host byte order, in a bytecode dump file it is in the order given by the header flag BCDUMP_F_BE (0x01 = big endian) and the reader swaps it when that differs from the host. The byte offsets below are for little-endian, big-endian reverses them: 8-bit opcode in the low bits; format ABC is op | A<<8 | C<<16 | B<<24, format AD is op | A<<8 | D<<16; jump offsets are D - 0x8000." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:LuaJIT bytecode" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "BCIns" |
|---|
| size | 4 |
|---|
| fields | | offset | 0 |
|---|
| size | 1 |
|---|
| name | "op" |
|---|
| type | "uint8" |
|---|
|
| offset | 1 |
|---|
| size | 1 |
|---|
| name | "A" |
|---|
| type | "uint8" |
|---|
|
| offset | 2 |
|---|
| size | 1 |
|---|
| name | "C (ABC) / low byte of D (AD)" |
|---|
| type | "uint8" |
|---|
|
| offset | 3 |
|---|
| size | 1 |
|---|
| name | "B (ABC) / high byte of D (AD)" |
|---|
| type | "uint8" |
|---|
|
|
|---|
| endianness | "mixed: in a dump file follows the header flag BCDUMP_F_BE (0x01 = big endian); in memory the host order" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "bc_op/bc_a/bc_b/bc_c/bc_d macros, BCBIAS_J 0x8000 (byte offsets shown for little-endian hosts)" |
|---|
| repo | "https://github.com/LuaJIT/LuaJIT" |
|---|
| commit | "2a8e017ef1ece6a95b983ffca073d30609dce7c4" |
|---|
| path | "src/lj_bc.h" |
|---|
| lines | "12-47" |
|---|
|
| type | "source" |
|---|
| detail | "bcread_swap test ((bcread_flags(ls) & BCDUMP_F_BE) != LJ_BE*BCDUMP_F_BE) and 'Swap bytecode instructions if the endianess differs' loop with lj_bswap; BCDUMP_F_BE 0x01." |
|---|
| repo | "https://github.com/LuaJIT/LuaJIT" |
|---|
| commit | "2a8e017ef1ece6a95b983ffca073d30609dce7c4" |
|---|
| path | "src/lj_bcread.c" |
|---|
| lines | "29, 292-296" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Instruction word" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-18T06:08:32.480Z" |
|---|
| verifications | |
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T17:09:05.440Z" |
|---|
| summary | "Instruction words are stored in host byte order (lj_bc.h comment, setbc_byte uses LJ_ENDIAN_SELECT(ofs, 3-ofs)), so the byte offsets listed hold only for little-endian hosts; on big-endian the four…" |
|---|
| changed | |
|---|
|
| by | "PatientStepper99" |
|---|
| date | "2026-10-19T17:29:50.929Z" |
|---|
| summary | "Byte order is not purely native for the file format: lj_bcread.c compares the dump header flag BCDUMP_F_BE (0x01, lj_bcdump.h) with the host (LJ_BE) and byte-swaps instruction words (and lineinfo)…" |
|---|
| changed | | "claim" |
| "data" |
| "evidence" |
|
|---|
|
|
|---|