Reference

Keurnel Assembly Syntax

This page provides a comprehensive reference for the Keurnel Assembly language used to interact directly with the system's core execution layer. Select an architecture below to view architecture-specific syntax documentation.

Overview

This documentation serves as the definitive guide to the structure, rules, and conventions that govern how low-level instructions are written, interpreted, and executed within the kernel environment. Each architecture page contains specific information about registers, addressing modes, and instruction encoding.

Common Language Grammar

Across all architectures, the assembly language grammar includes:

  • Instruction formats and operand types
  • Addressing modes and register usage
  • Directives and symbolic conventions

Important Considerations

Special attention is given to privilege levels, memory access semantics, interrupt handling, and system call interfaces, ensuring clarity when working in protected or performance-critical contexts.

Common Syntax Rules

The following syntax rules apply across all architectures:

Labels and constants
Macros definitions
Inline annotations
Reserved keywords

Token Types

Token types are fundamental building blocks used during lexical analysis—the first phase of the assembler pipeline. The lexer scans raw source code character by character and groups them into meaningful units called tokens. Each token is classified into a specific type that tells the parser what kind of element it represents.

These token types are used for syntax highlighting in IDEs, error detection, and building the Abstract Syntax Tree (AST) that represents your assembly program's structure. The following token types are recognized across all architectures:

TokenWhitespace

Represents a sequence of whitespace characters (spaces, tabs, newlines).

spacestabs (\t)newlines (\n)
TokenComment

Represents a comment in the source code (e.g., lines starting with ';').

; This is a comment
TokenIdentifier

Represents an identifier (e.g., variable names, labels).

myLabel_counterloop_start
TokenDirective

Represents an assembler directive (e.g., %define, %include).

%define%include%macro
TokenInstruction

Represents an assembly instruction mnemonic.

MOVADDJMPCALL
TokenRegister

Represents a CPU register (architecture-specific).

RAXR1SP
TokenImmediate

Represents an immediate value (e.g., numeric literals).

420xFF0b1010
TokenString

Represents a string literal (e.g., "Hello, World!").

"Hello, World!"
Reference x86-64

x86-64 Keurnel Assembly Syntax

Complete syntax reference for Keurnel Assembly targeting the x86-64 (AMD64) architecture.

x86-64 (AMD64)

The x86-64 architecture, also known as AMD64 or Intel 64, is a 64-bit extension of the x86 instruction set. It is the dominant architecture for desktop and server computing.

Features

  • 64-bit addressing
  • 16 general-purpose registers
  • SSE/AVX extensions
  • Red zone optimization
  • RIP-relative addressing

x86-64 Registers

General Purpose (64-bit)

RAXRBXRCXRDXRSIRDIRBPRSP

Extended Registers

R8R9R10R11R12R13R14R15

Segment Registers

CSDSESFSGSSS

Addressing Modes

ImmediateMOV RAX, 42

Value encoded directly in instruction

RegisterMOV RAX, RBX

Value stored in a register

DirectMOV RAX, [0x1000]

Value at a fixed memory address

Register IndirectMOV RAX, [RBX]

Value at address in register

Base + DisplacementMOV RAX, [RBX + 8]

Register plus offset

SIBMOV RAX, [RBX + RCX*4]

Scale-Index-Base addressing

x86-64 Token Types

The following token types are specific to x86-64 Keurnel assembly.

Example: x86-64 Keurnel Assembly

; x86-64 Hello World Example
%define SYS_WRITE 1
%define SYS_EXIT 60
%define STDOUT 1

section .data
    msg: db "Hello, World!", 10
    len: equ $ - msg

section .text
    global _start

_start:
    MOV RAX, SYS_WRITE    ; syscall number
    MOV RDI, STDOUT       ; file descriptor
    LEA RSI, [msg]        ; message address
    MOV RDX, len           ; message length
    SYSCALL

    MOV RAX, SYS_EXIT     ; exit syscall
    XOR RDI, RDI          ; exit code 0
    SYSCALL

More Architectures Coming Soon

We're actively working on adding support for ARM64, RISC-V, and other architectures.