WIPIVERSE All articles

Parrot assembly language

Parrot assembly language (often abbreviated PAS) is a low‑level, human‑readable language used to write programs that run on the Parrot virtual machine (Parrot VM). The Parrot VM was originally developed as a target for dynamic languages such as Perl 6, Python, Ruby, and others, with the goal of providing a common runtime environment.

Purpose and Design
PAS provides a textual representation of the bytecode that the Parrot VM executes. It allows developers to:

  • Write assembler‑style code for performance‑critical sections.
  • Inspect, debug, and manually edit compiled code.
  • Serve as an intermediate format when developing higher‑level language front‑ends that compile to Parrot bytecode.

The language is deliberately simple, exposing the VM’s registers, control‑flow instructions, and built‑in operations. It mirrors the structure of the Parrot bytecode, making translation between the two straightforward.

Syntax Overview
A typical PAS file begins with a header defining the version and optionally includes comments preceded by #. Core elements include:

  • Registers – Named as $I0, $N1, $S2, etc., where the prefix indicates the type (integer, floating‑point, string).
  • Instructions – Mnemonic opcodes such as set, add, sub, branch, goto, call, return.
  • Labels – Used for branching, written as label_name:.
  • Constants – Embedded directly or referenced via .const directives.

Example fragment:

# Simple PAS program
.sub main :main
    $I0 = 10
    $I1 = 20
    $I2 = $I0 + $I1
    print $I2
    end
.end

Relationship to Other Parrot Representations
The Parrot project also defined a higher‑level intermediate language called Parrot Intermediate Representation (PIR), which adds abstractions such as high‑level control structures and automatic register allocation. Source code written in PIR is typically compiled to PAS, which is then assembled into Parrot bytecode.

Toolchain

  • pasm – The assembler that translates PAS source files (.pas) into Parrot bytecode (.pbc).
  • pir – A compiler that converts PIR source into PAS before invoking pasm.
  • parrot – The VM executable that loads and runs .pbc files.

Historical Context
Development of the Parrot VM began in 2001 under the Perl 6 (now Raku) community. PAS was introduced early in the project to provide a concrete, testable target for language implementers. Throughout the 2000s, PAS was used for bootstrapping the VM, writing runtime libraries, and creating reference implementations of dynamic languages.

By the mid‑2010s, activity on the Parrot project declined, and the VM was officially declared unmaintained in 2016. Consequently, PAS is rarely used in contemporary language development, though its syntax remains documented in archived Parrot manuals and source repositories.

Current Status

  • The Parrot VM is no longer actively maintained; the official repository is archived.
  • PAS documentation is preserved in the Parrot source tree and historical wiki pages.
  • No major language projects currently target Parrot or PAS for production use.

References

  • Parrot Documentation – Parrot Assembly Language (archived).
  • "The Parrot VM and its Assembly Language", Parrot Project Blog, 2006.
  • Parrot source repository (GitHub, archived).
Browse

More topics to explore

    Browse all articles