Standard library

The standard library has three layers:

Layer

Location

Import

Intrinsics

Compiler and niblick/runtime/runtime.asm

Built in

Standard modules

lib/*.nbl

import "lib/<name>.nbl";

Drivers

lib/drivers/*.nbl

Explicit import

Each module is an ordinary Niblick source file. The compiler removes functions and globals that are not reachable, so an unused module contributes no code or RAM.

Module index

Module

Purpose

Intrinsics

Compiler builtins and runtime-backed operations

Print formatting

Compile-time print() expansion

UART

UART setup, byte I/O, formatting, hex input

GPIO

GPIO port reads and writes

Board constants

Voja4 pin and default SPI constants

Display

Display pages, framebuffer, pixels, lines, rectangles

Keys

Front-panel key state and key codes

Time

Clock, Sync, and delays

Power

Auto-off and sleep

System

Raw status and control SFR access

Random

Hardware PRNG helpers

Memory

Nibble and byte memory operations

Strings

RAM and flash string operations, number formatting

Math

Integer helpers, square roots, mapping

Fixed point

Q4.4 fixed-point helpers

Trigonometry

Q4.4 sine and cosine table

Audio

Square-wave output

PDM

PDM sample playback

SPI

Bit-banged SPI mode-0 master

Font

5x8 font glyphs

Text scrolling

Horizontal text scroller

W5500 Ethernet driver

W5500 Ethernet register and socket access

Public and internal modules

The pages above document the public library. lib/wide.nbl, lib/float16.nbl, and lib/float32.nbl are compiler implementation modules. They are loaded automatically when a program uses 64-bit arithmetic or a float type. Their interfaces are documented in 64-bit arithmetic and Soft float.

Import resolution

Imports resolve relative to the importing file, then the repository root, installed data directory, and NIBLICK_PATH entries. See Imports.

Calling conventions

All module functions use the normal Niblick calling convention. Argument and return types follow Types. Stack costs for intrinsics and runtime helpers are listed in Runtime ABI.