QuakeC Bytecode Format

Keywords: quake
Created: 2020-05-22 Fri 18:14
Table of Contents

Structure of .dat bytecode files generated by the QuakeC compiler.

Header

  • u32, version number, 6
  • u16, CRC sum
  • u16, skip, 0
  • u32 + u32, offset & size of the statement section
  • u32 + u32, offset & size of the definition section
  • u32 + u32, offset & size of the field section
  • u32 + u32, offset & size of the function section
  • u32 + u32, offset & size of the string section
  • u32 + u32, offset & size of the globals section

Statement Section

Bytecode instructions.

16 bytes per statement.

  • u32, Opcode
  • u32, argument 1
  • u32, argument 2
  • u32, argument 3

Definition Section

Used to assign types and names to globals.

8 bytes per definition:

  • u16, type
  • u16, global index
  • u32, name, index in the string table

Types:

0
void
1
string
2
float
3
vector
4
entity
5
field
6
function

In the type, the 15th bit is used mark it as global.

Field Section

8 bytes per field:

  • u16, type
  • u16, offset
  • u32, name, index in the string table

Function Section

36 bytes per function:

  • int32, entry point if positive, index the first instruction if negative, index of a builtin
  • uint32, first local
  • uint32, number of locals
  • uint32, profile, always zero
  • uint32, name, index in the string table
  • uint32, file, index in the string table
  • int32, number of arguments
  • 8 x uint8, size of arguments

String Section

A sequence of NULL-terminated strings, usually starts with 0x00 so there is an empty string at index 0x00 .

Globals Section

Assigning initial values to globals. u32 for each global.

Backlinks


Last export: 2020-07-12 Sun 22:29
This document is also available as plain text and pdf.

If you have an idea how this page could be improved or a comment send me a mail.