Download Latest Version cencio-bin-0.0.12-20261105-win-x64.zip (1.3 MB)
Home / ragman
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2026-11-02 10.3 kB
cencio.sym 2026-11-02 1.1 kB
ragman.eg 2026-11-02 4.1 kB
ragman-src-0.0.7-20261101-perl.zip 2026-11-01 9.7 kB
Totals: 4 Items   25.1 kB 0

Ragman Assembler

Ragman is a two-pass assembler targeting the C1316 execution engine and the Cencio VM: a compact stack-oriented virtual machine designed around a minimal instruction set, explicit scope management, and an extensible runtime.

The VM intentionally keeps its native instruction set small and delegates most computation and platform services to external runtime libraries through system calls (sys). This design keeps the virtual machine simple while allowing rich functionality to be implemented outside the core runtime.

This assembler targets the C1316 virtual CPU and needs a symbol file for translating human readable system calls provided by Cencio to their instruction ids. The full technical reference for the C1316 is present in the documentation folder.

Core Concepts

Stack-Based Execution

The virtual machine uses an operand stack for expression evaluation and parameter passing.

+----------------+
| Operand Stack  |
+----------------+

Most instructions consume values from and/or produce values onto this stack.


Frame-Based Scoping

In addition to the operand stack, the VCPU maintains a stack of frames.

+----------------+
| Frame Stack    |
+----------------+

Frames represent scopes and may be used for:

  • Blocks
  • Loops
  • Function calls

Frames are explicitly managed through bytecode instructions.

frm #0
...
frr

New variables belong to the current frame.

Variable lookup follows the parent chain until a matching variable is found. When a function boundary is found the resolution jumps to the global frame. In this way we can have lexical scoping by using closures and a bounded dynamic scoping that is easy to serialize and avoids the downsides of pure dynamic binding.


Constant Pool

All constants are stored in a constant pool.

The assembler automatically populates the pool with:

  • Numeric literals
  • Floating-point values
  • Strings
  • Blobs
  • Variable names

Instructions reference constants through their pool index.

For example:

.data
  counter: "counter"

creates a constant pool entry that can later be referenced by variable instructions.

Inline literals are also automatically interned into the constant pool:

vrm "counter"

The assembler transparently creates the corresponding constant pool entry.


External Runtime

Arithmetic, floating-point operations, I/O, collections, networking, cryptography, and any other high-level services are intentionally implemented outside the Virtual CPU. C1316 provides a single mechanism:

sys

to invoke runtime functionality. Cencio provides the default serializable runtime.

This keeps the virtual machine small, stable, and extensible. We provide the cencio.sym file in order to make the assembler usable out of the box for the Cencio VM.


Assembly Structure

A Ragman source file consists of up to three sections:

.abi
.data
.code

Only the .code section is mandatory.

.abi
  print: #65 ;  the current version of cencio.sym defines con.writeLine: #65 

.data
  message: "Hello World"

.code
  psh message
  sys print #1
  pop ; sys always leaves a value onto the stack
  hlt #0

ABI Section

The ABI section defines symbolic names for runtime system calls.

.abi
  print: #65
  int.add: #0
  int.lt: #7

Symbols may be imported from an external file:

.abi "cencio.sym"

ABI symbols are used by the sys instruction.

sys print #1

is equivalent to:

sys #65 #1

Data Section

The data section declares constants.

.data
  hello: "Hello"
  answer: 42
  pi: 3.1415926535

Each declaration creates an entry in the constant pool.

hello: "Hello"

defines a constant named hello whose value can later be referenced from code.


Code Section

Executable instructions reside in the code section.

.code
  main:
    hlt #0

Code labels define symbolic addresses.

start:

Labels may be referenced using:

&start

Data Types

Signed Integers

10
-10
0xFF
0b1010
0o755

Supported integer types:

Suffix Type
/b uint8
/s int16
/i int32
/l int64

Examples:

10/b
32767/s
123/i
1000000/l

Floating Point

32-bit:

3.14/f

64-bit:

3.14

or

3.14/d

Strings

"Hello World"

Strings support Unicode text, they are UTF-8 encoded in the bytecode and during serialization; the Cencio ABI provides functions to manage Unicode code points.

Escape sequences:

\"   quote
\\   backslash
\r   carriage return
\n   newline
\t   tab
\e   escape

Example:

"Hello\nWorld"

Binary Blobs

'48656C6C6F'

Each pair of hexadecimal digits produces one byte.


References

Code References

Code references point to labels.

jmp &main

Syntax:

&label

Data References

Data references point to constants declared in the data section.

psh hello

where:

.data
  hello: "Hello"

Variables

Variables are dynamically associated with a frame.

A variable is identified by a constant-pool key.

Three forms may be used:

vrm #42 ; the symbol that in the constant pool has index 42
vrm counter ; points to a data defined in the data section
vrm "counter" ; ragman adds an entry to the constant pool and references it.

All three ultimately identify a constant-pool entry.


Create Variable

vrm counter

Creates a variable in the current frame.

Fails if the variable already exists in that frame.

Semantically equivalent to declaring a variable.


Set Variable

vrs counter

Updates an existing variable.

Lookup proceeds through the current frame and its parents' chain.

Fails if the variable cannot be resolved.

Semantically equivalent to assigning a variable.


Get Variable

vrg counter

Resolves the variable and pushes its value onto the operand stack.

Fails if the variable cannot be resolved.


Multiple Return Values

Functions may return multiple values.

Additional return values are accumulated using:

vry

The last return value is pushed onto the operand stack.

Additional values are stored in the MR multiple return register.

These values can be retrieved using the smr instruction.


Frames

Create Frame

frm #0

Creates and pushes a new block frame.

The operand specifies the frame kind.

Possible frame types may include:

  • 0 Block frames
  • 1 Loop frames

Remove Frame

frr

Removes the current frame.


Closures

A closure may be created from a code reference.

cls &handler

The resulting closure is pushed onto the operand stack.

A closure may later be invoked using:

cal

which consumes a closure from the stack and executes it.


Function Calls

Ragman supports multiple invocation styles.

Subroutine calls:

jsr

where the destination address is popped from the operand stack.

Closure calls:

cal

where the closure object is popped from the operand stack: this provides lexical scoping.

Returns:

ret

Loops

The whl instruction supports loop control.

Typical usage:

frm #1

loop.begin:
  ...
  whl &loop.end
  ...
  jmp &loop.begin

loop.end:
frr

The instruction evaluates the condition value currently on the operand stack and exits the loop when the condition is false.


System Calls

System calls provide access to runtime functionality.

Syntax:

sys <id> <argc>

Examples:

sys #65 #1
sys con.writeLine #1

System calls consume the specified number of arguments from the operand stack.

Example:

psh "Hello"
psh "\n"
sys print #2

The implementation is provided by the Cencio runtime libraries and not by the VCPU itself.


Boolean Normalization

The VM provides the xnr instruction.

xnr #0

This instruction performs a logical XNOR between the operand and the value on the stack.

It is commonly used to:

  • Normalize values to logical booleans
  • Invert boolean results
  • Implement lightweight logical operations

Example Program

.abi "cencio.sym"

.data
  i: "i"

.code
  jmp &main
  body:
    psh 0
    vrm i
    frm #1
    loop.begin:
      vrg i
      psh 12
      sys int.lt #2
      whl &loop.end
      vrg i
      psh "\n"
      sys con.write #2
      pop
      vrg i
      psh 1
      sys int.add #2
      vrs i
      jmp &loop.begin
    loop.end:
    frr
    hlt #0
  main:
    jmp &body

You can compile and run this sample with the following commands:

$ ragman sample.asm $ fuller.exe sample.cxe $ cencio.exe sample.cxe


Design Philosophy

Ragman is the official assembler for the C1316 Virtual Processor and the Cencio Virtual Machine, which are built around a few core principles:

  1. Minimal instruction set.
  2. Explicit scope management through frames.
  3. Constant-pool-based symbol resolution.
  4. Externalized runtime services.
  5. First-class closures.
  6. Support for multiple return values.
  7. Simple and predictable bytecode generation.
  8. Compact fixed-width instructions.
  9. Serialization.

The result is a small but expressive virtual machine suitable for interpreters, scripting environments, embedded runtimes, educational projects, and language experimentation.

Status

The project is still alpha.

Changelog

2026-11-02 (0.0.3)

Added this readme to the project.

Source: README.md, updated 2026-11-02