Keywords: pcode

Next: 4 Header Codes Up: HAFTA Overlord P-Code Definition Previous: 2 Virtual Machine Contents
Subsections

- 3.1 Version Code
- 3.2 Ola Version Code
- 3.3 Olc Version Code
- 3.4 Stack Size and Policy
- 3.5 Context Count
- 3.6 Module Table
- 3.7 P-Code Segment Table
- 3.8 The P-Code

# 3 P-Code File Format

The P-Code is stored in big-endian format on disk. It contains a version code, an assembler version code, a compiler version code, a stack size and policy, a context count, a module table, a p-code segment table, and the p-code itself.

## 3.1 Version Code

32-bit, unsigned, big-endian.

The Version Code defines the p-code version contained in the file. This document defines version 1 of the pcode.

## 3.2 Ola Version Code

32-bit, unsigned, big-endian.

The Ola Version Code indicates the version of the assembler which was used to create the file.

## 3.3 Olc Version Code

32-bit, unsigned, big-endian.

The Olc Version Code indicates the version of the compiler which was used to produce the input for the assembler.

## 3.4 Stack Size and Policy

2 16-bit, unsigned, big-endian.

The Stack Size entry (the first 16-bit field) defines what size stack to allocate upon initialization.

The Stack Policy entry (the second 16-bit field) defines what to do when the stack size is exceeded.

Currently the two policies are

- 0 - grow the stack
- 1 - die horribly

## 3.5 Context Count

32-bit, unsigned, big-endian.

The Context Count defines how many local nebuloid contexts are referenced in the pcode.

## 3.6 Module Table

8-bit, null-terminated strings, empty string terminated.

The Module Table lists the modules referenced by the p-code.

It is used to ensure that all referenced modules are present at module load time. It is also used to enumerate module names.

## 3.7 P-Code Segment Table

32-bit, unsigned, big-endian. 8-bit, null-terminated strings.

The P-Code Segment Table lists p-code segments as a series of entries consisting of a 32-bit unsigned offset from the start-of-file followed by a string name. It is terminated by a null entry (32-bit zero, and a null string).

## 3.8 The P-Code

mostly 64-bit, mostly signed, big-endian

The P-Code itself is stored in big-endian format on disk and starts immediately following the P-Code Segment Table. It is terminated by the end-of-file.

Next: 4 Header Codes Up: HAFTA Overlord P-Code Definition Previous: 2 Virtual Machine Contents